diff --git a/Ground.cpp b/Ground.cpp index fff7c1ed..cad91fec 100644 --- a/Ground.cpp +++ b/Ground.cpp @@ -255,9 +255,9 @@ void TGroundNode::RaRenderVBO() glDrawArrays(iType, iVboPtr, iNumVerts); // Narysuj naraz wszystkie trójkąty } -void TGroundNode::Compile(bool many) +void TGroundNode::Compile( Math3D::vector3 const &Origin, bool const Multiple ) { // tworzenie skompilowanej listy w wyświetlaniu DL - if (!many) + if (false == Multiple) { // obsługa pojedynczej listy if (DisplayListID) Release(); @@ -273,9 +273,9 @@ void TGroundNode::Compile(bool many) glBegin(iType); for (int i = 0; i < iNumPts; ++i) glVertex3d( - Points[i].x - m_rootposition.x, - Points[i].y - m_rootposition.y, - Points[i].z - m_rootposition.z ); + Points[i].x - Origin.x, + Points[i].y - Origin.y, + Points[i].z - Origin.z ); glEnd(); } else if (iType == GL_TRIANGLE_STRIP || iType == GL_TRIANGLE_FAN || iType == GL_TRIANGLES) @@ -293,9 +293,9 @@ void TGroundNode::Compile(bool many) Vertices[i].tu, Vertices[i].tv); glVertex3d( - Points[i].x - m_rootposition.x, - Points[i].y - m_rootposition.y, - Points[i].z - m_rootposition.z ); + Vertices[i].Point.x - Origin.x, + Vertices[i].Point.y - Origin.y, + Vertices[i].Point.z - Origin.z ); } glEnd(); } @@ -318,7 +318,7 @@ void TGroundNode::Compile(bool many) n = n->nNext3; // następny z listy } } - if (!many) + if (false == Multiple) if (Global::bManageNodes) glEndList(); }; @@ -392,6 +392,7 @@ void TSubRect::NodeAdd(TGroundNode *Node) case TP_TRACK: // TODO: tory z cieniem (tunel, canyon) też dać bez łączenia? ++iTracks; // jeden tor więcej Node->pTrack->RaOwnerSet(this); // do którego sektora ma zgłaszać animację +/* if( ( true == Global::bUseVBO ) || ( false == Node->pTrack->IsGroupable() ) ) { // tory ruchome nie są grupowane przy Display Lists (wymagają odświeżania DL) @@ -427,6 +428,11 @@ void TSubRect::NodeAdd(TGroundNode *Node) nMeshed = Node; } // do podzielenia potem } +*/ + // NOTE: track merge code temporarily disabled to simplify implementation of camera-centric rendering + // TODO: re-implement merge for both render paths down the road + RaNodeAdd( Node ); + break; case GL_TRIANGLE_STRIP: case GL_TRIANGLE_FAN: @@ -940,8 +946,10 @@ TGroundRect::Init() { - glm::vec3( 500.0f, 0.0f, 500.0f ) // 'upper left' corner of rectangle + glm::vec3( subrectsize * 0.5f, 0.0f, subrectsize * 0.5f ) // center of sub-rectangle + glm::vec3( subrectsize * column, 0.0f, subrectsize * row ); +/* // NOTE: the actual coordinates get swapped, as they're swapped in rest of the code :x area.center = glm::vec3( area.center.z, area.center.y, area.center.x ); +*/ area.radius = subrectsize * M_SQRT2; } } @@ -962,16 +970,23 @@ void TGroundRect::RenderDL() nRender->DisplayListID = glGenLists(1); glNewList(nRender->DisplayListID, GL_COMPILE); nRender->iVersion = Global::iReCompile; // aktualna wersja siatek + auto const origin = Math3D::vector3( m_area.center.x, m_area.center.y, m_area.center.z ); for (TGroundNode *node = nRender; node; node = node->nNext3) // następny tej grupy - node->Compile(true); + node->Compile(origin, true); glEndList(); } GfxRenderer.Render( nRender ); // nieprzezroczyste trójkąty kwadratu kilometrowego } - if( nRootMesh ) + // submodels geometry is world-centric, so at least for the time being we need to pop the stack early + ::glPopMatrix(); + if( nRootMesh ) { GfxRenderer.Render( nRootMesh ); + } iLastDisplay = iFrameNumber; // drugi raz nie potrzeba } + else { + ::glPopMatrix(); + } #else if( iLastDisplay != iFrameNumber ) { // tylko jezeli dany kwadrat nie był jeszcze renderowany LoadNodes(); // ewentualne tworzenie siatek @@ -1898,7 +1913,7 @@ TSubRect * TGround::FastGetSubRect(int iCol, int iRow) sc = iCol - bc * iNumSubRects; if ((br < 0) || (bc < 0) || (br >= iNumRects) || (bc >= iNumRects)) return NULL; - return (Rects[br][bc].FastGetRect(sc, sr)); + return (Rects[bc][br].FastGetRect(sc, sr)); } TSubRect * TGround::GetSubRect(int iCol, int iRow) @@ -1910,7 +1925,7 @@ TSubRect * TGround::GetSubRect(int iCol, int iRow) sc = iCol - bc * iNumSubRects; if ((br < 0) || (bc < 0) || (br >= iNumRects) || (bc >= iNumRects)) return NULL; // jeśli poza mapą - return (Rects[br][bc].SafeGetRect(sc, sr)); // pobranie małego kwadratu + return (Rects[bc][br].SafeGetRect(sc, sr)); // pobranie małego kwadratu } TEvent * TGround::FindEvent(const std::string &asEventName) diff --git a/Ground.h b/Ground.h index ca2aced2..4ee33f16 100644 --- a/Ground.h +++ b/Ground.h @@ -166,7 +166,7 @@ public: return NULL; }; - void Compile(bool many = false); + void Compile(Math3D::vector3 const &Origin, bool const Multiple = false); void Release(); void RenderHidden(); // obsługa dźwięków i wyzwalaczy zdarzeń @@ -341,16 +341,15 @@ class TGround { return &Rects[GetColFromX(x) / iNumSubRects][GetRowFromZ(z) / iNumSubRects]; }; + TSubRect * GetSubRect( int iCol, int iRow ); TSubRect * GetSubRect(double x, double z) { return GetSubRect(GetColFromX(x), GetRowFromZ(z)); }; - TSubRect * FastGetSubRect(double x, double z) - { - return FastGetSubRect(GetColFromX(x), GetRowFromZ(z)); + TSubRect * FastGetSubRect( int iCol, int iRow ); + TSubRect * FastGetSubRect( double x, double z ) { + return FastGetSubRect( GetColFromX( x ), GetRowFromZ( z ) ); }; - TSubRect * GetSubRect(int iCol, int iRow); - TSubRect * FastGetSubRect(int iCol, int iRow); int GetRowFromZ(double z) { return (int)(z / fSubRectSize + fHalfTotalNumSubRects); diff --git a/Model3d.cpp b/Model3d.cpp index a6e0845f..7eb1493f 100644 --- a/Model3d.cpp +++ b/Model3d.cpp @@ -1828,6 +1828,8 @@ TSubModel *TModel3d::TerrainSquare(int n) void TModel3d::TerrainRenderVBO(int n) { // renderowanie terenu z VBO glPushMatrix(); + ::glTranslated( -Global::pCameraPosition.x, -Global::pCameraPosition.y, -Global::pCameraPosition.z ); + // glTranslated(vPosition->x,vPosition->y,vPosition->z); // if (vAngle->y!=0.0) glRotated(vAngle->y,0.0,1.0,0.0); // if (vAngle->x!=0.0) glRotated(vAngle->x,1.0,0.0,0.0); diff --git a/Track.cpp b/Track.cpp index ddb669cc..d42a3c91 100644 --- a/Track.cpp +++ b/Track.cpp @@ -1447,19 +1447,19 @@ void TTrack::Compile(GLuint tex) if( SwitchExtension->iRoads == 3 ) { // mogą być tylko 3 drogi zamiast 4 SwitchExtension->iPoints = - 5 + SwitchExtension->Segments[ 0 ]->RaSegCount() + - SwitchExtension->Segments[ 1 ]->RaSegCount() + - SwitchExtension->Segments[ 2 ]->RaSegCount(); + SwitchExtension->Segments[ 0 ]->RaSegCount() + + SwitchExtension->Segments[ 1 ]->RaSegCount() + + SwitchExtension->Segments[ 2 ]->RaSegCount(); } else { SwitchExtension->iPoints = - 5 + SwitchExtension->Segments[ 2 ]->RaSegCount() + - SwitchExtension->Segments[ 3 ]->RaSegCount() + - SwitchExtension->Segments[ 4 ]->RaSegCount() + - SwitchExtension->Segments[ 5 ]->RaSegCount(); // mogą być tylko 3 drogi + SwitchExtension->Segments[ 2 ]->RaSegCount() + + SwitchExtension->Segments[ 3 ]->RaSegCount() + + SwitchExtension->Segments[ 4 ]->RaSegCount() + + SwitchExtension->Segments[ 5 ]->RaSegCount(); } // tablica utworzona z zapasem, ale nie wypełniona współrzędnymi - SwitchExtension->vPoints = new vector3[SwitchExtension->iPoints]; + SwitchExtension->vPoints = new vector3[ SwitchExtension->iPoints + SwitchExtension->iRoads ]; } vector3 *b = SwitchExtension->bPoints ? @@ -1573,39 +1573,43 @@ void TTrack::Compile(GLuint tex) // renderowanie nawierzchni na końcu double sina0 = sin(a[0]), cosa0 = cos(a[0]); double u, v; - if (!SwitchExtension->bPoints) // jeśli tablica nie wypełniona - if (b) // ale jest wskaźnik do tablicy - może nie być? - { // coś się gubi w obliczeniach na wskaźnikach - // ustalenie liczby punktów, bo mogło wyjść inaczej niż - i = (int)(((size_t)(b)) - ((size_t)(SwitchExtension->vPoints))) / sizeof(vector3); - // policzone z góry - if (i > 0) - { // jeśli zostało to właśnie utworzone - if (SwitchExtension->iPoints > i) // jeśli wyszło mniej niż było miejsca - SwitchExtension->iPoints = i; // domknięcie wachlarza - else { - // jak tutaj wejdzie, to błąd jest - zrobić miejsce na powtórzenie pierwszego punktu na końcu - --SwitchExtension->iPoints; - } - SwitchExtension->vPoints[SwitchExtension->iPoints++] = SwitchExtension->vPoints[0]; - SwitchExtension->bPoints = true; // tablica punktów została wypełniona - } - } + if( ( false == SwitchExtension->bPoints ) // jeśli tablica nie wypełniona + && ( b != nullptr ) ) { + SwitchExtension->bPoints = true; // tablica punktów została wypełniona + } + if (TextureID1) // jeśli podana tekstura nawierzchni if ( (tex == TextureID1) || (tex == 0) ) // jeśli pasuje do grupy (tex) { if (!tex) GfxRenderer.Bind( TextureID1 ); glBegin(GL_TRIANGLE_FAN); // takie kółeczko będzie + // we start with a vertex in the middle... glNormal3f(0, 1, 0); glTexCoord2f(0.5, 0.5); //środek tekstury na środku skrzyżowania - glVertex3f(oxz.x, oxz.y, oxz.z); - for (i = SwitchExtension->iPoints - 1; i >= 0; --i) + glVertex3f( + oxz.x - origin.x, + oxz.y - origin.y, + oxz.z - origin.z ); + // ...and add one extra vertex to close the fan... + glNormal3f( 0, 1, 0 ); + // mapowanie we współrzędnych scenerii + u = ( SwitchExtension->vPoints[ 0 ].x - oxz.x + origin.x ) / fTexLength; + v = ( SwitchExtension->vPoints[ 0 ].z - oxz.z + origin.z ) / ( fTexRatio1 * fTexLength ); + glTexCoord2f( + cosa0 * u + sina0 * v + 0.5, + -sina0 * u + cosa0 * v + 0.5 ); + glVertex3f( + SwitchExtension->vPoints[ 0 ].x, + SwitchExtension->vPoints[ 0 ].y, + SwitchExtension->vPoints[ 0 ].z ); + + for ( i = SwitchExtension->iPoints + SwitchExtension->iRoads - 1; i >= 0; --i ) { glNormal3f(0, 1, 0); // mapowanie we współrzędnych scenerii - u = (SwitchExtension->vPoints[i].x - oxz.x) / fTexLength; - v = (SwitchExtension->vPoints[i].z - oxz.z) / (fTexRatio1 * fTexLength); + u = (SwitchExtension->vPoints[i].x - oxz.x + origin.x) / fTexLength; + v = (SwitchExtension->vPoints[i].z - oxz.z + origin.z) / (fTexRatio1 * fTexLength); glTexCoord2f( cosa0 * u + sina0 * v + 0.5, -sina0 * u + cosa0 * v + 0.5); diff --git a/Traction.cpp b/Traction.cpp index 6cf2842a..c7add93a 100644 --- a/Traction.cpp +++ b/Traction.cpp @@ -109,7 +109,7 @@ TTraction::~TTraction() glDeleteLists(uiDisplayList, 1); } -void TTraction::Optimize() +void TTraction::Optimize( Math3D::vector3 const &Origin ) { if (Global::bUseVBO) return; @@ -125,13 +125,13 @@ void TTraction::Optimize() // Przewoz jezdny 1 'Marcin glBegin(GL_LINE_STRIP); glVertex3f( - pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, - pPoint1.y, - pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); + pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset - Origin.x, + pPoint1.y - Origin.y, + pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset - Origin.z); glVertex3f( - pPoint2.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, - pPoint2.y, - pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); + pPoint2.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset - Origin.x, + pPoint2.y - Origin.y, + pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset - Origin.z ); glEnd(); // Nie wiem co 'Marcin Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2; @@ -147,29 +147,39 @@ void TTraction::Optimize() if (Wires > 1) { glBegin(GL_LINE_STRIP); - glVertex3f(pPoint3.x, pPoint3.y, pPoint3.z); + glVertex3f( + pPoint3.x - Origin.x, + pPoint3.y - Origin.y, + pPoint3.z - Origin.z ); for (int i = 0; i < iNumSections - 1; ++i) { pt3 = pPoint3 + v1 * f; t = (1 - std::fabs(f - mid) * 2); if ((Wires < 4) || ((i != 0) && (i != iNumSections - 2))) glVertex3f( - pt3.x, - pt3.y - std::sqrt(t) * fHeightDifference, - pt3.z); + pt3.x - Origin.x, + pt3.y - std::sqrt(t) * fHeightDifference - Origin.y, + pt3.z - Origin.z ); f += step; } - glVertex3f(pPoint4.x, pPoint4.y, pPoint4.z); + glVertex3f( + pPoint4.x - Origin.x, + pPoint4.y - Origin.y, + pPoint4.z - Origin.z ); glEnd(); } // Drugi przewod jezdny 'Winger if (Wires > 2) { glBegin(GL_LINE_STRIP); - glVertex3f(pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint1.y, - pPoint1.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); - glVertex3f(pPoint2.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint2.y, - pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); + glVertex3f( + pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset - Origin.x, + pPoint1.y - Origin.y, + pPoint1.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset - Origin.z ); + glVertex3f( + pPoint2.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset - Origin.x, + pPoint2.y - Origin.y, + pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset - Origin.z ); glEnd(); } @@ -178,22 +188,29 @@ void TTraction::Optimize() if (Wires == 4) { glBegin(GL_LINE_STRIP); - glVertex3f(pPoint3.x, pPoint3.y - 0.65f * fHeightDifference, pPoint3.z); + glVertex3f( + pPoint3.x - Origin.x, + pPoint3.y - 0.65f * fHeightDifference - Origin.y, + pPoint3.z - Origin.z ); for (int i = 0; i < iNumSections - 1; ++i) { pt3 = pPoint3 + v1 * f; t = (1 - std::fabs(f - mid) * 2); glVertex3f( - pt3.x, + pt3.x - Origin.x, pt3.y - std::sqrt( t ) * fHeightDifference - ( ( ( i == 0 ) || ( i == iNumSections - 2 ) ) ? 0.25f * fHeightDifference : - 0.05 ), - pt3.z); + 0.05 ) + - Origin.y, + pt3.z - Origin.z ); f += step; } - glVertex3f(pPoint4.x, pPoint4.y - 0.65f * fHeightDifference, pPoint4.z); + glVertex3f( + pPoint4.x - Origin.x, + pPoint4.y - 0.65f * fHeightDifference - Origin.y, + pPoint4.z - Origin.z ); glEnd(); } @@ -214,35 +231,35 @@ void TTraction::Optimize() if ((i % 2) == 0) { glVertex3f( - pt3.x, - pt3.y - std::sqrt(t) * fHeightDifference - ((i == 0) || (i == iNumSections - 2) ? flo : flo1), - pt3.z); + pt3.x - Origin.x, + pt3.y - std::sqrt(t) * fHeightDifference - ((i == 0) || (i == iNumSections - 2) ? flo : flo1) - Origin.y, + pt3.z - Origin.z ); glVertex3f( - pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, - pt4.y, - pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); + pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset - Origin.x, + pt4.y - Origin.y, + pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset - Origin.z ); } else { glVertex3f( - pt3.x, - pt3.y - std::sqrt(t) * fHeightDifference - ((i == 0) || (i == iNumSections - 2) ? flo : flo1), - pt3.z); + pt3.x - Origin.x, + pt3.y - std::sqrt(t) * fHeightDifference - ((i == 0) || (i == iNumSections - 2) ? flo : flo1) - Origin.y, + pt3.z - Origin.z ); glVertex3f( - pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, - pt4.y, - pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset); + pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset - Origin.x, + pt4.y - Origin.y, + pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset - Origin.z ); } if ((Wires == 4) && ((i == 1) || (i == iNumSections - 3))) { glVertex3f( - pt3.x, - pt3.y - std::sqrt(t) * fHeightDifference - 0.05, - pt3.z); + pt3.x - Origin.x, + pt3.y - std::sqrt(t) * fHeightDifference - 0.05 - Origin.y, + pt3.z - Origin.z ); glVertex3f( - pt3.x, - pt3.y - std::sqrt(t) * fHeightDifference, - pt3.z); + pt3.x - Origin.x, + pt3.y - std::sqrt(t) * fHeightDifference - Origin.y, + pt3.z - Origin.z ); } f += step; } @@ -258,7 +275,7 @@ void TTraction::InitCenter(vector3 Angles, vector3 pOrigin) fSquaredRadius= SquareMagnitude((pPoint2-pPoint1)*0.5f); } */ -void TTraction::RenderDL(float mgn) // McZapkie: mgn to odleglosc od obserwatora +void TTraction::RenderDL(float mgn, Math3D::vector3 const &Origin ) // McZapkie: mgn to odleglosc od obserwatora { // McZapkie: ustalanie przezroczystosci i koloru linii: if( Wires != 0 && !TestFlag( DamageFlag, 128 ) ) // rysuj jesli sa druty i nie zerwana @@ -281,7 +298,7 @@ void TTraction::RenderDL(float mgn) // McZapkie: mgn to odleglosc od obserwatora ::glColor4f( red, green, blue, linealpha ); // draw code if (!uiDisplayList) - Optimize(); // generowanie DL w miarę potrzeby + Optimize( Origin ); // generowanie DL w miarę potrzeby ::glCallList(uiDisplayList); // cleanup ::glLineWidth(1.0); diff --git a/Traction.h b/Traction.h index 5a68c359..62a635cb 100644 --- a/Traction.h +++ b/Traction.h @@ -56,7 +56,7 @@ class TTraction int iTries = 0; int PowerState{ 0 }; // type of incoming power, if any - void Optimize(); + void Optimize( Math3D::vector3 const &Origin ); TTraction(); ~TTraction(); @@ -66,7 +66,7 @@ class TTraction // { return TNode::Hit(x,z,hitPoint,hitDirection); }; // virtual bool Move(double dx, double dy, double dz) { return false; }; // virtual void SelectedRender(); - void RenderDL(float mgn); + void RenderDL(float mgn, Math3D::vector3 const &Origin ); int RaArrayPrepare(); int RaArrayFill( CVertNormTex *Vert, Math3D::vector3 const &Origin ); void RenderVBO(float mgn, int iPtr); diff --git a/renderer.cpp b/renderer.cpp index 0403e303..19ae8014 100644 --- a/renderer.cpp +++ b/renderer.cpp @@ -395,12 +395,12 @@ opengl_renderer::Render( TGround *Ground ) { if( Global::bUseVBO ) { // vbo render path Ground->Rects[ ( i + c ) / iNumSubRects ][ ( j + r ) / iNumSubRects ].RenderVBO(); + ::glPopMatrix(); } else { // display list render path Ground->Rects[ ( i + c ) / iNumSubRects ][ ( j + r ) / iNumSubRects ].RenderDL(); } - ::glPopMatrix(); if( ( tmp = Ground->FastGetSubRect( i + c, j + r ) ) != nullptr ) { if( tmp->iNodeCount ) { @@ -440,8 +440,12 @@ opengl_renderer::Render( TGroundNode *Node ) { switch (Node->iType) { // obiekty renderowane niezależnie od odległości case TP_SUBMODEL: + ::glPushMatrix(); + auto const originoffset = Node->pCenter - Global::pCameraPosition; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); TSubModel::fSquareDist = 0; Render( Node->smTerrain ); + ::glPopMatrix(); return true; } @@ -494,7 +498,7 @@ opengl_renderer::Render( TGroundNode *Node ) { // additional setup for display lists if( ( Node->DisplayListID == 0 ) || ( Node->iVersion != Global::iReCompile ) ) { // Ra: wymuszenie rekompilacji - Node->Compile(); + Node->Compile(Node->m_rootposition); if( Global::bManageNodes ) ResourceManager::Register( Node ); }; @@ -506,9 +510,6 @@ opengl_renderer::Render( TGroundNode *Node ) { // wszelkie linie są rysowane na samym końcu if( Node->iNumPts ) { // setup - ::glPushMatrix(); - auto const originoffset = Node->m_rootposition - Global::pCameraPosition; - ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); // w zaleznosci od koloru swiatla ::glColor4ub( static_cast( std::floor( Node->Diffuse[ 0 ] * Global::DayLight.ambient[ 0 ] ) ), @@ -521,14 +522,16 @@ opengl_renderer::Render( TGroundNode *Node ) { // render // TODO: unify the render code after generic buffers are in place if( Global::bUseVBO ) { + ::glPushMatrix(); + auto const originoffset = Node->m_rootposition - Global::pCameraPosition; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); ::glDrawArrays( Node->iType, Node->iVboPtr, Node->iNumPts ); + ::glPopMatrix(); } else { ::glCallList( Node->DisplayListID ); } - // post-render cleanup - ::glPopMatrix(); return true; } else { @@ -542,12 +545,7 @@ opengl_renderer::Render( TGroundNode *Node ) { Node->DisplayListID == 0 ) ) { return false; } - // setup - ::glPushMatrix(); - auto const originoffset = Node->m_rootposition - Global::pCameraPosition; - ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); - ::glColor3ub( static_cast( Node->Diffuse[ 0 ] ), static_cast( Node->Diffuse[ 1 ] ), @@ -559,16 +557,17 @@ opengl_renderer::Render( TGroundNode *Node ) { // TODO: unify the render code after generic buffers are in place if( Global::bUseVBO ) { // vbo render path + ::glPushMatrix(); + auto const originoffset = Node->m_rootposition - Global::pCameraPosition; + ::glTranslated( originoffset.x, originoffset.y, originoffset.z ); ::glDrawArrays( Node->iType, Node->iVboPtr, Node->iNumVerts ); + ::glPopMatrix(); } else { // display list render path ::glCallList( Node->DisplayListID ); } - // post-render cleanup - ::glPopMatrix(); - return true; } } @@ -703,7 +702,8 @@ opengl_renderer::Render( TModel3d *Model, material_data const *Material, Math3D: if( Angle.z != 0.0 ) ::glRotated( Angle.z, 0.0, 0.0, 1.0 ); - auto const result = Render( Model, Material, SquareMagnitude( Position / Global::ZoomFactor ) ); // position is effectively camera offset +// auto const result = Render( Model, Material, SquareMagnitude( Position / Global::ZoomFactor ) ); // position is effectively camera offset + auto const result = Render( Model, Material, SquareMagnitude( Position ) ); // position is effectively camera offset ::glPopMatrix(); @@ -978,7 +978,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) { Node->hvTraction->RenderVBO( distancesquared, Node->iVboPtr ); } else { - Node->hvTraction->RenderDL( distancesquared ); + Node->hvTraction->RenderDL( distancesquared, Node->m_rootposition ); } // post-render cleanup ::glPopMatrix(); @@ -1010,7 +1010,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) { // additional setup for display lists if( ( Node->DisplayListID == 0 ) || ( Node->iVersion != Global::iReCompile ) ) { // Ra: wymuszenie rekompilacji - Node->Compile(); + Node->Compile(Node->m_rootposition); if( Global::bManageNodes ) ResourceManager::Register( Node ); }; @@ -1218,7 +1218,8 @@ opengl_renderer::Render_Alpha( TModel3d *Model, material_data const *Material, M if( Angle.z != 0.0 ) ::glRotated( Angle.z, 0.0, 0.0, 1.0 ); - auto const result = Render_Alpha( Model, Material, SquareMagnitude( Position / Global::ZoomFactor ) ); // position is effectively camera offset +// auto const result = Render_Alpha( Model, Material, SquareMagnitude( Position / Global::ZoomFactor ) ); // position is effectively camera offset + auto const result = Render_Alpha( Model, Material, SquareMagnitude( Position ) ); // position is effectively camera offset ::glPopMatrix(); diff --git a/version.h b/version.h index 12dfa00e..7667fb27 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 17 -#define VERSION_MINOR 524 +#define VERSION_MINOR 525 #define VERSION_REVISION 0