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) {
NamedBatchData& instance = _namedData[instanceName];
instance._count += count;
instance._function = function;
instance.count += count;
instance.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) {
NamedBatchData& instance = _namedData[instanceName];
if (instance._buffers.size() <= index) {
instance._buffers.resize(index + 1);
if (instance.buffers.size() <= index) {
instance.buffers.resize(index + 1);
}
if (!instance._buffers[index]) {
instance._buffers[index].reset(new Buffer());
if (!instance.buffers[index]) {
instance.buffers[index].reset(new Buffer());
}
return instance._buffers[index];
return instance.buffers[index];
}
void Batch::preExecute() {

View file

@ -49,14 +49,13 @@ public:
using BufferPointers = std::vector<BufferPointer>;
using Function = std::function<void(gpu::Batch&, NamedBatchData&)>;
std::once_flag _once;
BufferPointers _buffers;
size_t _count{ 0 };
Function _function;
BufferPointers buffers;
size_t count { 0 };
Function function;
void process(Batch& batch) {
if (_function) {
_function(batch, *this);
if (function) {
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) {
static const std::string INSTANCE_NAME = __FUNCTION__;
renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, GeometryCache::Sphere, data._count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]);
DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, GeometryCache::Sphere, data.count,
data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
});
}
void GeometryCache::renderWireSphereInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) {
static const std::string INSTANCE_NAME = __FUNCTION__;
renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, GeometryCache::Sphere, data._count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]);
DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, GeometryCache::Sphere, data.count,
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.
if (fractionalSeconds > 0.5f) {
DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data._count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]);
DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count,
data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
} else {
DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data._count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]);
DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count,
data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
}
});
#else
renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
DependencyManager::get<GeometryCache>()->renderCubeInstances(batch, data._count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]);
DependencyManager::get<GeometryCache>()->renderCubeInstances(batch, data.count,
data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
});
#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) {
static const std::string INSTANCE_NAME = __FUNCTION__;
renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
DependencyManager::get<GeometryCache>()->renderWireCubeInstances(batch, data._count,
data._buffers[INSTANCE_TRANSFORM_BUFFER], data._buffers[INSTANCE_COLOR_BUFFER]);
DependencyManager::get<GeometryCache>()->renderWireCubeInstances(batch, data.count,
data.buffers[INSTANCE_TRANSFORM_BUFFER],
data.buffers[INSTANCE_COLOR_BUFFER]);
});
}

View file

@ -246,7 +246,7 @@ public:
batch.setModelTransform(Transform());
batch.setPipeline(_pipeline);
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);
});
}