mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 17:26:24 +02:00
Merge branch '20660' of github.com:thoys/hifi into 20660
This commit is contained in:
commit
90c8200d66
3 changed files with 33 additions and 18 deletions
|
@ -35,19 +35,33 @@ using namespace std;
|
|||
void renderWorldBox(gpu::Batch& batch) {
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
// Show edge of world
|
||||
// Show center of world
|
||||
static const glm::vec3 red(1.0f, 0.0f, 0.0f);
|
||||
static const glm::vec3 green(0.0f, 1.0f, 0.0f);
|
||||
static const glm::vec3 blue(0.0f, 0.0f, 1.0f);
|
||||
static const glm::vec3 grey(0.5f, 0.5f, 0.5f);
|
||||
|
||||
static const glm::vec4 DASHED_RED(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
static const glm::vec4 DASHED_GREEN(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
static const glm::vec4 DASHED_BLUE(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
static const float DASH_LENGTH = 0.5;
|
||||
static const float GAP_LENGTH = 0.5;
|
||||
auto transform = Transform{};
|
||||
|
||||
batch.setModelTransform(transform);
|
||||
|
||||
// TODO - consider alternate rendering for negative build-able space in the domain
|
||||
|
||||
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(HALF_TREE_SCALE, 0.0f, 0.0f), red);
|
||||
geometryCache->renderDashedLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(-HALF_TREE_SCALE, 0.0f, 0.0f), DASHED_RED,
|
||||
DASH_LENGTH, GAP_LENGTH);
|
||||
|
||||
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, HALF_TREE_SCALE, 0.0f), green);
|
||||
geometryCache->renderDashedLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, -HALF_TREE_SCALE, 0.0f), DASHED_GREEN,
|
||||
DASH_LENGTH, GAP_LENGTH);
|
||||
|
||||
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, HALF_TREE_SCALE), blue);
|
||||
geometryCache->renderDashedLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, -HALF_TREE_SCALE), DASHED_BLUE,
|
||||
DASH_LENGTH, GAP_LENGTH);
|
||||
|
||||
geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, HALF_TREE_SCALE), glm::vec3(HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), grey);
|
||||
geometryCache->renderLine(batch, glm::vec3(HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), glm::vec3(HALF_TREE_SCALE, 0.0f, 0.0f), grey);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in
|
|||
|
||||
int vertices = slices * (stacks - 1) + 2;
|
||||
int indices = slices * (stacks - 1) * NUM_VERTICES_PER_TRIANGULATED_QUAD;
|
||||
|
||||
|
||||
if ((registered && (!_registeredSphereVertices.contains(id) || _lastRegisteredSphereVertices[id] != radiusKey))
|
||||
|| (!registered && !_sphereVertices.contains(radiusKey))) {
|
||||
|
||||
|
@ -80,7 +80,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in
|
|||
qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED VERTICES BUFFER";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
||||
if (registered) {
|
||||
_registeredSphereVertices[id] = verticesBuffer;
|
||||
|
@ -134,7 +134,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in
|
|||
qCDebug(renderutils) << "renderSphere()... REUSING PREVIOUSLY REGISTERED VERTICES BUFFER";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if ((registered && (!_registeredSphereIndices.contains(id) || _lastRegisteredSphereIndices[id] != slicesStacksKey))
|
||||
|| (!registered && !_sphereIndices.contains(slicesStacksKey))) {
|
||||
|
||||
|
@ -1327,7 +1327,9 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons
|
|||
batch.draw(gpu::TRIANGLE_STRIP, 4, 0);
|
||||
}
|
||||
|
||||
void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
|
||||
void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color,
|
||||
const float dash_length, const float gap_length, int id) {
|
||||
|
||||
bool registered = (id != UNKNOWN_ID);
|
||||
Vec3PairVec2Pair key(Vec3Pair(start, end), Vec2Pair(glm::vec2(color.x, color.y), glm::vec2(color.z, color.w)));
|
||||
BatchItemDetails& details = registered ? _registeredDashedLines[id] : _dashedLines[key];
|
||||
|
@ -1351,16 +1353,14 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start,
|
|||
((int(color.w * 255.0f) & 0xFF) << 24);
|
||||
|
||||
// draw each line segment with appropriate gaps
|
||||
const float DASH_LENGTH = 0.05f;
|
||||
const float GAP_LENGTH = 0.025f;
|
||||
const float SEGMENT_LENGTH = DASH_LENGTH + GAP_LENGTH;
|
||||
const float SEGMENT_LENGTH = dash_length + gap_length;
|
||||
float length = glm::distance(start, end);
|
||||
float segmentCount = length / SEGMENT_LENGTH;
|
||||
int segmentCountFloor = (int)glm::floor(segmentCount);
|
||||
|
||||
glm::vec3 segmentVector = (end - start) / segmentCount;
|
||||
glm::vec3 dashVector = segmentVector / SEGMENT_LENGTH * DASH_LENGTH;
|
||||
glm::vec3 gapVector = segmentVector / SEGMENT_LENGTH * GAP_LENGTH;
|
||||
glm::vec3 dashVector = segmentVector / SEGMENT_LENGTH * dash_length;
|
||||
glm::vec3 gapVector = segmentVector / SEGMENT_LENGTH * gap_length;
|
||||
|
||||
const int FLOATS_PER_VERTEX = 3;
|
||||
details.vertices = (segmentCountFloor + 1) * 2;
|
||||
|
@ -1394,7 +1394,7 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start,
|
|||
*(vertex++) = point.y;
|
||||
*(vertex++) = point.z;
|
||||
*(colorDataAt++) = compactColor;
|
||||
|
||||
|
||||
for (int i = 0; i < segmentCountFloor; i++) {
|
||||
point += dashVector;
|
||||
*(vertex++) = point.x;
|
||||
|
|
|
@ -183,7 +183,8 @@ public:
|
|||
void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||
|
||||
void renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id = UNKNOWN_ID);
|
||||
void renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color,
|
||||
const float dash_length = 0.05f, const float gap_length = 0.025f, int id = UNKNOWN_ID);
|
||||
|
||||
void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, const glm::vec3& color, int id = UNKNOWN_ID)
|
||||
{ renderLine(batch, p1, p2, glm::vec4(color, 1.0f), id); }
|
||||
|
@ -193,9 +194,9 @@ public:
|
|||
|
||||
|
||||
void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID)
|
||||
const glm::vec3& color1, const glm::vec3& color2, int id = UNKNOWN_ID)
|
||||
{ renderLine(batch, p1, p2, glm::vec4(color1, 1.0f), glm::vec4(color2, 1.0f), id); }
|
||||
|
||||
|
||||
void renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2,
|
||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||
|
||||
|
@ -215,7 +216,7 @@ public:
|
|||
private:
|
||||
GeometryCache();
|
||||
virtual ~GeometryCache();
|
||||
|
||||
|
||||
typedef QPair<int, int> IntPair;
|
||||
typedef QPair<unsigned int, unsigned int> VerticesIndices;
|
||||
|
||||
|
@ -246,7 +247,7 @@ private:
|
|||
~BatchItemDetails();
|
||||
void clear();
|
||||
};
|
||||
|
||||
|
||||
QHash<IntPair, VerticesIndices> _coneVBOs;
|
||||
|
||||
int _nextID;
|
||||
|
|
Loading…
Reference in a new issue