Skip to content
9 changes: 6 additions & 3 deletions trinity/Eve/EveEffectRoot2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "Utilities/BoundingSphere.h"
#include "Utilities/BoundingBox.h"
#include "Utilities/Obb.h"
#include "TriFrustum.h"
#include "Lights/Tr2PointLight.h"
#include "Tr2LightManager.h"
Expand Down Expand Up @@ -431,15 +432,17 @@ void EveEffectRoot2::GetLocalToWorldTransform( Matrix& transform ) const
transform = m_lastUpdateMatrix;
}

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

BoundingBoxInitialize( m_boundingSphere, min, max );
BoundingBoxTransform( min, max, m_lastUpdateMatrix );
CcpMath::Sphere worldSphere( m_boundingSphere );
worldSphere.Transform( m_lastUpdateMatrix );
BoundingBoxInitialize( Vector4( worldSphere.center, worldSphere.radius ), localMin, localMax );
localToWorld = IdentityMatrix();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion trinity/Eve/EveEffectRoot2.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ BLUE_CLASS( EveEffectRoot2 ) :

/////////////////////////////////////////////////////////////////////////////////////
// ITr2BoundingBox
bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const override;
bool GetOrientedBoundingBox( Vector3 & localMin, Vector3 & localMax, Matrix & localToWorld ) const override;
bool IsBoundingBoxReady() const override;

/////////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 5 additions & 5 deletions trinity/Eve/EvePlanet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "EveUpdateContext.h"
#include "Curves/TriCurveSet.h"
#include "Utilities/BoundingBox.h"
#include "Utilities/Obb.h"

const float EvePlanet::SCALE = 1000000.0f;

Expand Down Expand Up @@ -150,19 +151,18 @@ Quaternion EvePlanet::GetWorldRotation()
return m_rotation;
}

bool EvePlanet::GetWorldBoundingBox( Vector3& min, Vector3& max ) const
bool EvePlanet::GetOrientedBoundingBox( Vector3& localMin, Vector3& localMax, Matrix& localToWorld ) 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 );
const float radius = m_radius / renderScale;
BoundingBoxInitialize( Vector4( scaledTransform.GetTranslation(), radius ), localMin, localMax );
localToWorld = IdentityMatrix();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion trinity/Eve/EvePlanet.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ BLUE_CLASS( EvePlanet ) :
virtual Quaternion GetWorldRotation();

// ITr2BoundingBox
bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const override;
bool GetOrientedBoundingBox( Vector3 & localMin, Vector3 & localMax, Matrix & localToWorld ) const override;
bool IsBoundingBoxReady() const override;

// ITr2SecondaryLightSource
Expand Down
7 changes: 4 additions & 3 deletions trinity/Eve/EveTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Utilities/Vector3d.h"
#include "Utilities/BoundingSphere.h"
#include "Utilities/BoundingBox.h"
#include "Utilities/Obb.h"
#include "TriFrustum.h"
#include "Particle/Tr2ParticleSystem.h"
#include "Particle/ITr2GenericEmitter.h"
Expand Down Expand Up @@ -381,13 +382,13 @@ bool EveTransform::GetLocalBoundingBox( Vector3& min, Vector3& max )
return true;
}

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

Expand Down
2 changes: 1 addition & 1 deletion trinity/Eve/EveTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ BLUE_CLASS( EveTransform ) :

/////////////////////////////////////////////////////////////////////////////////////
// ITr2BoundingBox
bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const override;
bool GetOrientedBoundingBox( Vector3 & localMin, Vector3 & localMax, Matrix & localToWorld ) const override;
bool IsBoundingBoxReady() const override;

/////////////////////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 5 additions & 4 deletions trinity/Eve/SpaceObject/EveSpaceObject2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Utilities/BoundingBox.h"
#include "Utilities/BoundingSphere.h"
#include "Utilities/MatrixUtils.h"
#include "Utilities/Obb.h"

#include "include/ITr2DebugRenderer.h"
#include "Include/TriMath.h"
Expand Down Expand Up @@ -4198,11 +4199,11 @@ void EveSpaceObject2::GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr
}
}

