Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<SortingVertexBufferClass*>(state->sorting_state.vertex_buffers[0]);
Expand Down Expand Up @@ -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);
}

// ----------------------------------------------------------------------------
Expand Down
16 changes: 11 additions & 5 deletions Core/Libraries/Source/WWVegas/WWMath/sphere.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f

}
2 changes: 1 addition & 1 deletion Core/Tools/W3DView/ViewerScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 0 additions & 4 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,24 +1180,20 @@ 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);
}

if (dazzle_poly_count) {
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);
}

if (lensflare_poly_count) {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 0 additions & 4 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,24 +1227,20 @@ 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);
}

if (dazzle_poly_count) {
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);
}

if (lensflare_poly_count) {
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);
}

Expand Down
Loading