Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6b12cfe
add ITr2BoundingBox to EvePlanet, EveEffectRoot2, EveRootTransform, E…
Ikreb1 May 22, 2026
b5e325e
update bounding box bracket modernize it and add features that space …
Ikreb1 Jun 4, 2026
2f63866
Merge remote-tracking branch 'origin/main' into bugfix/BoundingBoxBra…
Jun 12, 2026
5ce1797
Merge remote-tracking branch 'origin/main' into bugfix/BoundingBoxBra…
Jun 12, 2026
cccde3a
Merge remote-tracking branch 'origin/main' into bugfix/BoundingBoxBra…
Jun 16, 2026
32593d9
Merge remote-tracking branch 'origin/main' into bugfix/BoundingBoxBra…
Jun 18, 2026
b9790b1
Merge remote-tracking branch 'origin/main' into bugfix/BoundingBoxBra…
Jun 19, 2026
de0a05e
Merge remote-tracking branch 'origin/main' into bugfix/BoundingBoxBra…
Jun 22, 2026
48d52ed
Merge remote-tracking branch 'origin/main' into bugfix/BoundingBoxBra…
Ikreb1 Jun 26, 2026
efbf68b
Merge branch 'main' into bugfix/BoundingBoxBracket-iteration
Ikreb1 Jul 14, 2026
c68a590
update boundingBoxBracket after feedback and review
Ikreb1 Jul 17, 2026
90bd80f
remove unused helper function
Ikreb1 Jul 17, 2026
310c82f
Remove child bounding sphere logic and remove boundingsphere interfac…
Ikreb1 Jul 21, 2026
c9d4dd7
Apply suggestions from code review
Ikreb1 Jul 21, 2026
19668f3
simplify changes by removing isfinite checks and applying other coder…
Ikreb1 Jul 21, 2026
d0efbaf
Update trinity/TriMath.cpp
Ikreb1 Jul 21, 2026
76ad6c2
remove unused includes and functions caused by older commits
Ikreb1 Jul 21, 2026
e377e7c
better is trivially inside function
Ikreb1 Jul 21, 2026
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
29 changes: 26 additions & 3 deletions trinity/Eve/EveEffectRoot2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "EveEffectRoot2.h"

#include "Utilities/BoundingSphere.h"
#include "Utilities/BoundingBox.h"
#include "TriFrustum.h"
#include "Lights/Tr2PointLight.h"
#include "Tr2LightManager.h"
Expand Down Expand Up @@ -398,8 +399,13 @@ void EveEffectRoot2::GetModelCenterWorldPosition( Vector3& position ) const

bool EveEffectRoot2::GetLocalBoundingBox( Vector3& min, Vector3& max )
{
// If possible, return an AABB in local coordinates
return false;
if( m_boundingSphere.w <= 0.0f )
{
return false;
}

BoundingBoxInitialize( m_boundingSphere, min, max );
return true;
}

void EveEffectRoot2::GetLocalToWorldTransform( Matrix& transform ) const
Expand All @@ -408,6 +414,23 @@ void EveEffectRoot2::GetLocalToWorldTransform( Matrix& transform ) const
transform = m_lastUpdateMatrix;
}

bool EveEffectRoot2::GetWorldBoundingBox( Vector3& min, Vector3& max ) const
{
if( m_boundingSphere.w <= 0.0f )
{
return false;
}

BoundingBoxInitialize( m_boundingSphere, min, max );
BoundingBoxTransform( min, max, m_lastUpdateMatrix );
return true;
}

bool EveEffectRoot2::IsBoundingBoxReady() const
{
return m_boundingSphere.w > 0.0f;
}

void EveEffectRoot2::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer )
{
for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it )
Expand Down Expand Up @@ -995,4 +1018,4 @@ void EveEffectRoot2::SetProceduralContainerVariable( const char* name, float val
auto child = *it;
child->SetProceduralContainerVariable( name, value );
}
}
}
9 changes: 8 additions & 1 deletion trinity/Eve/EveEffectRoot2.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ITr2SoundEmitterOwner.h"
#include "Controllers/ITr2ControllerOwner.h"
#include "Lights/ITr2LightOwner.h"
#include "ITr2BoundingBox.h"
#include "EveEntity.h"

