mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:36:47 +02:00
Improve performance of drawing GridOverlay3D
This commit is contained in:
parent
16e3887cbc
commit
ad3d7fbfb4
1 changed files with 11 additions and 9 deletions
|
@ -69,9 +69,10 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
||||||
xColor color = getColor();
|
xColor color = getColor();
|
||||||
glm::vec3 position = getPosition();
|
glm::vec3 position = getPosition();
|
||||||
|
|
||||||
const int GRID_DIVISIONS = 300;
|
const int MINOR_GRID_DIVISIONS = 100;
|
||||||
|
const int MAJOR_GRID_DIVISIONS = 50;
|
||||||
const float MAX_COLOR = 255.0f;
|
const float MAX_COLOR = 255.0f;
|
||||||
float scale = GRID_DIVISIONS * spacing;
|
|
||||||
|
|
||||||
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
|
||||||
|
|
||||||
|
@ -80,12 +81,13 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
||||||
// Minor grid
|
// Minor grid
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
{
|
{
|
||||||
glTranslatef(_minorGridWidth * (floorf(rotated.x / spacing) - GRID_DIVISIONS / 2),
|
glTranslatef(_minorGridWidth * (floorf(rotated.x / spacing) - MINOR_GRID_DIVISIONS / 2),
|
||||||
spacing * (floorf(rotated.y / spacing) - GRID_DIVISIONS / 2), position.z);
|
spacing * (floorf(rotated.y / spacing) - MINOR_GRID_DIVISIONS / 2), position.z);
|
||||||
|
|
||||||
|
float scale = MINOR_GRID_DIVISIONS * spacing;
|
||||||
glScalef(scale, scale, scale);
|
glScalef(scale, scale, scale);
|
||||||
|
|
||||||
Application::getInstance()->getGeometryCache()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
|
Application::getInstance()->getGeometryCache()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
@ -94,13 +96,13 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
||||||
{
|
{
|
||||||
glLineWidth(4.0f);
|
glLineWidth(4.0f);
|
||||||
spacing *= _majorGridEvery;
|
spacing *= _majorGridEvery;
|
||||||
glTranslatef(spacing * (floorf(rotated.x / spacing) - GRID_DIVISIONS / 2),
|
glTranslatef(spacing * (floorf(rotated.x / spacing) - MAJOR_GRID_DIVISIONS / 2),
|
||||||
spacing * (floorf(rotated.y / spacing) - GRID_DIVISIONS / 2), position.z);
|
spacing * (floorf(rotated.y / spacing) - MAJOR_GRID_DIVISIONS / 2), position.z);
|
||||||
|
|
||||||
scale *= _majorGridEvery;
|
float scale = MAJOR_GRID_DIVISIONS * spacing;
|
||||||
glScalef(scale, scale, scale);
|
glScalef(scale, scale, scale);
|
||||||
|
|
||||||
Application::getInstance()->getGeometryCache()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
|
Application::getInstance()->getGeometryCache()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue