Cleaning up a missing constructor and adjusting the stride for the StrucBuffer by default + merging with upstream

This commit is contained in:
samcake 2016-10-11 17:13:08 -07:00
parent eea5118eab
commit 77062ac1b3
3 changed files with 18 additions and 4 deletions

View file

@ -384,12 +384,12 @@ public:
template <class T> class StructBuffer : public gpu::BufferView {
public:
static BufferPointer makeBuffer() {
T t;
return std::make_shared<gpu::Buffer>(sizeof(T), (const gpu::Byte*) &t);
template <class U> static BufferPointer makeBuffer() {
U t;
return std::make_shared<gpu::Buffer>(sizeof(U), (const gpu::Byte*) &t, sizeof(U));
}
~StructBuffer<T>() {};
StructBuffer<T>() : gpu::BufferView(makeBuffer()) {}
StructBuffer<T>() : gpu::BufferView(makeBuffer<T>()) {}
T& edit() {

View file

@ -44,6 +44,17 @@ enum LightClusterGridShader_BufferSlot {
LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
};
FrustumGrid::FrustumGrid(const FrustumGrid& source) :
frustumNear(source.frustumNear),
rangeNear(source.rangeNear),
rangeFar(source.rangeFar),
frustumFar(source.frustumFar),
dims(source.dims),
spare(source.spare),
eyeToGridProj(source.eyeToGridProj),
worldToEyeMat(source.worldToEyeMat),
eyeToWorldMat(source.eyeToWorldMat)
{}
void FrustumGrid::generateGridPlanes(Planes& xPlanes, Planes& yPlanes, Planes& zPlanes) {
xPlanes.resize(dims.x + 1);

View file

@ -33,6 +33,9 @@ public:
glm::mat4 worldToEyeMat;
glm::mat4 eyeToWorldMat;
FrustumGrid() = default;
FrustumGrid(const FrustumGrid& source);
void updateFrustum(const ViewFrustum& frustum) {
frustumNear = frustum.getNearClip();
frustumFar = frustum.getFarClip();