#include <ITriFunction.h>
Expand Down Expand Up @@ -49,6 +50,7 @@ BLUE_CLASS( EveEffectRoot2 ) :
public ITr2SoundEmitterOwner,
public ITr2ControllerOwner,
public ITr2LightOwner,
public ITr2BoundingBox,
public EveEntity

{
Expand Down Expand Up @@ -88,6 +90,11 @@ BLUE_CLASS( EveEffectRoot2 ) :
void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer );
void SetProceduralContainerVariable( const char* name, float value ) override;

/////////////////////////////////////////////////////////////////////////////////////
// ITr2BoundingBox
bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const override;
bool IsBoundingBoxReady() const override;

/////////////////////////////////////////////////////////////////////////////////////
// ITr2LightOwner
void GetLights( Tr2LightManager & lightManager ) const override;
Expand Down Expand Up @@ -229,4 +236,4 @@ BLUE_CLASS( EveEffectRoot2 ) :

TYPEDEF_BLUECLASS( EveEffectRoot2 );

#endif // EveEffectRoot2_h
#endif // EveEffectRoot2_h
1 change: 1 addition & 0 deletions trinity/Eve/EveEffectRoot2_Blue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Be::ClassInfo* EveEffectRoot2::ExposeToBlue()
MAP_INTERFACE( IShaderConfigurer )
MAP_INTERFACE( ITr2SoundEmitterOwner )
MAP_INTERFACE( ITr2LightOwner )
MAP_INTERFACE( ITr2BoundingBox )
MAP_INTERFACE( IWorldPosition )
MAP_INTERFACE( EveEntity )

Expand Down
24 changes: 23 additions & 1 deletion trinity/Eve/EvePlanet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "TriDevice.h"
#include "EveUpdateContext.h"
#include "Curves/TriCurveSet.h"
#include "Utilities/BoundingBox.h"

const float EvePlanet::SCALE = 1000000.0f;

Expand Down Expand Up @@ -149,6 +150,27 @@ Quaternion EvePlanet::GetWorldRotation()
return m_rotation;
}

bool EvePlanet::GetWorldBoundingBox( Vector3& min, Vector3& max ) const
{
Vector4 sphere;
if( m_radius <= 0.0f )
{
return false;
}

const float renderScale = m_renderScale > 0.0f ? m_renderScale : 1.0f;
const Matrix scaledTransform = CalculatePlanetScaleTransform( m_worldTransform, renderScale );
sphere = Vector4( scaledTransform.GetTranslation(), m_radius / renderScale );

BoundingBoxInitialize( sphere, min, max );
return true;
}

bool EvePlanet::IsBoundingBoxReady() const
{
return m_radius > 0.0f;
}

// --------------------------------------------------------------------------------
// Description:
// Calculate the pixeldiameter of this planet sphere at a given position. Is used
Expand Down Expand Up @@ -386,4 +408,4 @@ void EvePlanet::RenderDebugInfo( ITr2DebugRenderer2& renderer )
renderable->RenderDebugInfo( renderer );
}
}
}
}
4 changes: 4 additions & 0 deletions trinity/Eve/EvePlanet.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ BLUE_CLASS( EvePlanet ) :
virtual Vector3 GetWorldPosition();
virtual Quaternion GetWorldRotation();

// ITr2BoundingBox
bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const override;
bool IsBoundingBoxReady() const override;

