diff --git a/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp b/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp index 9d35c5931cb..e58a6443c57 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp @@ -809,7 +809,7 @@ void CollectionClass::Update_Obj_Space_Bounding_Volumes() { int i; if (SubObjects.Count() <= 0) { - BoundSphere = SphereClass(Vector3(0,0,0),0); + BoundSphere = SphereClass(); BoundBox.Center.Set(0,0,0); BoundBox.Extent.Set(0,0,0); return; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp index 03412bce96b..08750d2a9dd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp @@ -323,7 +323,7 @@ void DynamicMeshModel::Render(RenderInfoClass & rinfo) DX8Wrapper::Set_Shader(MatDesc->Get_Single_Shader(pass)); } - SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f); + SphereClass sphere; Get_Bounding_Sphere(&sphere); // If no texture, shader or material arrays for this pass just draw and go to next pass diff --git a/Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp index 7de76b29115..4b6f8608854 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp @@ -240,13 +240,7 @@ void SortingRendererClass::Insert_Triangles( state->min_vertex_index=min_vertex_index; state->vertex_count=vertex_count; - if (bounding_sphere.Radius <= 0.0) - { - // TheSuperHackers @perf stephanmeesters 04/07/2026 Nodes without bounding information do not require sorting. - state->transformed_center = Vector3(0.0f, 0.0f, 0.0f); - unsorted_list.push_back(state); - } - else + if (bounding_sphere.Is_Valid()) { D3DXMATRIX mtx=(D3DXMATRIX&)state->sorting_state.world*(D3DXMATRIX&)state->sorting_state.view; D3DXVECTOR3 vec=(D3DXVECTOR3&)bounding_sphere.Center; @@ -259,6 +253,12 @@ void SortingRendererClass::Insert_Triangles( Insert_To_Sorted_List(state); } + else + { + // TheSuperHackers @perf stephanmeesters 04/07/2026 Nodes without bounding information do not require sorting. + state->transformed_center = Vector3(0.0f, 0.0f, 0.0f); + unsorted_list.push_back(state); + } #ifdef WWDEBUG SortingVertexBufferClass* vertex_buffer=static_cast(state->sorting_state.vertex_buffers[0]); @@ -296,8 +296,7 @@ void SortingRendererClass::Insert_Triangles( unsigned short min_vertex_index, unsigned short vertex_count) { - SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f); - Insert_Triangles(sphere,start_index,polygon_count,min_vertex_index,vertex_count); + Insert_Triangles(SphereClass(),start_index,polygon_count,min_vertex_index,vertex_count); } // ---------------------------------------------------------------------------- diff --git a/Core/Libraries/Source/WWVegas/WWMath/sphere.h b/Core/Libraries/Source/WWVegas/WWMath/sphere.h index 0bb7eaca11b..90cb26e9077 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/sphere.h +++ b/Core/Libraries/Source/WWVegas/WWMath/sphere.h @@ -65,7 +65,7 @@ class SphereClass { public: - SphereClass() { }; + SphereClass() : Center(Vector3(0.0f, 0.0f, 0.0f)), Radius(0.0f) { } SphereClass(const Vector3 & center,float radius) { Init(center,radius); } SphereClass(const Matrix3D& mtx,const Vector3 & center,float radius) { Init(mtx,center,radius); } inline SphereClass(const Vector3 & center,const SphereClass & s0); @@ -77,6 +77,7 @@ class SphereClass inline void Add_Sphere(const SphereClass & s); inline void Transform(const Matrix3D & tm); inline float Volume() const; + inline bool Is_Valid() const; inline SphereClass & operator += (const SphereClass & s); inline SphereClass & operator *= (const Matrix3D & m); @@ -302,7 +303,7 @@ inline void SphereClass::Re_Center(const Vector3 & center) *=============================================================================================*/ inline void SphereClass::Add_Sphere(const SphereClass & s) { - if (s.Radius == 0.0f) return; + if (!s.Is_Valid()) return; float dist = (s.Center - Center).Length(); if (dist == 0.0f) { @@ -452,12 +453,12 @@ inline bool Spheres_Intersect(const SphereClass & s0,const SphereClass & s1) *=============================================================================================*/ inline SphereClass Add_Spheres(const SphereClass & s0, const SphereClass & s1) { - if (s0.Radius == 0.0f) { - return s1; - } else { + if (s0.Is_Valid()) { SphereClass result(s0); result.Add_Sphere(s1); return result; + } else { + return s1; } } @@ -539,3 +540,8 @@ inline SphereClass operator * (const Matrix3D & m, const SphereClass & s) { return Transform_Sphere(m,s); } + +inline bool SphereClass::Is_Valid() const +{ + return Radius > 0.0; +} diff --git a/Core/Tools/W3DView/ViewerScene.cpp b/Core/Tools/W3DView/ViewerScene.cpp index 1ad15a42081..87e50050b3f 100644 --- a/Core/Tools/W3DView/ViewerScene.cpp +++ b/Core/Tools/W3DView/ViewerScene.cpp @@ -226,7 +226,7 @@ ViewerSceneClass::Get_Bounding_Sphere () // Iterate through every object in the scene, adding its // bounding sphere to the current bounding sphere. The sum of // the bounding spheres will be the scene's bounding sphere. - SphereClass bounding_sphere(Vector3(0,0,0), 0.0f); + SphereClass bounding_sphere; SceneIterator *it = Create_Iterator(); assert(it); for (; !it->Is_Done(); it->Next()) diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp index 7a140b6fd8f..4f61b8507cc 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp @@ -3258,7 +3258,6 @@ void W3DVolumetricShadowManager::renderShadows( Bool forceStencilFill ) Int numRenderedShadows = 0; AABoxClass bbox; - SphereClass bsphere; //Get a bounding box around our visible universe. Bounded by terrain and the sky //so much tighter fitting volume than what's actually visible. This will cull diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp index 4a9bf52823c..6a77974f3c6 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp @@ -511,9 +511,6 @@ void BoxRenderObjClass::render_box(RenderInfoClass & rinfo,const Vector3 & cente DX8Wrapper::Set_Index_Buffer(ibaccess,0); DX8Wrapper::Set_Vertex_Buffer(vbaccess); - SphereClass sphere; - Get_Obj_Space_Bounding_Sphere(sphere); - DX8Wrapper::Draw_Triangles(buffer_type,0,NUM_BOX_FACES,0,NUM_BOX_VERTS); } } diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp index ccfebcdccf9..5b1d4618445 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp @@ -1180,8 +1180,6 @@ void DazzleRenderObjClass::Render_Dazzle(CameraClass* camera) DX8Wrapper::Set_Index_Buffer(ib_access,dazzle_vertex_count); DX8Wrapper::Set_Shader(default_halo_shader); DX8Wrapper::Set_Texture(0,types[type]->Get_Halo_Texture()); - SphereClass sphere(Get_Position(),0.1f); - DX8Wrapper::Draw_Triangles(0,halo_poly_count,0,vertex_count); } @@ -1189,7 +1187,6 @@ void DazzleRenderObjClass::Render_Dazzle(CameraClass* camera) DX8Wrapper::Set_Index_Buffer(ib_access,0); DX8Wrapper::Set_Shader(default_dazzle_shader); DX8Wrapper::Set_Texture(0,types[type]->Get_Dazzle_Texture()); - SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f); DX8Wrapper::Draw_Triangles(0,dazzle_poly_count,0,vertex_count); } @@ -1197,7 +1194,6 @@ void DazzleRenderObjClass::Render_Dazzle(CameraClass* camera) DX8Wrapper::Set_Index_Buffer(ib_access,dazzle_vertex_count+halo_vertex_count); DX8Wrapper::Set_Shader(default_dazzle_shader); DX8Wrapper::Set_Texture(0,lensflare->Get_Texture()); - SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f); DX8Wrapper::Draw_Triangles(0,lensflare_poly_count,0,vertex_count); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp index 4d12971edb7..648fd170337 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp @@ -3402,7 +3402,6 @@ void W3DVolumetricShadowManager::renderShadows( Bool forceStencilFill ) Int numRenderedShadows = 0; AABoxClass bbox; - SphereClass bsphere; //Get a bounding box around our visible universe. Bounded by terrain and the sky //so much tighter fitting volume than what's actually visible. This will cull diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp index 3620d63ca84..7b048d57a72 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp @@ -511,9 +511,6 @@ void BoxRenderObjClass::render_box(RenderInfoClass & rinfo,const Vector3 & cente DX8Wrapper::Set_Index_Buffer(ibaccess,0); DX8Wrapper::Set_Vertex_Buffer(vbaccess); - SphereClass sphere; - Get_Obj_Space_Bounding_Sphere(sphere); - DX8Wrapper::Draw_Triangles(buffer_type,0,NUM_BOX_FACES,0,NUM_BOX_VERTS); } } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp index ee5b18e079a..76c8916f477 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp @@ -1227,8 +1227,6 @@ void DazzleRenderObjClass::Render_Dazzle(CameraClass* camera) DX8Wrapper::Set_Index_Buffer(ib_access,dazzle_vertex_count); DX8Wrapper::Set_Shader(default_halo_shader); DX8Wrapper::Set_Texture(0,types[type]->Get_Halo_Texture()); - SphereClass sphere(Get_Position(),0.1f); - DX8Wrapper::Draw_Triangles(0,halo_poly_count,0,vertex_count); } @@ -1236,7 +1234,6 @@ void DazzleRenderObjClass::Render_Dazzle(CameraClass* camera) DX8Wrapper::Set_Index_Buffer(ib_access,0); DX8Wrapper::Set_Shader(default_dazzle_shader); DX8Wrapper::Set_Texture(0,types[type]->Get_Dazzle_Texture()); - SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f); DX8Wrapper::Draw_Triangles(0,dazzle_poly_count,0,vertex_count); } @@ -1244,7 +1241,6 @@ void DazzleRenderObjClass::Render_Dazzle(CameraClass* camera) DX8Wrapper::Set_Index_Buffer(ib_access,dazzle_vertex_count+halo_vertex_count); DX8Wrapper::Set_Shader(default_dazzle_shader); DX8Wrapper::Set_Texture(0,lensflare->Get_Texture()); - SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f); DX8Wrapper::Draw_Triangles(0,lensflare_poly_count,0,vertex_count); }