Fix line entity rendering

This commit is contained in:
Atlante45 2015-06-04 10:54:57 +02:00
parent e421485908
commit 166eff7df1
2 changed files with 20 additions and 18 deletions

View file

@ -24,32 +24,32 @@ EntityItemPointer RenderableLineEntityItem::factory(const EntityItemID& entityID
return EntityItemPointer(new RenderableLineEntityItem(entityID, properties));
}
void RenderableLineEntityItem::updateGeometry() {
auto geometryCache = DependencyManager::get<GeometryCache>();
if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
_lineVerticesID = geometryCache ->allocateID();
}
if (_pointsChanged) {
glm::vec4 lineColor(toGlm(getXColor()), getLocalRenderAlpha());
geometryCache->updateVertices(_lineVerticesID, getLinePoints(), lineColor);
_pointsChanged = false;
}
}
void RenderableLineEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("RenderableLineEntityItem::render");
Q_ASSERT(getType() == EntityTypes::Line);
glm::vec3 p1 = ENTITY_ITEM_ZERO_VEC3;
glm::vec3 p2 = getDimensions();
glm::vec4 lineColor(toGlm(getXColor()), getLocalRenderAlpha());
Q_ASSERT(args->_batch);
gpu::Batch& batch = *args->_batch;
batch.setModelTransform(getTransformToCenter());
glLineWidth(getLineWidth());
auto geometryCache = DependencyManager::get<GeometryCache>();
if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
_lineVerticesID = geometryCache ->allocateID();
}
//TODO: Figure out clean , efficient way to do relative line positioning. For now we'll just use absolute positioning.
//glTranslatef(position.x, position.y, position.z);
//glm::vec3 axis = glm::axis(rotation);
//glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
if (_pointsChanged) {
geometryCache->updateVertices(_lineVerticesID, getLinePoints(), lineColor);
_pointsChanged = false;
}
geometryCache->renderVertices(gpu::LINE_STRIP, _lineVerticesID);
// TODO: Figure out clean , efficient way to do relative line positioning. For now we'll just use absolute positioning.
//batch.setModelTransform(getTransformToCenter());
batch.setModelTransform(Transform());
batch._glLineWidth(getLineWidth());
DependencyManager::get<GeometryCache>()->renderVertices(batch, gpu::LINE_STRIP, _lineVerticesID);
RenderableDebugableEntityItem::render(this, args);
};

View file

@ -31,6 +31,8 @@ public:
SIMPLE_RENDERABLE()
protected:
void updateGeometry();
int _lineVerticesID;
};