// ITr2SecondaryLightSource
virtual void RegisterSecondaryLightSource( Tr2ShLightingManager& );
virtual void UnregisterSecondaryLightSource( Tr2ShLightingManager& );
Expand Down
1 change: 1 addition & 0 deletions trinity/Eve/EvePlanet_Blue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Be::ClassInfo* EvePlanet::ExposeToBlue()
MAP_INTERFACE( IShaderConfigurer )
MAP_INTERFACE( ITr2SoundEmitterOwner )
MAP_INTERFACE( IWorldPosition )
MAP_INTERFACE( ITr2BoundingBox )
MAP_ATTRIBUTE(
"radius",
m_radius,
Expand Down
1 change: 1 addition & 0 deletions trinity/Eve/EveRootTransform_Blue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Be::ClassInfo* EveRootTransform::ExposeToBlue()
MAP_INTERFACE( ITriTargetable )
MAP_INTERFACE( ITr2Pickable )
MAP_INTERFACE( IWorldPosition )
MAP_INTERFACE( ITr2BoundingBox )

MAP_ATTRIBUTE(
"translationCurve",
Expand Down
49 changes: 48 additions & 1 deletion trinity/Eve/EveTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@

extern float g_eveSpaceSceneLowUpdateRate;

namespace
{
bool HasOverrideBounds( const Vector3& boundsMin, const Vector3& boundsMax )
{
return boundsMax.x != boundsMin.x || boundsMax.y != boundsMin.y || boundsMax.z != boundsMin.z;
}

bool GetDirectLocalBounds( const Vector3& overrideBoundsMin, const Vector3& overrideBoundsMax, Tr2MeshBase* mesh, Vector3& min, Vector3& max )
{
if( HasOverrideBounds( overrideBoundsMin, overrideBoundsMax ) )
{
min = overrideBoundsMin;
max = overrideBoundsMax;
return true;
}

return mesh && mesh->GetBoundingBox( min, max );
}
}

EveTransform::EveTransform( IRoot* lockobj ) :
Tr2Transform( lockobj ),
PARENTLOCK( m_children ),
Expand Down Expand Up @@ -351,6 +371,33 @@ void EveTransform::GetRenderables( std::vector<ITr2Renderable*>& renderables )
GetRenderables( renderables, nullptr );
}

bool EveTransform::GetLocalBoundingBox( Vector3& min, Vector3& max )
Comment thread
Ikreb1 marked this conversation as resolved.
{
if( !GetDirectLocalBounds( m_overrideBoundsMin, m_overrideBoundsMax, m_mesh, min, max ) )
{
return false;
}

return true;
}

bool EveTransform::GetWorldBoundingBox( Vector3& min, Vector3& max ) const
{
if( !GetDirectLocalBounds( m_overrideBoundsMin, m_overrideBoundsMax, m_mesh, min, max ) )
{
return false;
}
BoundingBoxTransform( min, max, m_worldTransform );
return true;
}

bool EveTransform::IsBoundingBoxReady() const
{
Vector3 min;
Vector3 max;
return GetDirectLocalBounds( m_overrideBoundsMin, m_overrideBoundsMax, m_mesh, min, max );
}

bool EveTransform::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const
{
bool valid = false;
Expand Down Expand Up @@ -506,4 +553,4 @@ void EveTransform::GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2Pi
GetBatches( batches, TRIBATCHTYPE_TRANSPARENT, perObjectData );
GetBatches( batches, TRIBATCHTYPE_ADDITIVE, perObjectData );
}
}
}
14 changes: 9 additions & 5 deletions trinity/Eve/EveTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "IEveTransform.h"
#include "IWorldPosition.h"
#include "ITr2BoundingBox.h"

BLUE_DECLARE( Tr2ParticleSystem );
BLUE_DECLARE_VECTOR( Tr2ParticleSystem );
Expand All @@ -37,6 +38,7 @@ BLUE_CLASS( EveTransform ) :
public IWorldPosition,
public IInitialize,
public ITr2CurveSetOwner,
public ITr2BoundingBox,
public ITr2DebugRenderable
{
public:
Expand All @@ -59,15 +61,17 @@ BLUE_CLASS( EveTransform ) :
bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override;
void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ) override;
void GetModelCenterWorldPosition( Vector3 & position ) const override;
bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ) override
{
return false;
}
bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ) override;
void GetLocalToWorldTransform( Matrix & transform ) const override
{
transform = IdentityMatrix();
transform = m_worldTransform;
Comment thread
Ikreb1 marked this conversation as resolved.
}

/////////////////////////////////////////////////////////////////////////////////////
// ITr2BoundingBox
bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const override;
bool IsBoundingBoxReady() const override;

/////////////////////////////////////////////////////////////////////////////////////
// ITr2Renderable - mostly implemented by Tr2Transform except for these
virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator );
Expand Down
1 change: 1 addition & 0 deletions trinity/Eve/EveTransform_Blue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Be::ClassInfo* EveTransform::ExposeToBlue()
MAP_INTERFACE( ITr2Pickable )
MAP_INTERFACE( IWorldPosition )
MAP_INTERFACE( IInitialize )
MAP_INTERFACE( ITr2BoundingBox )

MAP_ATTRIBUTE(
"hideOnLowQuality",
Expand Down
Loading