Naming coding standard

This commit is contained in:
Atlante45 2016-01-11 13:26:47 -08:00
parent 205c14eb43
commit c30569cd55
4 changed files with 31 additions and 26 deletions

View file

@ -362,8 +362,8 @@ bool Batch::isSkyboxEnabled() const {
void Batch::setupNamedCalls(const std::string& instanceName, size_t count, NamedBatchData::Function function) { void Batch::setupNamedCalls(const std::string& instanceName, size_t count, NamedBatchData::Function function) {
NamedBatchData& instance = _namedData[instanceName]; NamedBatchData& instance = _namedData[instanceName];
instance._count += count; instance.count += count;
instance._function = function; instance.function = function;
} }
void Batch::setupNamedCalls(const std::string& instanceName, NamedBatchData::Function function) { void Batch::setupNamedCalls(const std::string& instanceName, NamedBatchData::Function function) {
@ -372,13 +372,13 @@ void Batch::setupNamedCalls(const std::string& instanceName, NamedBatchData::Fun
BufferPointer Batch::getNamedBuffer(const std::string& instanceName, uint8_t index) { BufferPointer Batch::getNamedBuffer(const std::string& instanceName, uint8_t index) {
NamedBatchData& instance = _namedData[instanceName]; NamedBatchData& instance = _namedData[instanceName];
if (instance._buffers.size() <= index) { if (instance.buffers.size() <= index) {
instance._buffers.resize(index + 1); instance.buffers.resize(index + 1);
} }
if (!instance._buffers[index]) { if (!instance.buffers[index]) {
instance._buffers[index].reset(new Buffer()); instance.buffers[index].reset(new Buffer());
} }
return instance._buffers[index]; return instance.buffers[index];
} }
void Batch::preExecute() { void Batch::preExecute() {

View file

@ -49,14 +49,13 @@ public:
using BufferPointers = std::vector<BufferPointer>; using BufferPointers = std::vector<BufferPointer>;
using Function = std::function<void(gpu::Batch&, NamedBatchData&)>; using Function = std::function<void(gpu::Batch&, NamedBatchData&)>;
std::once_flag _once; BufferPointers buffers;
BufferPointers _buffers; size_t count { 0 };
size_t _count{ 0 }; Function function;
Function _function;
void process(Batch& batch) { void process(Batch& batch) {
if (_function) { if (function) {
_function(batch, *this); function(batch, *this);
} }
} }
}; };

View file

@ -1854,16 +1854,18 @@ void renderInstances(const std::string& name, gpu::Batch& batch, const Transform
void GeometryCache::renderSolidSphereInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) { void GeometryCache::renderSolidSphereInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) {
static const std::string INSTANCE_NAME = __FUNCTION__; static const std::string INSTANCE_NAME = __FUNCTION__;
renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, GeometryCache::Sphere, data._count, DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, GeometryCache::Sphere, data.count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]); data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
}); });
} }
void GeometryCache::renderWireSphereInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) { void GeometryCache::renderWireSphereInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) {
static const std::string INSTANCE_NAME = __FUNCTION__; static const std::string INSTANCE_NAME = __FUNCTION__;
renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, GeometryCache::Sphere, data._count, DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, GeometryCache::Sphere, data.count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]); data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
}); });
} }
@ -1901,17 +1903,20 @@ void GeometryCache::renderSolidCubeInstance(gpu::Batch& batch, const Transform&
// For the first half second for a given shape, show the wireframe, for the second half, show the solid. // For the first half second for a given shape, show the wireframe, for the second half, show the solid.
if (fractionalSeconds > 0.5f) { if (fractionalSeconds > 0.5f) {
DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data._count, DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]); data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
} else { } else {
DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data._count, DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]); data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
} }
}); });
#else #else
renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
DependencyManager::get<GeometryCache>()->renderCubeInstances(batch, data._count, DependencyManager::get<GeometryCache>()->renderCubeInstances(batch, data.count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]); data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
}); });
#endif #endif
} }
@ -1919,8 +1924,9 @@ void GeometryCache::renderSolidCubeInstance(gpu::Batch& batch, const Transform&
void GeometryCache::renderWireCubeInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) { void GeometryCache::renderWireCubeInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) {
static const std::string INSTANCE_NAME = __FUNCTION__; static const std::string INSTANCE_NAME = __FUNCTION__;
renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
DependencyManager::get<GeometryCache>()->renderWireCubeInstances(batch, data._count, DependencyManager::get<GeometryCache>()->renderWireCubeInstances(batch, data.count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]); data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
}); });
} }

View file

@ -246,7 +246,7 @@ public:
batch.setModelTransform(Transform()); batch.setModelTransform(Transform());
batch.setPipeline(_pipeline); batch.setPipeline(_pipeline);
batch._glUniform1i(_instanceLocation, 1); batch._glUniform1i(_instanceLocation, 1);
geometryCache->renderWireShapeInstances(batch, GeometryCache::Line, data._count, transformBuffer, colorBuffer); geometryCache->renderWireShapeInstances(batch, GeometryCache::Line, data.count, transformBuffer, colorBuffer);
batch._glUniform1i(_instanceLocation, 0); batch._glUniform1i(_instanceLocation, 0);
}); });
} }