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
4 changes: 3 additions & 1 deletion trinity/Eve/EveEffectRoot2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ void EveEffectRoot2::UpdateSyncronous( const EveUpdateContext& updateContext )

for( TriObserverLocalVector::iterator it = m_observers.begin(); it != m_observers.end(); ++it )
{
( *it )->SetParentBall( m_ballPosition );
Comment thread
phevosccp marked this conversation as resolved.
Resolved
( *it )->Update( m_lastUpdateMatrix );
}

Expand All @@ -220,6 +221,7 @@ void EveEffectRoot2::UpdateSyncronous( const EveUpdateContext& updateContext )
params.bones = nullptr;
params.localToWorldTransform = worldTransform;
params.isVisible = m_display;
params.ballPosition = m_ballPosition;

for( auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt )
{
Expand Down Expand Up @@ -1007,7 +1009,7 @@ ITr2AudEmitterPtr EveEffectRoot2::FindSoundEmitter( const char* name )

void EveEffectRoot2::AddObserver( TriObserverLocalPtr observer )
{
m_observers.Append( observer );
m_observers.Append( observer->GetRawRoot() );
}

void EveEffectRoot2::SetMute( bool isMute )
Expand Down
13 changes: 12 additions & 1 deletion trinity/Eve/SpaceObject/Children/EveChildAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#include "StdAfx.h"
#include "EveChildAudio.h"

#include <ITr2AudParentBall.h>
#include <ITriFunction.h>
Comment thread
phevosccp marked this conversation as resolved.
Resolved


EveChildAudio::EveChildAudio( IRoot* lockobj ) :
m_mute( false ),
m_worldTransform( IdentityMatrix() )
m_worldTransform( IdentityMatrix() ),
m_parentBall( nullptr )
{
m_name = BlueSharedString( "EveChildAudio" );
}
Expand All @@ -16,6 +20,7 @@ bool EveChildAudio::Initialize()
// Early exit if already initialized
if( m_audioEmitter )
{
m_parentBall = dynamic_cast<ITr2AudParentBall*>( m_audioEmitter.p );
return true;
}

Expand All @@ -33,6 +38,7 @@ bool EveChildAudio::Initialize()
emitterName = m_name.c_str();
}
m_audioEmitter->Initialize( emitterName, L"", position );
m_parentBall = dynamic_cast<ITr2AudParentBall*>( m_audioEmitter.p );

