mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
quads painting
This commit is contained in:
parent
32eade9ead
commit
101400809a
4 changed files with 36 additions and 8 deletions
|
@ -39,7 +39,7 @@ void RenderableLineEntityItem::updateGeometry() {
|
||||||
void RenderableLineEntityItem::render(RenderArgs* args) {
|
void RenderableLineEntityItem::render(RenderArgs* args) {
|
||||||
PerformanceTimer perfTimer("RenderableLineEntityItem::render");
|
PerformanceTimer perfTimer("RenderableLineEntityItem::render");
|
||||||
Q_ASSERT(getType() == EntityTypes::Line);
|
Q_ASSERT(getType() == EntityTypes::Line);
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
|
|
||||||
Q_ASSERT(args->_batch);
|
Q_ASSERT(args->_batch);
|
||||||
gpu::Batch& batch = *args->_batch;
|
gpu::Batch& batch = *args->_batch;
|
||||||
|
|
|
@ -31,7 +31,7 @@ void RenderableQuadEntityItem::updateGeometry() {
|
||||||
}
|
}
|
||||||
if (_pointsChanged) {
|
if (_pointsChanged) {
|
||||||
glm::vec4 lineColor(toGlm(getXColor()), getLocalRenderAlpha());
|
glm::vec4 lineColor(toGlm(getXColor()), getLocalRenderAlpha());
|
||||||
geometryCache->updateVertices(_lineVerticesID, getLinePoints(), lineColor);
|
geometryCache->updateVertices(_lineVerticesID, getQuadVertices(), lineColor);
|
||||||
_pointsChanged = false;
|
_pointsChanged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ void RenderableQuadEntityItem::render(RenderArgs* args) {
|
||||||
batch.setModelTransform(transform);
|
batch.setModelTransform(transform);
|
||||||
|
|
||||||
batch._glLineWidth(getLineWidth());
|
batch._glLineWidth(getLineWidth());
|
||||||
if (getLinePoints().size() > 1) {
|
if (getLinePoints().size() > 3) {
|
||||||
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch);
|
DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(batch);
|
||||||
DependencyManager::get<GeometryCache>()->renderVertices(batch, gpu::LINE_STRIP, _lineVerticesID);
|
DependencyManager::get<GeometryCache>()->renderVertices(batch, gpu::QUAD_STRIP, _lineVerticesID);
|
||||||
}
|
}
|
||||||
batch._glLineWidth(1.0f);
|
batch._glLineWidth(1.0f);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const float QuadEntityItem::DEFAULT_LINE_WIDTH = 2.0f;
|
const float QuadEntityItem::DEFAULT_LINE_WIDTH = 0.1f;
|
||||||
const int QuadEntityItem::MAX_POINTS_PER_LINE = 70;
|
const int QuadEntityItem::MAX_POINTS_PER_LINE = 70;
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ QuadEntityItem::QuadEntityItem(const EntityItemID& entityItemID, const EntityIte
|
||||||
EntityItem(entityItemID) ,
|
EntityItem(entityItemID) ,
|
||||||
_lineWidth(DEFAULT_LINE_WIDTH),
|
_lineWidth(DEFAULT_LINE_WIDTH),
|
||||||
_pointsChanged(true),
|
_pointsChanged(true),
|
||||||
_points(QVector<glm::vec3>(0))
|
_points(QVector<glm::vec3>(0)),
|
||||||
|
_quadVertices(QVector<glm::vec3>(0))
|
||||||
{
|
{
|
||||||
_type = EntityTypes::Quad;
|
_type = EntityTypes::Quad;
|
||||||
_created = properties.getCreated();
|
_created = properties.getCreated();
|
||||||
|
@ -105,6 +106,20 @@ bool QuadEntityItem::setLinePoints(const QVector<glm::vec3>& points) {
|
||||||
if (points.size() > MAX_POINTS_PER_LINE) {
|
if (points.size() > MAX_POINTS_PER_LINE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//Check to see if points actually changed. If they haven't, return before doing anything else
|
||||||
|
if (points.size() == _points.size()) {
|
||||||
|
//same number of points, so now compare every point
|
||||||
|
for (int i = 0; i < points.size(); i++ ) {
|
||||||
|
if (points.at(i) != _points.at(i)){
|
||||||
|
_pointsChanged = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!_pointsChanged) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < points.size(); i++) {
|
for (int i = 0; i < points.size(); i++) {
|
||||||
glm::vec3 point = points.at(i);
|
glm::vec3 point = points.at(i);
|
||||||
glm::vec3 pos = getPosition();
|
glm::vec3 pos = getPosition();
|
||||||
|
@ -115,9 +130,18 @@ bool QuadEntityItem::setLinePoints(const QVector<glm::vec3>& points) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_points = points;
|
_points = points;
|
||||||
_pointsChanged = true;
|
//All our points are valid and at least one point has changed, now create quads from points
|
||||||
|
_quadVertices.clear();
|
||||||
|
for (int i = 0; i < points.size(); i++) {
|
||||||
|
glm::vec3 point = points.at(i);
|
||||||
|
|
||||||
|
glm::vec3 p1 = glm::vec3(point.x - _lineWidth, point.y - _lineWidth, point.z);
|
||||||
|
glm::vec3 p2 = glm::vec3(point.x + _lineWidth, point.y - _lineWidth, point.z);
|
||||||
|
glm::vec3 p3 = glm::vec3(point.x + _lineWidth, point.y + _lineWidth, point.z);
|
||||||
|
glm::vec3 p4 = glm::vec3(point.x - _lineWidth, point.y + _lineWidth, point.z);
|
||||||
|
_quadVertices << p1 << p2 << p3 << p4;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,9 @@ class QuadEntityItem : public EntityItem {
|
||||||
bool setLinePoints(const QVector<glm::vec3>& points);
|
bool setLinePoints(const QVector<glm::vec3>& points);
|
||||||
bool appendPoint(const glm::vec3& point);
|
bool appendPoint(const glm::vec3& point);
|
||||||
|
|
||||||
|
const QVector<glm::vec3>& getQuadVertices() const{ return _quadVertices; }
|
||||||
|
|
||||||
|
|
||||||
const QVector<glm::vec3>& getLinePoints() const{ return _points; }
|
const QVector<glm::vec3>& getLinePoints() const{ return _points; }
|
||||||
|
|
||||||
virtual ShapeType getShapeType() const { return SHAPE_TYPE_LINE; }
|
virtual ShapeType getShapeType() const { return SHAPE_TYPE_LINE; }
|
||||||
|
@ -76,6 +79,7 @@ class QuadEntityItem : public EntityItem {
|
||||||
float _lineWidth;
|
float _lineWidth;
|
||||||
bool _pointsChanged;
|
bool _pointsChanged;
|
||||||
QVector<glm::vec3> _points;
|
QVector<glm::vec3> _points;
|
||||||
|
QVector<glm::vec3> _quadVertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_QuadEntityItem_h
|
#endif // hifi_QuadEntityItem_h
|
||||||
|
|
Loading…
Reference in a new issue