bool EveSpaceObject2::GetWorldBoundingBox( Vector3& min, Vector3& max ) const
bool EveSpaceObject2::GetOrientedBoundingBox( Vector3& localMin, Vector3& localMax, Matrix& localToWorld ) const
{
min = m_localAabbMin;
max = m_localAabbMax;
BoundingBoxTransform( min, max, m_worldTransform );
localMin = m_localAabbMin;
localMax = m_localAabbMax;
localToWorld = m_worldTransform;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion trinity/Eve/SpaceObject/EveSpaceObject2.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ BLUE_CLASS( EveSpaceObject2 ) :

/////////////////////////////////////////////////////////////////////////////////////
// ITr2BoundingBox
virtual bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const;
virtual bool GetOrientedBoundingBox( Vector3 & localMin, Vector3 & localMax, Matrix & localToWorld ) const;
virtual bool IsBoundingBoxReady() const;

/////////////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion trinity/Include/ITr2BoundingBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#define ITr2BoundingBox_h

struct Vector3;
struct Matrix;

BLUE_INTERFACE( ITr2BoundingBox ) :
IRoot
{
virtual bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const = 0;
virtual bool GetOrientedBoundingBox( Vector3 & localMin, Vector3 & localMax, Matrix & localToWorld ) const = 0;
virtual bool IsBoundingBoxReady( void ) const = 0;
};

Expand Down
13 changes: 12 additions & 1 deletion trinity/Interior/Tr2IntSkinnedObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Tr2IntSkinnedObject.h"

#include "Utilities/BoundingSphere.h"
#include "Utilities/Obb.h"
#include "TriSettingsRegistrar.h"
#include "Tr2PerObjectData.h"
#include "Resources/TriGeometryRes.h"
Expand Down Expand Up @@ -147,10 +148,20 @@ bool Tr2IntSkinnedObject::GetWorldBoundingBox( Vector3& min, Vector3& max ) cons
return true;
}

bool Tr2IntSkinnedObject::GetOrientedBoundingBox( Vector3& localMin, Vector3& localMax, Matrix& localToWorld ) const
{
if( !GetLocalBoundingBox( localMin, localMax ) )
{
return false;
}
localToWorld = GetSkinningTransform();
return true;
}

bool Tr2IntSkinnedObject::IsBoundingBoxReady( void ) const
{
Vector3 min, max;
return GetWorldBoundingBox( min, max );
return GetLocalBoundingBox( min, max );
}

void Tr2IntSkinnedObject::AddToApexScene( Tr2ApexScene* apexScene )
Expand Down
3 changes: 3 additions & 0 deletions trinity/Interior/Tr2IntSkinnedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class Tr2IntSkinnedObject : public ITr2InteriorDynamic,
virtual bool GetWorldBoundingBox( Vector3& min, Vector3& max ) const;
virtual bool IsBoundingBoxReady( void ) const;

// ITr2BoundingBox
virtual bool GetOrientedBoundingBox( Vector3& localMin, Vector3& localMax, Matrix& localToWorld ) const;

// Apex
void AddToApexScene( Tr2ApexScene* apexScene );
void RemoveFromApexScene( void );
Expand Down
11 changes: 11 additions & 0 deletions trinity/Interior/Tr2InteriorPlaceable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

// Trinity headers
#include "Utilities/BoundingSphere.h"
#include "Utilities/Obb.h"
#include "Tr2PerObjectData.h"
#include "Wod/WodPlaceableRes.h"
#include "Tr2Mesh.h"
Expand Down Expand Up @@ -135,6 +136,16 @@ bool Tr2InteriorPlaceable::GetWorldBoundingBox( Vector3& min, Vector3& max ) con
return true;
}

bool Tr2InteriorPlaceable::GetOrientedBoundingBox( Vector3& localMin, Vector3& localMax, Matrix& localToWorld ) const
{
if( !GetLocalBoundingBox( localMin, localMax ) )
{
return false;
}
localToWorld = m_transform;
return true;
}

bool Tr2InteriorPlaceable::IsBoundingBoxReady( void ) const
{
return m_isBoundingBoxModified || ( m_placeableRes && m_placeableRes->IsReady() );
Expand Down
4 changes: 4 additions & 0 deletions trinity/Interior/Tr2InteriorPlaceable.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class Tr2InteriorPlaceable : public INotify,
virtual bool GetLocalBoundingBox( Vector3& min, Vector3& max ) const;
virtual bool GetWorldBoundingBox( Vector3& min, Vector3& max ) const;
virtual bool IsBoundingBoxReady( void ) const;

/////////////////////////////////////////////////////////////////////////////////////
// ITr2BoundingBox
virtual bool GetOrientedBoundingBox( Vector3& localMin, Vector3& localMax, Matrix& localToWorld ) const;
virtual void PrePhysicsUpdate( Be::Time time );
virtual void PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene );

Expand Down
Loading
Loading