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
8 changes: 5 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,16 @@ void EveEffectRoot2::GetLocalToWorldTransform( Matrix& transform ) const
transform = m_lastUpdateMatrix;
}

bool EveEffectRoot2::GetWorldBoundingBox( Vector3& min, Vector3& max ) const
bool EveEffectRoot2::GetWorldBoundingObb( Obb& obb ) 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 );
obb.CreateFromSphere( worldSphere );
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 GetWorldBoundingObb( Obb & obb ) 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::GetWorldBoundingObb( Obb& obb ) 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;
CcpMath::Sphere worldSphere( scaledTransform.GetTranslation(), radius );
obb.CreateFromSphere( worldSphere );
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 GetWorldBoundingObb( Obb & obb ) const override;
bool IsBoundingBoxReady() const override;

// ITr2SecondaryLightSource
Expand Down
6 changes: 4 additions & 2 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,14 @@ bool EveTransform::GetLocalBoundingBox( Vector3& min, Vector3& max )
return true;
}

bool EveTransform::GetWorldBoundingBox( Vector3& min, Vector3& max ) const
bool EveTransform::GetWorldBoundingObb( Obb& obb ) const
{
Vector3 min, max;
if( !GetDirectLocalBounds( m_overrideBoundsMin, m_overrideBoundsMax, m_mesh, min, max ) )
{
return false;
}
BoundingBoxTransform( min, max, m_worldTransform );
obb.CreateWorldBoundingObb( min, max, 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 GetWorldBoundingObb( Obb & obb ) const override;
bool IsBoundingBoxReady() const override;

/////////////////////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 3 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/IEveBallpark.h"
Expand Down Expand Up @@ -4165,11 +4166,9 @@ void EveSpaceObject2::GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr
}
}

bool EveSpaceObject2::GetWorldBoundingBox( Vector3& min, Vector3& max ) const
bool EveSpaceObject2::GetWorldBoundingObb( Obb& obb ) const
{
min = m_localAabbMin;
max = m_localAabbMax;
BoundingBoxTransform( min, max, m_worldTransform );
obb.CreateWorldBoundingObb( m_localAabbMin, m_localAabbMax, 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 @@ -347,7 +347,7 @@ BLUE_CLASS( EveSpaceObject2 ) :

/////////////////////////////////////////////////////////////////////////////////////
// ITr2BoundingBox
virtual bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const;
virtual bool GetWorldBoundingObb( Obb & obb ) const;
virtual bool IsBoundingBoxReady() const;

/////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions trinity/Include/ITr2BoundingBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#ifndef ITr2BoundingBox_h
#define ITr2BoundingBox_h

struct Vector3;
struct Obb;

BLUE_INTERFACE( ITr2BoundingBox ) :
IRoot
{
virtual bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const = 0;
virtual bool GetWorldBoundingObb( Obb & obb ) const = 0;
virtual bool IsBoundingBoxReady( void ) const = 0;
};

Expand Down
14 changes: 13 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,21 @@ bool Tr2IntSkinnedObject::GetWorldBoundingBox( Vector3& min, Vector3& max ) cons
return true;
}

bool Tr2IntSkinnedObject::GetWorldBoundingObb( Obb& obb ) const
{
Vector3 min, max;
if( !GetLocalBoundingBox( min, max ) )
{
return false;
}
obb.CreateWorldBoundingObb( min, max, 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 GetWorldBoundingObb( Obb& obb ) const;

// Apex
void AddToApexScene( Tr2ApexScene* apexScene );
void RemoveFromApexScene( void );
Expand Down
12 changes: 12 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,17 @@ bool Tr2InteriorPlaceable::GetWorldBoundingBox( Vector3& min, Vector3& max ) con
return true;
}

bool Tr2InteriorPlaceable::GetWorldBoundingObb( Obb& obb ) const
{
Vector3 min, max;
if( !GetLocalBoundingBox( min, max ) )
{
return false;
}
obb.CreateWorldBoundingObb( min, max, 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 GetWorldBoundingObb( Obb& obb ) const;
virtual void PrePhysicsUpdate( Be::Time time );
virtual void PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene );

Expand Down
Loading