return true;
}
Expand Down Expand Up @@ -98,6 +104,11 @@ void EveChildAudio::UpdateSyncronous( const EveUpdateContext& updateContext, con

if( m_audioEmitter && !m_mute )
{
if( m_parentBall )
{
m_parentBall->SetParentBall( params.ballPosition );
}

Vector3 position = m_worldTransform.GetTranslation();
Quaternion rotation = RotationQuaternion( m_worldTransform );
Matrix rotationMatrix = RotationMatrix( rotation );
Expand Down
2 changes: 2 additions & 0 deletions trinity/Eve/SpaceObject/Children/EveChildAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// Forward declarations and smart pointer typedefs
BLUE_DECLARE_INTERFACE( ITr2AudEmitter );
BLUE_DECLARE_IVECTOR( ITr2AudEmitter );
BLUE_DECLARE_INTERFACE( ITr2AudParentBall );
BLUE_DECLARE( EveChildAudio );

/**
Expand Down Expand Up @@ -85,6 +86,7 @@ BLUE_CLASS( EveChildAudio ) :
Matrix m_worldTransform; ///< Cached world transformation matrix.
bool m_mute; ///< Whether audio playback is muted.
ITr2AudEmitterPtr m_audioEmitter; ///< The audio emitter instance.
ITr2AudParentBall* m_parentBall;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion trinity/Eve/SpaceObject/Children/EveChildContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ void EveChildContainer::UpdateSyncronous( const EveUpdateContext& updateContext,
}
for( auto it = m_observers.begin(); it != m_observers.end(); it++ )
{
( *it )->SetParentBall( params.ballPosition );
( *it )->Update( m_worldTransform );
}
}
Expand Down Expand Up @@ -1061,7 +1062,7 @@ ITr2AudEmitterPtr EveChildContainer::FindSoundEmitter( const char* name )

void EveChildContainer::AddObserver( TriObserverLocalPtr observer )
{
m_observers.Append( observer );
m_observers.Append( observer->GetRawRoot() );
}

float EveChildContainer::GetOwnerMaxSpeed() const
Expand Down
6 changes: 5 additions & 1 deletion trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Tr2LightManager;
BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild );
BLUE_DECLARE( EveSpaceObjectChild );
BLUE_DECLARE_INTERFACE( IEveChildTransformModifier );
BLUE_DECLARE_INTERFACE( ITriVectorFunction );

struct EveChildUpdateParams
{
Expand All @@ -27,7 +28,8 @@ struct EveChildUpdateParams
isVisible( true ),
localToWorldTransform( IdentityMatrix() ),
controllerUpdateFrequency( 0.5f ),
worldVelocity( 0.f, 0.f, 0.f )
worldVelocity( 0.f, 0.f, 0.f ),
ballPosition( nullptr )
{
}

Expand All @@ -41,6 +43,8 @@ struct EveChildUpdateParams
bool isVisible;
Matrix localToWorldTransform;
Vector3 worldVelocity;
/// Translation curve of the root space object, usually its destiny ball. May be nullptr.
ITriVectorFunction* ballPosition;
};

/**
Expand Down
4 changes: 3 additions & 1 deletion trinity/Eve/SpaceObject/EveSpaceObject2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ void EveSpaceObject2::UpdateSyncronous( const EveUpdateContext& updateContext )
Matrix observerTransform = GetObserverTransform();
for( TriObserverLocalVector::iterator it = m_observers.begin(); it != observersEnd; ++it )
{
( *it )->SetParentBall( m_ballPosition );
Comment thread
phevosccp marked this conversation as resolved.
Resolved
( *it )->Update( observerTransform );
}

Expand All @@ -595,6 +596,7 @@ void EveSpaceObject2::UpdateSyncronous( const EveUpdateContext& updateContext )
params.ownerMaxSpeed = m_maxSpeed;
params.activationStrength = m_activationStrength;
params.localToWorldTransform = worldTransform;
params.ballPosition = m_ballPosition;

Tr2GrannyAnimationUtils::GetBoneList( m_animationUpdater, params.bones, params.boneCount );

Expand Down Expand Up @@ -3393,7 +3395,7 @@ void EveSpaceObject2::AddController( ITr2Controller* controller )
// --------------------------------------------------------------------------------
void EveSpaceObject2::AddObserver( TriObserverLocalPtr observer )
{
m_observers.Append( observer );
m_observers.Append( observer->GetRawRoot() );
}

// --------------------------------------------------------------------------------
Expand Down
23 changes: 22 additions & 1 deletion trinity/TriObserverLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

#include "StdAfx.h"
#include <ITr2AudEmitter.h>
#include <ITr2AudParentBall.h>
#include "TriObserverLocal.h"


TriObserverLocal::TriObserverLocal( IRoot* lockobj ) :
m_front( 0.0f, 0.0f, 1.0f ),
m_position( 0.0f, 0.0f, 0.0f ),
m_mute( false )
m_mute( false ),
m_parentBall( nullptr ),
m_parentBallStale( true )
{
}

Expand Down Expand Up @@ -41,6 +44,19 @@ void TriObserverLocal::Update( const Matrix& worldTransform )
}
}

void TriObserverLocal::SetParentBall( IRoot* ball )
{
if( m_parentBallStale )
{
m_parentBall = dynamic_cast<ITr2AudParentBall*>( m_observer.p );
m_parentBallStale = false;
}
if( m_parentBall )
{
m_parentBall->SetParentBall( ball );
}
}

IBluePlacementObserver* TriObserverLocal::GetObserver()
{
return m_observer;
Expand All @@ -49,6 +65,7 @@ IBluePlacementObserver* TriObserverLocal::GetObserver()
void TriObserverLocal::SetObserver( IBluePlacementObserver* obs )
{
m_observer = obs;
m_parentBallStale = true;
}

void TriObserverLocal::SetPosition( Vector3 pos )
Expand Down Expand Up @@ -90,6 +107,10 @@ void TriObserverLocal::SetMute( bool isMute )

bool TriObserverLocal::OnModified( Be::Var* val )
{
if( IsMatch( val, m_observer ) )
{
m_parentBallStale = true;
}
return true;
}

Expand Down
8 changes: 7 additions & 1 deletion trinity/TriObserverLocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

#include <ITriObserverLocal.h>

BLUE_DECLARE_INTERFACE( ITr2AudParentBall );

struct Vector3;
struct Matrix;

BLUE_CLASS( TriObserverLocal ) :
public ITriObserverLocal
public ITriObserverLocal,
public INotify
{
public:
TriObserverLocal( IRoot* lockobj = NULL );
Expand All @@ -22,6 +24,8 @@ BLUE_CLASS( TriObserverLocal ) :
EXPOSE_TO_BLUE();

void Update( const Matrix& worldTransform );
/// Tells an audio emitter observer which ball it is mounted on. Does nothing for other observers.
void SetParentBall( IRoot * ball );

// ITriObserverLocal
IBluePlacementObserver* GetObserver();
Expand All @@ -47,6 +51,8 @@ BLUE_CLASS( TriObserverLocal ) :
Vector3 m_front;
Vector3 m_position;
IBluePlacementObserverPtr m_observer;
ITr2AudParentBall* m_parentBall;
bool m_parentBallStale;
};

BLUE_DECLARE_VECTOR( TriObserverLocal );
Expand Down
3 changes: 2 additions & 1 deletion trinity/TriObserverLocal_Blue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ const Be::ClassInfo* TriObserverLocal::ExposeToBlue()
{
EXPOSURE_BEGIN( TriObserverLocal, "Connects locators to placement observers." )
MAP_INTERFACE( ITriObserverLocal )
MAP_INTERFACE( INotify )

MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST )
MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST )
MAP_ATTRIBUTE( "front", m_front, "", Be::READWRITE | Be::PERSIST )
MAP_PROPERTY( "mute", GetMute, SetMute, "" )
MAP_ATTRIBUTE( "observer", m_observer, "", Be::READWRITE | Be::PERSIST )
MAP_ATTRIBUTE( "observer", m_observer, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY )


EXPOSURE_END()
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
{
"name": "carbon-trinityaudioapi",
"version>=": "3.1.0"
"version>=": "3.2.0"
},
{
"name": "freetype",
Expand Down
Loading