From a0d04a0ac495aa55a622d6ed0d8a897f7c4876b9 Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Fri, 17 Jul 2026 15:25:56 +0000 Subject: [PATCH 01/29] Refactor IEveSpaceObjectChild interface into a base class The new base class has support "owner", "parent" and "part tag" shared attributes. --- trinity/CMakeLists.txt | 3 + .../Actions/Tr2ActionChildEffect.cpp | 4 +- .../Actions/Tr2ActionChildEffect.h | 4 +- .../Actions/Tr2ActionPlayCurveSet.cpp | 1 - trinity/Eve/EveEffectRoot2.cpp | 29 ++++- trinity/Eve/EveEffectRoot2.h | 12 +- .../Eve/Renderable/Stretch/EveStretch3.cpp | 52 ++++---- trinity/Eve/Renderable/Stretch/EveStretch3.h | 32 ++--- .../SpaceObject/Children/EveChildAudio.cpp | 41 +------ .../Eve/SpaceObject/Children/EveChildAudio.h | 15 +-- .../Children/EveChildAudio_Blue.cpp | 4 + .../Children/EveChildBehaviorSystem.cpp | 20 +-- .../Children/EveChildBehaviorSystem.h | 10 +- .../Children/EveChildBehaviorSystem_Blue.cpp | 4 + .../Children/EveChildBulletStorm.cpp | 28 ----- .../Children/EveChildBulletStorm.h | 15 +-- .../Children/EveChildBulletStorm_Blue.cpp | 4 + .../SpaceObject/Children/EveChildCloud.cpp | 10 -- .../Eve/SpaceObject/Children/EveChildCloud.h | 13 +- .../SpaceObject/Children/EveChildCloud2.cpp | 18 --- .../Eve/SpaceObject/Children/EveChildCloud2.h | 17 +-- .../Children/EveChildCloud2_Blue.cpp | 4 + .../Children/EveChildCloud_Blue.cpp | 4 + .../Children/EveChildContainer.cpp | 48 +++++--- .../SpaceObject/Children/EveChildContainer.h | 20 ++- .../Children/EveChildContainer_Blue.cpp | 10 +- .../Children/EveChildEffectPropagator.cpp | 6 +- .../Children/EveChildEffectPropagator.h | 1 - .../EveChildEffectPropagator_Blue.cpp | 4 + .../Children/EveChildExplosion.cpp | 8 +- .../SpaceObject/Children/EveChildExplosion.h | 12 +- .../Children/EveChildExplosion_Blue.cpp | 4 + .../Children/EveChildFogVolume.cpp | 20 +-- .../SpaceObject/Children/EveChildFogVolume.h | 14 +-- .../Children/EveChildFogVolume_Blue.cpp | 5 +- .../Children/EveChildInstanceContainer.cpp | 116 +++++++++++------- .../Children/EveChildInstanceContainer.h | 31 +++-- .../EveChildInstanceContainer_Blue.cpp | 95 +++++++------- .../Children/EveChildInstanceMeshRenderer.h | 2 +- .../EveChildInstanceMeshRenderer_Blue.cpp | 4 + .../Children/EveChildInstancedMeshes.cpp | 14 --- .../Children/EveChildInstancedMeshes.h | 10 +- .../Children/EveChildInstancedMeshes_Blue.cpp | 4 + .../Children/EveChildLightingOverride.cpp | 14 --- .../Children/EveChildLightingOverride.h | 15 +-- .../EveChildLightingOverride_Blue.cpp | 4 + .../SpaceObject/Children/EveChildLineSet.cpp | 10 -- .../SpaceObject/Children/EveChildLineSet.h | 11 +- .../Children/EveChildLineSet_Blue.cpp | 4 + .../Eve/SpaceObject/Children/EveChildLink.h | 2 +- .../Eve/SpaceObject/Children/EveChildMesh.cpp | 10 -- .../Eve/SpaceObject/Children/EveChildMesh.h | 11 +- .../Children/EveChildMesh_Blue.cpp | 5 + .../Children/EveChildParticleSphere.cpp | 12 -- .../Children/EveChildParticleSphere.h | 11 +- .../Children/EveChildParticleSphere_Blue.cpp | 4 + .../Children/EveChildParticleSystem.cpp | 10 -- .../Children/EveChildParticleSystem.h | 10 +- .../Children/EveChildParticleSystem_Blue.cpp | 4 + .../Eve/SpaceObject/Children/EveChildPlug.cpp | 47 ++++--- .../Eve/SpaceObject/Children/EveChildPlug.h | 20 ++- .../Children/EveChildPlug_Blue.cpp | 4 + .../Children/EveChildPostProcessVolume.cpp | 19 +-- .../Children/EveChildPostProcessVolume.h | 14 +-- .../EveChildPostProcessVolume_Blue.cpp | 4 + .../Eve/SpaceObject/Children/EveChildQuad.cpp | 14 --- .../Eve/SpaceObject/Children/EveChildQuad.h | 11 +- .../Children/EveChildQuad_Blue.cpp | 4 + .../Eve/SpaceObject/Children/EveChildRef.cpp | 49 +++++--- .../Eve/SpaceObject/Children/EveChildRef.h | 21 ++-- .../SpaceObject/Children/EveChildRef_Blue.cpp | 4 + .../SpaceObject/Children/EveChildSocket.cpp | 44 ++++--- .../Eve/SpaceObject/Children/EveChildSocket.h | 19 ++- .../Children/EveChildSocket_Blue.cpp | 4 + .../SpaceObject/Children/EveChildSpherePin.h | 2 +- .../Children/IEveEffectChildrenOwner.h | 8 +- .../Children/IEveSpaceObjectChild.h | 57 ++------- .../EveChildProceduralContainer.cpp | 39 ++++-- .../EveChildProceduralContainer.h | 16 ++- .../EveChildProceduralContainer_Blue.cpp | 4 + .../SmartLightSets/EveChildSmartLightSet.cpp | 10 -- .../SmartLightSets/EveChildSmartLightSet.h | 14 +-- .../EveChildSmartLightSet_Blue.cpp | 4 + .../EveSmartLightBaseAttributeModifier.h | 2 +- trinity/Eve/SpaceObject/EveSpaceObject2.cpp | 29 ++++- trinity/Eve/SpaceObject/EveSpaceObject2.h | 10 +- .../fxAttributes/EveCameraFxAttributes.h | 2 +- trinity/Eve/SpaceObjectFactory/EveSOF.cpp | 22 ++-- trinity/Eve/Turret/EveTurretFiringFX.h | 4 +- trinity/Eve/Turret/EveTurretSet.cpp | 8 +- trinity/Eve/Turret/EveTurretSet.h | 8 +- trinity/Eve/UI/EveEllipseSet.cpp | 14 --- trinity/Eve/UI/EveEllipseSet.h | 10 +- trinity/Eve/UI/EveEllipseSet_Blue.cpp | 4 + trinity/trinity.cpp | 6 +- 95 files changed, 653 insertions(+), 807 deletions(-) diff --git a/trinity/CMakeLists.txt b/trinity/CMakeLists.txt index 606b971e0..13c53c2f8 100644 --- a/trinity/CMakeLists.txt +++ b/trinity/CMakeLists.txt @@ -572,6 +572,9 @@ set(_SOURCES Eve/SpaceObject/Children/EveCloudEditableVolume.cpp Eve/SpaceObject/Children/EveCloudEditableVolume.h Eve/SpaceObject/Children/EveCloudEditableVolume_Blue.cpp + Eve/SpaceObject/Children/EveSpaceObjectChild.cpp + Eve/SpaceObject/Children/EveSpaceObjectChild.h + Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp Eve/SpaceObject/Children/IEveEffectChildrenOwner.h Eve/SpaceObject/Children/IEveSpaceObjectChild.h Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierProcessLifetime.cpp diff --git a/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp b/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp index 637e4b83d..2ff61cfb4 100644 --- a/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp +++ b/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp @@ -4,7 +4,7 @@ #include "Tr2ActionChildEffect.h" #include "Controllers/Tr2Controller.h" #include "Eve/SpaceObject/Children/IEveEffectChildrenOwner.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Eve/EveMultiEffect.h" #include "Eve/EveMultiEffectParameter.h" #include "Eve/Renderable/Stretch/EveStretch3.h" @@ -115,7 +115,7 @@ void Tr2ActionChildEffect::Start( ITr2ActionController& controller ) } if( m_addOnStart && !m_child && !m_path.empty() ) { - m_child = BeResMan->LoadObject( m_path.c_str() ); + m_child = BeResMan->LoadObject( m_path.c_str() ); if( m_child ) { if( !m_childName.empty() ) diff --git a/trinity/Controllers/Actions/Tr2ActionChildEffect.h b/trinity/Controllers/Actions/Tr2ActionChildEffect.h index 10efcb47e..77f53a5b0 100644 --- a/trinity/Controllers/Actions/Tr2ActionChildEffect.h +++ b/trinity/Controllers/Actions/Tr2ActionChildEffect.h @@ -4,7 +4,7 @@ #include "ITr2ControllerAction.h" -BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); BLUE_CLASS( Tr2ActionChildEffect ) : @@ -21,7 +21,7 @@ BLUE_CLASS( Tr2ActionChildEffect ) : private: std::string m_path; std::string m_childName; - IEveSpaceObjectChildPtr m_child; + EveSpaceObjectChildPtr m_child; bool m_addOnStart; bool m_removeOnStop; BlueSharedString m_targetAnotherOwner; diff --git a/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp b/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp index eed76b4ac..ca8b094d5 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp +++ b/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp @@ -7,7 +7,6 @@ #include "Curves/TriCurveSet.h" #include "Eve/SpaceObject/EveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" #include "Eve/EveEffectRoot2.h" diff --git a/trinity/Eve/EveEffectRoot2.cpp b/trinity/Eve/EveEffectRoot2.cpp index b37c60d85..70eb1bdf3 100644 --- a/trinity/Eve/EveEffectRoot2.cpp +++ b/trinity/Eve/EveEffectRoot2.cpp @@ -49,10 +49,18 @@ EveEffectRoot2::~EveEffectRoot2() { controller->Unlink( UnlinkReason::DELETING ); } + for( auto& child : m_effectChildren ) + { + child->SetOwner( nullptr ); + } } bool EveEffectRoot2::Initialize() { + for( auto& child : m_effectChildren ) + { + child->SetOwner( this ); + } for( auto& controller : m_controllers ) { if( !controller->IsLinked() ) @@ -113,8 +121,9 @@ void EveEffectRoot2::OnListModified( long event, ssize_t key, ssize_t key2, IRoo switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - if( IEveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) { + child->SetOwner( this ); for( auto it = begin( m_controllerVariables ); it != end( m_controllerVariables ); ++it ) { child->SetControllerVariable( it->first.c_str(), it->second ); @@ -137,6 +146,10 @@ void EveEffectRoot2::OnListModified( long event, ssize_t key, ssize_t key2, IRoo entity->UnRegister( GetComponentRegistry() ); } } + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + { + child->SetOwner( nullptr ); + } break; case BELIST_UNLOADSTART: if( IsInRegistry() ) @@ -149,6 +162,10 @@ void EveEffectRoot2::OnListModified( long event, ssize_t key, ssize_t key2, IRoo } } } + for( auto& child : m_effectChildren ) + { + child->SetOwner( nullptr ); + } default: break; } @@ -668,7 +685,7 @@ void EveEffectRoot2::GetMissPosition( const Vector3* hit, const Vector3* source, } // ----------------------------------------------------------------------------- -PIEveSpaceObjectChildVector& EveEffectRoot2::GetChildren() +PEveSpaceObjectChildVector& EveEffectRoot2::GetChildren() { return m_effectChildren; } @@ -884,7 +901,7 @@ void EveEffectRoot2::StartControllers() } // -------------------------------------------------------------------------------- -IEveSpaceObjectChildPtr EveEffectRoot2::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveEffectRoot2::GetEffectChildByName( const char* name ) const { for( auto it = begin( m_effectChildren ); it != end( m_effectChildren ); ++it ) { @@ -898,7 +915,7 @@ IEveSpaceObjectChildPtr EveEffectRoot2::GetEffectChildByName( const char* name ) } // -------------------------------------------------------------------------------- -void EveEffectRoot2::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveEffectRoot2::AddToEffectChildrenList( EveSpaceObjectChild* child ) { if( IsInRegistry() && m_display ) { @@ -911,7 +928,7 @@ void EveEffectRoot2::AddToEffectChildrenList( IEveSpaceObjectChild* child ) } // -------------------------------------------------------------------------------- -void EveEffectRoot2::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveEffectRoot2::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { auto index = m_effectChildren.FindKey( child ); if( index >= 0 ) @@ -931,7 +948,7 @@ void EveEffectRoot2::SetShaderOption( const BlueSharedString& name, const BlueSh { for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) { - IEveSpaceObjectChild* child = *it; + EveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } } diff --git a/trinity/Eve/EveEffectRoot2.h b/trinity/Eve/EveEffectRoot2.h index 2f49183c5..7114339a1 100644 --- a/trinity/Eve/EveEffectRoot2.h +++ b/trinity/Eve/EveEffectRoot2.h @@ -9,7 +9,7 @@ #include "EveTransform.h" #include "EveLODHelper.h" #include "IEveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Eve/SpaceObject/Children/IEveEffectChildrenOwner.h" #include "Tr2ShLightingManager.h" #include "Include/ITriTargetable.h" @@ -134,9 +134,9 @@ BLUE_CLASS( EveEffectRoot2 ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; ///////////////////////////////////////////////////////////////////////////////////// @@ -160,7 +160,7 @@ BLUE_CLASS( EveEffectRoot2 ) : void Start(); void Stop(); - PIEveSpaceObjectChildVector& GetChildren(); + PEveSpaceObjectChildVector& GetChildren(); void SetTransform( const Matrix& transform ); @@ -204,7 +204,7 @@ BLUE_CLASS( EveEffectRoot2 ) : std::string m_name; bool m_display; bool m_mute; - PIEveSpaceObjectChildVector m_effectChildren; + PEveSpaceObjectChildVector m_effectChildren; Vector3 m_scaling; Quaternion m_rotation; diff --git a/trinity/Eve/Renderable/Stretch/EveStretch3.cpp b/trinity/Eve/Renderable/Stretch/EveStretch3.cpp index ef4a5711e..f518ca15e 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch3.cpp +++ b/trinity/Eve/Renderable/Stretch/EveStretch3.cpp @@ -13,7 +13,7 @@ #include "Lights/Tr2PointLight.h" #include "Controllers/ITr2Controller.h" #include "Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Audio/Tr2AudioStretchAuto.h" #include "Audio/Tr2AudioStretchBase.h" @@ -123,7 +123,7 @@ void EveStretch3::Rebind( bool onlyUpdateBindings ) } } -void EveStretch3::RunOnComponents( std::function func ) const +void EveStretch3::RunOnComponents( std::function func ) const { if( m_sourceObject ) { @@ -146,7 +146,7 @@ void EveStretch3::RunOnComponents( std::function } } -float EveStretch3::RunOnComponentsGetMax( std::function func ) const +float EveStretch3::RunOnComponentsGetMax( std::function func ) const { float ret = -1.f; if( m_sourceObject ) @@ -211,12 +211,12 @@ std::unordered_map EveStretch3::GetParameterMap() const return parameterMap; } -IEveSpaceObjectChild* EveStretch3::GetSourceObject() +EveSpaceObjectChild* EveStretch3::GetSourceObject() { return m_sourceObject; } -void EveStretch3::SetSourceObject( IEveSpaceObjectChild* sourceObject ) +void EveStretch3::SetSourceObject( EveSpaceObjectChild* sourceObject ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_sourceObject ) ) @@ -230,12 +230,12 @@ void EveStretch3::SetSourceObject( IEveSpaceObjectChild* sourceObject ) } } -IEveSpaceObjectChild* EveStretch3::GetDestObject() +EveSpaceObjectChild* EveStretch3::GetDestObject() { return m_destObject; } -void EveStretch3::SetDestObject( IEveSpaceObjectChild* destObject ) +void EveStretch3::SetDestObject( EveSpaceObjectChild* destObject ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_destObject ) ) @@ -249,12 +249,12 @@ void EveStretch3::SetDestObject( IEveSpaceObjectChild* destObject ) } } -IEveSpaceObjectChild* EveStretch3::GetStretchObject() +EveSpaceObjectChild* EveStretch3::GetStretchObject() { return m_stretchObject; } -void EveStretch3::SetStretchObject( IEveSpaceObjectChild* stretchObject ) +void EveStretch3::SetStretchObject( EveSpaceObjectChild* stretchObject ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_stretchObject ) ) @@ -280,12 +280,12 @@ void EveStretch3::SetStretchObject( IEveSpaceObjectChild* stretchObject ) } } -IEveSpaceObjectChild* EveStretch3::GetMoveObject() +EveSpaceObjectChild* EveStretch3::GetMoveObject() { return m_moveObject; } -void EveStretch3::SetMoveObject( IEveSpaceObjectChild* moveObject ) +void EveStretch3::SetMoveObject( EveSpaceObjectChild* moveObject ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_moveObject ) ) @@ -605,7 +605,7 @@ void EveStretch3::GetRenderables( std::vector& renderables, Tr2 return; } - RunOnComponents( [&renderables]( IEveSpaceObjectChild* c ) { c->GetRenderables( renderables ); } ); + RunOnComponents( [&renderables]( EveSpaceObjectChild* c ) { c->GetRenderables( renderables ); } ); } void EveStretch3::SetDisplay( bool display ) @@ -724,7 +724,7 @@ void EveStretch3::RegisterComponents() if( registry && m_display ) { RunOnComponents( - [this]( IEveSpaceObjectChild* c ) { + [this]( EveSpaceObjectChild* c ) { if( EveEntityPtr entity = BlueCastPtr( c ) ) { entity->Register( GetComponentRegistry() ); @@ -739,7 +739,7 @@ void EveStretch3::UnRegisterComponents() if( registry ) { RunOnComponents( - [this]( IEveSpaceObjectChild* c ) { + [this]( EveSpaceObjectChild* c ) { if( EveEntityPtr entity = BlueCastPtr( c ) ) { entity->UnRegister( GetComponentRegistry() ); @@ -763,7 +763,7 @@ void EveStretch3::GetBindingRoots( std::unordered_map& vari void EveStretch3::SetControllerVariable( const char* name, float value ) { - RunOnComponents( [name, value]( IEveSpaceObjectChild* c ) { c->SetControllerVariable( name, value ); } ); + RunOnComponents( [name, value]( EveSpaceObjectChild* c ) { c->SetControllerVariable( name, value ); } ); for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { @@ -774,7 +774,7 @@ void EveStretch3::SetControllerVariable( const char* name, float value ) void EveStretch3::HandleControllerEvent( const char* name ) { - RunOnComponents( [name]( IEveSpaceObjectChild* c ) { c->HandleControllerEvent( name ); } ); + RunOnComponents( [name]( EveSpaceObjectChild* c ) { c->HandleControllerEvent( name ); } ); for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { @@ -784,7 +784,7 @@ void EveStretch3::HandleControllerEvent( const char* name ) void EveStretch3::StartControllers() { - RunOnComponents( []( IEveSpaceObjectChild* c ) { c->StartControllers(); } ); + RunOnComponents( []( EveSpaceObjectChild* c ) { c->StartControllers(); } ); for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { @@ -799,7 +799,7 @@ void EveStretch3::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) { return; } - RunOnComponents( [&quadRenderer]( IEveSpaceObjectChild* c ) { c->RegisterWithQuadRenderer( quadRenderer ); } ); + RunOnComponents( [&quadRenderer]( EveSpaceObjectChild* c ) { c->RegisterWithQuadRenderer( quadRenderer ); } ); } void EveStretch3::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) @@ -809,7 +809,7 @@ void EveStretch3::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRend return; } - RunOnComponents( [&frustum, &quadRenderer]( IEveSpaceObjectChild* c ) { c->AddQuadsToQuadRenderer( frustum, quadRenderer ); } ); + RunOnComponents( [&frustum, &quadRenderer]( EveSpaceObjectChild* c ) { c->AddQuadsToQuadRenderer( frustum, quadRenderer ); } ); } void EveStretch3::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) @@ -837,7 +837,7 @@ void EveStretch3::SetDestObjectScale( float scale ) void EveStretch3::GetDebugOptions( Tr2DebugRendererOptions& options ) { options.insert( "Lights" ); - RunOnComponents( [&options]( IEveSpaceObjectChild* c ) { + RunOnComponents( [&options]( EveSpaceObjectChild* c ) { auto debugRenderable = dynamic_cast( c ); if( debugRenderable ) { @@ -862,7 +862,7 @@ void EveStretch3::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { return; } - RunOnComponents( [&renderer]( IEveSpaceObjectChild* c ) { + RunOnComponents( [&renderer]( EveSpaceObjectChild* c ) { auto debugRenderable = dynamic_cast( c ); if( debugRenderable ) { @@ -904,7 +904,7 @@ void EveStretch3::PlayCurveSet( const std::string& name, const std::string& rang } } - RunOnComponents( [name, rangeName]( IEveSpaceObjectChild* c ) { + RunOnComponents( [name, rangeName]( EveSpaceObjectChild* c ) { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { @@ -928,7 +928,7 @@ void EveStretch3::StopCurveSet( const std::string& name ) } } - RunOnComponents( [name]( IEveSpaceObjectChild* c ) { + RunOnComponents( [name]( EveSpaceObjectChild* c ) { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { @@ -947,7 +947,7 @@ void EveStretch3::UpdateCurveSet( const std::string& name, Be::Time time ) } } - RunOnComponents( [name, time]( IEveSpaceObjectChild* c ) { + RunOnComponents( [name, time]( EveSpaceObjectChild* c ) { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { @@ -971,7 +971,7 @@ float EveStretch3::GetCurveSetDuration( const std::string& name ) const maxDuration = max( maxDuration, ( *it )->GetMaxCurveDuration() ); } } - float componentMax = RunOnComponentsGetMax( [name]( IEveSpaceObjectChild* c ) -> float { + float componentMax = RunOnComponentsGetMax( [name]( EveSpaceObjectChild* c ) -> float { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { @@ -999,7 +999,7 @@ float EveStretch3::GetRangeDuration( const std::string& name, const std::string& } } - float componentMax = RunOnComponentsGetMax( [name, rangeName]( IEveSpaceObjectChild* c ) -> float { + float componentMax = RunOnComponentsGetMax( [name, rangeName]( EveSpaceObjectChild* c ) -> float { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { diff --git a/trinity/Eve/Renderable/Stretch/EveStretch3.h b/trinity/Eve/Renderable/Stretch/EveStretch3.h index 1040a537d..75b47d7d9 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch3.h +++ b/trinity/Eve/Renderable/Stretch/EveStretch3.h @@ -12,13 +12,13 @@ #include "Controllers/ITr2ControllerOwner.h" #include "Lights/ITr2LightOwner.h" #include "Lights/Tr2Light.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" BLUE_DECLARE( EveStretch3 ); BLUE_DECLARE( TriFloat ); BLUE_DECLARE( EveChildModifierStretch ); -BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); BLUE_DECLARE_INTERFACE( ITr2Controller ); BLUE_DECLARE_INTERFACE( ITriVectorFunction ); @@ -126,14 +126,14 @@ BLUE_CLASS( EveStretch3 ) : // ITr2SoundEmitterOwner ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; - IEveSpaceObjectChild* GetSourceObject(); - void SetSourceObject( IEveSpaceObjectChild * sourceObject ); - IEveSpaceObjectChild* GetDestObject(); - void SetDestObject( IEveSpaceObjectChild * destObject ); - IEveSpaceObjectChild* GetStretchObject(); - void SetStretchObject( IEveSpaceObjectChild * stretchObject ); - IEveSpaceObjectChild* GetMoveObject(); - void SetMoveObject( IEveSpaceObjectChild * moveObject ); + EveSpaceObjectChild* GetSourceObject(); + void SetSourceObject( EveSpaceObjectChild * sourceObject ); + EveSpaceObjectChild* GetDestObject(); + void SetDestObject( EveSpaceObjectChild * destObject ); + EveSpaceObjectChild* GetStretchObject(); + void SetStretchObject( EveSpaceObjectChild * stretchObject ); + EveSpaceObjectChild* GetMoveObject(); + void SetMoveObject( EveSpaceObjectChild * moveObject ); private: enum StretchState @@ -144,8 +144,8 @@ BLUE_CLASS( EveStretch3 ) : STRETCH_STATE_STOPPING }; - void RunOnComponents( std::function func ) const; - float RunOnComponentsGetMax( std::function func ) const; + void RunOnComponents( std::function func ) const; + float RunOnComponentsGetMax( std::function func ) const; void SetSourceSpaceObject( IEveSpaceObject2 * spaceObject ); void SetDestSpaceObject( IEveSpaceObject2 * spaceObject ); @@ -169,10 +169,10 @@ BLUE_CLASS( EveStretch3 ) : BlueWeakRef m_sourceSpaceObject; BlueWeakRef m_destSpaceObject; - IEveSpaceObjectChildPtr m_sourceObject; - IEveSpaceObjectChildPtr m_destObject; - IEveSpaceObjectChildPtr m_stretchObject; - IEveSpaceObjectChildPtr m_moveObject; + EveSpaceObjectChildPtr m_sourceObject; + EveSpaceObjectChildPtr m_destObject; + EveSpaceObjectChildPtr m_stretchObject; + EveSpaceObjectChildPtr m_moveObject; PTriCurveSetVector m_curveSets; Be::Time m_startTime; diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp b/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp index 0e8c8b2f9..0e7f9b9a0 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp @@ -5,10 +5,10 @@ EveChildAudio::EveChildAudio( IRoot* lockobj ) : - m_name( "EveChildAudio" ), m_mute( false ), m_worldTransform( IdentityMatrix() ) { + m_name = BlueSharedString( "EveChildAudio" ); } bool EveChildAudio::Initialize() @@ -30,7 +30,7 @@ bool EveChildAudio::Initialize() } else { - emitterName = m_name; + emitterName = m_name.c_str(); } m_audioEmitter->Initialize( emitterName, L"", position ); @@ -68,40 +68,17 @@ bool EveChildAudio::OnModified( Be::Var* val ) } else { - SetEmitterName( m_name ); + SetEmitterName( m_name.c_str() ); } } return true; } -const char* EveChildAudio::GetName() const -{ - return m_name.c_str(); -} - -void EveChildAudio::SetName( const char* name ) -{ - m_name = name; -} - void EveChildAudio::GetLocalToWorldTransform( Matrix& transform ) const { transform = m_worldTransform; } -void EveChildAudio::Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) -{ -} - -void EveChildAudio::GetRenderables( std::vector& renderables ) -{ -} - -bool EveChildAudio::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const -{ - return false; -} - void EveChildAudio::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { Matrix localToWorldTransform; @@ -130,10 +107,6 @@ void EveChildAudio::UpdateSyncronous( const EveUpdateContext& updateContext, con } } -void EveChildAudio::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) -{ -} - void EveChildAudio::SetEmitterName( const std::string& name ) { if( m_audioEmitter ) @@ -142,14 +115,6 @@ void EveChildAudio::SetEmitterName( const std::string& name ) } } -void EveChildAudio::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) -{ -} - -void EveChildAudio::ChangeLOD( Tr2Lod lod ) -{ -} - void EveChildAudio::GetDebugOptions( Tr2DebugRendererOptions& options ) { if( ITr2DebugRenderablePtr tmp = BlueCastPtr( m_audioEmitter ) ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio.h b/trinity/Eve/SpaceObject/Children/EveChildAudio.h index cbabd87cb..3b626c383 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio.h +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio.h @@ -3,7 +3,7 @@ #ifndef EVE_CHILD_AUDIO_H #define EVE_CHILD_AUDIO_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 @@ -27,7 +27,7 @@ BLUE_DECLARE( EveChildAudio ); * @brief Audio emitter that can be added as a child to EveChildContainer. */ BLUE_CLASS( EveChildAudio ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public IInitialize, public INotify, @@ -73,24 +73,15 @@ BLUE_CLASS( EveChildAudio ) : */ void SetEmitterName( const std::string& name ); - // Implementing the IEveSpaceObjectChild interface - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector & renderables ); - bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + // Implementing the EveSpaceObjectChild interface void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ); - void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); // ITr2DebugRenderable virtual void GetDebugOptions( Tr2DebugRendererOptions & options ) override; virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; private: - std::string m_name; ///< The name identifier for this audio child. Matrix m_worldTransform; ///< Cached world transformation matrix. bool m_mute; ///< Whether audio playback is muted. ITr2AudEmitterPtr m_audioEmitter; ///< The audio emitter instance. diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp index a156c15ed..1aeb552ad 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildAudio::ExposeToBlue() EXPOSURE_BEGIN( EveChildAudio, "Audio emitter space object child" ) MAP_INTERFACE( EveChildAudio ) MAP_INTERFACE( IEveSpaceObjectChild ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -20,5 +21,8 @@ const Be::ClassInfo* EveChildAudio::ExposeToBlue() MAP_METHOD_AND_WRAP( "SetEmitterName", SetEmitterName, "Sets emitter name" ) MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initialize the audio emitter after contruction/deserialization" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp index 0a2c09176..2cb9b827f 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp @@ -578,7 +578,7 @@ std::vector> EveChildBehaviorSystem::GetVertexElementAddedTh ///////////////////////////////////////////////////////////////////////////////////// -// IEveSpaceObjectChild +// EveSpaceObjectChild void EveChildBehaviorSystem::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { Matrix localToWorldTransform; @@ -615,11 +615,6 @@ void EveChildBehaviorSystem::UpdateAsyncronous( const EveUpdateContext& updateCo m_hasUpdated = true; } -const char* EveChildBehaviorSystem::GetName() const -{ - return m_name; -} - void EveChildBehaviorSystem::Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) { EveChildTransform::Setup( scale, rotation, translation, lowestLodVisible ); @@ -648,10 +643,6 @@ void EveChildBehaviorSystem::GetRenderables( std::vector& rende } } -void EveChildBehaviorSystem::SetName( const char* name ) -{ -} - void EveChildBehaviorSystem::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { if( !m_display ) @@ -665,11 +656,6 @@ void EveChildBehaviorSystem::UpdateVisibility( const EveUpdateContext& updateCon } } -bool EveChildBehaviorSystem::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const -{ - return true; -} - bool EveChildBehaviorSystem::GetInstanceBufferBoundingBox( unsigned int bufferIndex, Vector3& minBounds, Vector3& maxBounds ) const { return false; @@ -679,10 +665,6 @@ void EveChildBehaviorSystem::GetLocalToWorldTransform( Matrix& transform ) const { } -void EveChildBehaviorSystem::ChangeLOD( Tr2Lod lod ) -{ -} - void EveChildBehaviorSystem::RegisterComponents() { if( !m_display ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h index a5a4b4fe3..dcbbac7be 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h @@ -8,7 +8,7 @@ #include "Behaviors/BehaviorGroup.h" #include "Behaviors/SplineTunnelGroup.h" #include "Tr2DeviceResource.h" -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "TriRenderBatch.h" #include "ITr2Renderable.h" @@ -22,7 +22,7 @@ BLUE_DECLARE_VECTOR( BehaviorGroup ); BLUE_CLASS( EveChildBehaviorSystem ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public Tr2DeviceResource, public ITr2Renderable, public IInitialize, @@ -70,16 +70,11 @@ BLUE_CLASS( EveChildBehaviorSystem ) : { } - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); - bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); - void ChangeLOD( Tr2Lod lod ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -112,7 +107,6 @@ BLUE_CLASS( EveChildBehaviorSystem ) : bool OnPrepareResources(); void PassInVertexesToBehaviorGroups(); void PassInTunnelFunctionsToBehaviorGroups(); - char* m_name; bool m_behaviorGroupLoaded; bool m_behaviorGroupLoadedForTunnel; diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp index 7737739c7..1f34f4581 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp @@ -8,6 +8,7 @@ const Be::ClassInfo* EveChildBehaviorSystem::ExposeToBlue() { EXPOSURE_BEGIN( EveChildBehaviorSystem, "" ) MAP_INTERFACE( EveChildBehaviorSystem ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( INotify ) @@ -30,5 +31,8 @@ const Be::ClassInfo* EveChildBehaviorSystem::ExposeToBlue() GetVertexElementAddedThroughCode, "for validation and objects requiring vertex elements added to the shader through code\n:jessica-hidden: True" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp index ddb989ae1..062f2e4d2 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp @@ -77,18 +77,6 @@ bool EveChildBulletStorm::OnModified( Be::Var* val ) return true; } -// -------------------------------------------------------------------------------- -const char* EveChildBulletStorm::GetName() const -{ - return m_name.c_str(); -} - -// -------------------------------------------------------------------------------- -void EveChildBulletStorm::SetName( const char* name ) -{ - m_name = name; -} - // -------------------------------------------------------------------------------- // Description: // Trinity's way of rendering @@ -223,14 +211,6 @@ bool EveChildBulletStorm::GetBoundingSphere( Vector4& sphere, BoundingSphereQuer return true; } -// -------------------------------------------------------------------------------- -// Description: -// Syncronous updates happen here -// -------------------------------------------------------------------------------- -void EveChildBulletStorm::UpdateSyncronous( const EveUpdateContext&, const EveChildUpdateParams& ) -{ -} - void EveChildBulletStorm::StartEffect() { m_clipShereMul = 1.0f; @@ -317,14 +297,6 @@ void EveChildBulletStorm::GetLocalToWorldTransform( Matrix& transform ) const transform = m_worldTransform; } -// -------------------------------------------------------------------------------- -// Description: -// Used by state machine to animate state-related stuff -// -------------------------------------------------------------------------------- -void EveChildBulletStorm::Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) -{ -} - // -------------------------------------------------------------------------------- // Description: // Nothing transparent here, all additive! diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h index f78c16289..52f1c3df3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h @@ -4,7 +4,7 @@ #ifndef EveChildBulletStorm_H #define EveChildBulletStorm_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "ITr2Renderable.h" #include "Eve/SpaceObject/EveSpaceObject2.h" @@ -34,7 +34,7 @@ class EveChildBulletStormPerObjectData : public Tr2PerObjectData // A spaceobject child for rendering swarm like bullets // -------------------------------------------------------------------------------- BLUE_CLASS( EveChildBulletStorm ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2Renderable, public Tr2DeviceResource, public INotify, @@ -55,19 +55,11 @@ BLUE_CLASS( EveChildBulletStorm ) : bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) - { - } + // EveSpaceObjectChild void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ) {}; - void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable @@ -93,7 +85,6 @@ BLUE_CLASS( EveChildBulletStorm ) : private: // general data - std::string m_name; bool m_display; // Has UpdateSyncronous/UpdateAsyncronous been called: until it has, the object cannot be rendered bool m_hasUpdated = false; diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp index 86ba7b4a1..8b51cae94 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveChildBulletStorm::ExposeToBlue() { EXPOSURE_BEGIN( EveChildBulletStorm, "" ) MAP_INTERFACE( EveChildBulletStorm ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( INotify ) @@ -35,5 +36,8 @@ const Be::ClassInfo* EveChildBulletStorm::ExposeToBlue() MAP_METHOD_AND_WRAP( "StopEffect", StopEffect, "Stop Effect" ) MAP_METHOD_AND_WRAP( "CanChangeState", CanChangeState, "Can start or stop the effect without visual errors?" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp index c80462793..83fb8f5ca 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp @@ -208,16 +208,6 @@ bool EveChildCloud::OnModified( Be::Var* value ) return true; } -const char* EveChildCloud::GetName() const -{ - return m_name.c_str(); -} - -void EveChildCloud::SetName( const char* name ) -{ - m_name = name; -} - void EveChildCloud::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { auto& frustum = updateContext.GetFrustum(); diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud.h b/trinity/Eve/SpaceObject/Children/EveChildCloud.h index f6c107e28..27bfa4671 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud.h +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud.h @@ -6,7 +6,7 @@ #include "ITr2Renderable.h" #include "Eve/IEveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Tr2ShLightingManager.h" #include "Tr2DebugRenderer.h" @@ -24,7 +24,7 @@ BLUE_CLASS( EveChildCloud ) : public Tr2DeviceResource, public IInitialize, public INotify, - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2DebugRenderable { public: @@ -42,19 +42,13 @@ BLUE_CLASS( EveChildCloud ) : virtual bool OnModified( Be::Var * value ); ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - virtual const char* GetName() const; - virtual void SetName( const char* name ); + // EveSpaceObjectChild virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); virtual void GetLocalToWorldTransform( Matrix & transform ) const; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); virtual void GetRenderables( std::vector & renderables ); virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) - { - } - virtual void ChangeLOD( Tr2Lod lod ) {}; ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable @@ -94,7 +88,6 @@ BLUE_CLASS( EveChildCloud ) : Tr2BufferAL m_vertexBuffer; TrackableStdVector m_indexBuffers; - std::string m_name; bool m_display; bool m_isVisible; // Has UpdateSyncronous/UpdateAsyncronous been called: until it has, the object cannot be rendered diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp index 3e48803ae..ba6334b74 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp @@ -205,24 +205,6 @@ bool EveChildCloud2::OnModified( Be::Var* value ) return true; } -const char* EveChildCloud2::GetName() const -{ - return m_name.c_str(); -} - -void EveChildCloud2::SetName( const char* name ) -{ - m_name = name; -} - -void EveChildCloud2::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) -{ -} - -void EveChildCloud2::GetRenderables( std::vector& ) -{ -} - bool EveChildCloud2::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery ) const { sphere = Vector4( m_boundingSphere.center, m_boundingSphere.radius ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2.h b/trinity/Eve/SpaceObject/Children/EveChildCloud2.h index 9dce9cbbb..d641b48f4 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2.h +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2.h @@ -4,7 +4,7 @@ #include "ITr2Renderable.h" #include "Eve/IEveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Tr2DebugRenderer.h" #include "Tr2DepthStencil.h" #include "TriFrustumOrtho.h" @@ -27,12 +27,12 @@ BLUE_DECLARE( Tr2TextureAnimation ); // plane at the back of the object's bounding sphere using provided effect. // -------------------------------------------------------------------------------- BLUE_CLASS( EveChildCloud2 ) : + public EveSpaceObjectChild, public ITr2VolumetricRenderable, public Tr2DeviceResource, public IInitialize, public INotify, public IListNotify, - public IEveSpaceObjectChild, public ITr2DebugRenderable, public ITr2Renderable, public ITr2LightOwner, @@ -57,21 +57,11 @@ BLUE_CLASS( EveChildCloud2 ) : void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - virtual const char* GetName() const override; - virtual void SetName( const char* name ) override; + // EveSpaceObjectChild virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; virtual void GetLocalToWorldTransform( Matrix & transform ) const override; - virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - virtual void GetRenderables( std::vector & renderables ) override; virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; - virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override - { - } - virtual void ChangeLOD( Tr2Lod lod ) override - { - } ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner @@ -189,7 +179,6 @@ BLUE_CLASS( EveChildCloud2 ) : Tr2DepthStencilPtr m_shadowMapDS; TriVariable* m_depthShadowMapHandle; - std::string m_name; bool m_display; bool m_castShadows; bool m_receiveShadows; diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp index c4245e970..b9b921289 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp @@ -15,6 +15,7 @@ const Be::ClassInfo* EveChildCloud2::ExposeToBlue() MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( ITr2LightOwner ) @@ -65,5 +66,8 @@ const Be::ClassInfo* EveChildCloud2::ExposeToBlue() MAP_ATTRIBUTE( "mapOffset1", m_mapOffsets[1], "Texture offset 1. Used for debugging camera-attached clouds.\n:jessica-group: Tiling", Be::READ ) MAP_ATTRIBUTE( "mapOffset2", m_mapOffsets[2], "Texture offset 2. Used for debugging camera-attached clouds.\n:jessica-group: Tiling", Be::READ ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp index be2b2c06b..7e02f2205 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp @@ -13,6 +13,7 @@ const Be::ClassInfo* EveChildCloud::ExposeToBlue() MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_ATTRIBUTE( "name", m_name, "The name of the cloud", Be::READWRITE | Be::PERSIST ) @@ -36,5 +37,8 @@ const Be::ClassInfo* EveChildCloud::ExposeToBlue() MAP_ATTRIBUTE( "cellScreenSize", m_cellScreenSize, "Target size of a single cell in a grid on the screen (in pixels)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "currentLod", m_currentIB, "Current cloud LOD", Be::READ ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp b/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp index a0641cb6b..5f29c6b90 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp @@ -59,10 +59,12 @@ EveChildContainer::~EveChildContainer() { controller->Unlink( UnlinkReason::DELETING ); } + UnregisterChildren( m_objects ); } bool EveChildContainer::Initialize() { + RegisterChildren( m_objects ); for( auto& controller : m_controllers ) { if( !controller->IsLinked() ) @@ -142,6 +144,8 @@ void EveChildContainer::OnListModified( long event, ssize_t key, ssize_t key2, I } else if( list == &m_objects && ( event & BELIST_LOADING ) == 0 ) { + HandleChildrenListModified( event, value, m_objects ); + if( IsInRegistry() ) { switch( event & BELIST_EVENTMASK ) @@ -314,7 +318,7 @@ void EveChildContainer::SetShaderOption( const BlueSharedString& name, const Blu { for( auto it = m_objects.begin(); it != m_objects.end(); ++it ) { - IEveSpaceObjectChild* child = *it; + EveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } @@ -366,16 +370,6 @@ bool EveChildContainer::IsUpdating() const return ( m_display || !m_updateOnDisplay ) && ( IsRendering() || m_displayFilter == ONLY_REFLECTIONS ); } -const char* EveChildContainer::GetName() const -{ - return m_name.c_str(); -} - -void EveChildContainer::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildContainer::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { if( !m_display ) @@ -442,7 +436,7 @@ bool EveChildContainer::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if( ( *it )->GetBoundingSphere( bSphere ) ) + if( ( *it )->GetBoundingSphere( bSphere, EVE_BOUNDS_NORMAL ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -966,7 +960,7 @@ void EveChildContainer::StartControllers() } } -IEveSpaceObjectChildPtr EveChildContainer::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildContainer::GetEffectChildByName( const char* name ) const { for( auto it = begin( m_objects ); it != end( m_objects ); ++it ) { @@ -979,7 +973,7 @@ IEveSpaceObjectChildPtr EveChildContainer::GetEffectChildByName( const char* nam return nullptr; } -void EveChildContainer::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildContainer::AddToEffectChildrenList( EveSpaceObjectChild* child ) { auto childRoot = child->GetRootObject(); m_objects.Append( childRoot ); @@ -993,7 +987,7 @@ void EveChildContainer::AddToEffectChildrenList( IEveSpaceObjectChild* child ) } } -void EveChildContainer::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildContainer::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { auto index = m_objects.FindKey( child ); if( index >= 0 ) @@ -1111,6 +1105,30 @@ void EveChildContainer::SetProceduralContainerVariable( const char* name, float } } +void EveChildContainer::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + for( auto& child : m_objects ) + { + child->SetOwner( owner ); + } + } +} + +void EveChildContainer::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + for( auto& child : m_objects ) + { + child->SetPartTag( tag ); + } + } +} + void EveChildContainer::SetAnimationOwner( ITr2GrannyAnimationOwner* animationOwner ) { m_animationOwner = animationOwner; diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer.h b/trinity/Eve/SpaceObject/Children/EveChildContainer.h index e8bdeac85..7fa1faa73 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer.h @@ -4,7 +4,7 @@ #ifndef EveChildContainer_H #define EveChildContainer_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -31,7 +31,7 @@ BLUE_DECLARE_INTERFACE( IEveFxAttribute ); BLUE_DECLARE_IVECTOR( IEveFxAttribute ); BLUE_CLASS( EveChildContainer ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public ITr2CurveSetOwner, @@ -66,17 +66,19 @@ BLUE_CLASS( EveChildContainer ) : virtual bool OnModified( Be::Var * val ); ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + // EveSpaceObjectChild void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; bool IsAlwaysOn() const override; void AddTransformModifier( IEveChildTransformModifier * modifier ) override; void SetProceduralContainerVariable( const char* name, float value ) override; + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -111,9 +113,6 @@ BLUE_CLASS( EveChildContainer ) : uint32_t GetPerObjectDataSize( Tr2RenderContextEnum::ShaderType shaderType ) const; void UpdatePerObjectBuffer( Tr2RenderContextEnum::ShaderType shaderType, uint32_t size, void* ); - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -171,7 +170,7 @@ BLUE_CLASS( EveChildContainer ) : bool Empty() const; - PIEveSpaceObjectChildVector m_objects; + PEveSpaceObjectChildVector m_objects; protected: void DoUpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); @@ -183,7 +182,6 @@ BLUE_CLASS( EveChildContainer ) : bool HasRenderables() const; - BlueSharedString m_name; PTriCurveSetVector m_curveSets; PTriObserverLocalVector m_observers; PTr2LightVector m_lights; diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp index 9e345bbf3..42ac5b7c3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp @@ -5,11 +5,11 @@ Be::VarChooser EveSpaceObjectChildOriginChooser[] = { - { "SPACE", BeCast( IEveSpaceObjectChild::SPACE ), "Origin in Space" }, - { "SOF", BeCast( IEveSpaceObjectChild::SOF ), "Origin in SOF" }, + { "SPACE", BeCast( EveSpaceObjectChild::SPACE ), "Origin in Space" }, + { "SOF", BeCast( EveSpaceObjectChild::SOF ), "Origin in SOF" }, { 0 } }; -BLUE_REGISTER_ENUM_EX( "EveSpaceObjectChildOrigin", IEveSpaceObjectChild::Origin, EveSpaceObjectChildOriginChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); +BLUE_REGISTER_ENUM_EX( "EveSpaceObjectChildOrigin", EveSpaceObjectChild::Origin, EveSpaceObjectChildOriginChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); Be::VarChooser EveChildContainerDataSetShaderChooser[] = { { "None_", BeCast( EveChildContainer::SHADER_ALL ), "Visible to users with all shader settings" }, @@ -33,6 +33,7 @@ const Be::ClassInfo* EveChildContainer::ExposeToBlue() MAP_INTERFACE( EveChildContainer ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( ITr2LightOwner ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -106,5 +107,8 @@ const Be::ClassInfo* EveChildContainer::ExposeToBlue() StartControllers, "Start all controllers" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp index dc5824371..a2091ca8c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp @@ -39,6 +39,7 @@ EveChildEffectPropagator::EveChildEffectPropagator( IRoot* lockobj ) : EveChildEffectPropagator::~EveChildEffectPropagator() { + UnregisterChild( m_effect ); } @@ -130,6 +131,7 @@ void EveChildEffectPropagator::Stop() bool EveChildEffectPropagator::Initialize() { + RegisterChild( m_effect ); if( m_effect != nullptr ) { m_effect->DisableEditMode( true ); @@ -168,7 +170,7 @@ void EveChildEffectPropagator::ManageTriggers() // -------------------------------------------- // Description: -// Implements IEveSpaceObjectChild interface. +// Implements EveSpaceObjectChild interface. // -------------------------------------------- void EveChildEffectPropagator::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { @@ -646,10 +648,12 @@ void EveChildEffectPropagator::SetEffect( EveChildInstanceContainer* effect ) { // unregister the current effect UnRegisterComponents(); + UnregisterChild( m_effect ); m_effect = effect; // register again + RegisterChild( m_effect ); RegisterComponents(); } diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h index 12deb0d46..f4287aafe 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h @@ -98,7 +98,6 @@ BLUE_CLASS( EveChildEffectPropagator ) : float m_playTime; EveChildInstanceContainerPtr m_effect; // Child containing trigger effect - IEveSpaceObjectChildPtr m_effectShared; // Child containing shared parts of the effect (particle systems etc.) Vector3 m_effectScaling; float m_randScaleMin; diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp index 2391292dc..deca8722c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp @@ -27,6 +27,7 @@ const Be::ClassInfo* EveChildEffectPropagator::ExposeToBlue() EXPOSURE_BEGIN( EveChildEffectPropagator, "Specialized explosion propagator object child" ) MAP_INTERFACE( EveChildEffectPropagator ) MAP_INTERFACE( EveChildContainer ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( INotify ) MAP_INTERFACE( EveEntity ) @@ -72,5 +73,8 @@ const Be::ClassInfo* EveChildEffectPropagator::ExposeToBlue() MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform." ) MAP_METHOD_AND_WRAP( "Stop", Stop, "Stops effect playback.\n:jessica-favorite:\n:jessica-icon: timeline/stop.png" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp b/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp index a252e4579..a08bd47bb 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp @@ -174,7 +174,7 @@ void EveChildExplosion::SetGlobalExplosionOffset( const Vector3& offset ) // -------------------------------------------------------------------------------------- // Description: -// Implements IEveSpaceObjectChild interface. If the effect is playing this function +// Implements EveSpaceObjectChild interface. If the effect is playing this function // spawns explosions. // -------------------------------------------------------------------------------------- void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) @@ -224,7 +224,7 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, { if( m_globalExplosionInstances.empty() ) { - IEveSpaceObjectChildPtr instance; + EveSpaceObjectChildPtr instance; if( BeClasses->CopyTo( m_globalExplosion, (IRoot**)&instance.p ) ) { Quaternion rotation = Quaternion( 0.0, 0.0, 0.0, 1.0 ); @@ -261,7 +261,7 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, for( auto it = m_globalExplosions.begin(); it != m_globalExplosions.end(); ++it ) { auto globalExplosion = ( *it ); - IEveSpaceObjectChildPtr instance; + EveSpaceObjectChildPtr instance; if( BeClasses->CopyTo( globalExplosion, (IRoot**)&instance.p ) ) { m_globalExplosionContainer->m_objects.Append( instance ); @@ -460,7 +460,7 @@ void EveChildExplosion::SpawnLocalExplosion( const Matrix& transform ) { return; } - IEveSpaceObjectChildPtr instance; + EveSpaceObjectChildPtr instance; Transform t; Vector3 scale; diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion.h b/trinity/Eve/SpaceObject/Children/EveChildExplosion.h index 42953d774..4362c0319 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion.h +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion.h @@ -74,14 +74,14 @@ BLUE_CLASS( EveChildExplosion ) : // Child containing local explosion effect - IEveSpaceObjectChildPtr m_localExplosion; - PIEveSpaceObjectChildVector m_localExplosions; + EveSpaceObjectChildPtr m_localExplosion; + PEveSpaceObjectChildVector m_localExplosions; // Child containing shared parts of the local explosion effect (particle systems etc.) - IEveSpaceObjectChildPtr m_localExplosionShared; + EveSpaceObjectChildPtr m_localExplosionShared; // Child containing global explosion effect - IEveSpaceObjectChildPtr m_globalExplosion; - PIEveSpaceObjectChildVector m_globalExplosions; - PIEveSpaceObjectChildVector m_globalExplosionInstances; + EveSpaceObjectChildPtr m_globalExplosion; + PEveSpaceObjectChildVector m_globalExplosions; + PEveSpaceObjectChildVector m_globalExplosionInstances; EveChildContainerPtr m_globalExplosionContainer; // Transforms for local explosions diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp index 4a8777e78..e694d8237 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp @@ -12,6 +12,7 @@ const Be::ClassInfo* EveChildExplosion::ExposeToBlue() MAP_INTERFACE( EveChildExplosion ) MAP_INTERFACE( EveChildContainer ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) @@ -141,5 +142,8 @@ const Be::ClassInfo* EveChildExplosion::ExposeToBlue() "Sets the global explosion offset.\n" ":param offset: Vector3 that to be used as the global explosion offset should be in local coordinates" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.cpp b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.cpp index 15f13fbe3..92f9dafbd 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.cpp @@ -77,21 +77,7 @@ void EveChildFogVolume::UnRegisterComponents() } ///////////////////////////////////////////////////////////////////////////////////// -// IEveSpaceObjectChild -const char* EveChildFogVolume::GetName() const -{ - return m_name.c_str(); -} - -void EveChildFogVolume::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - -void EveChildFogVolume::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) -{ -} - +// EveSpaceObjectChild bool EveChildFogVolume::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { sphere.GetXYZ() = m_boundingSphere.center; @@ -100,10 +86,6 @@ bool EveChildFogVolume::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery return true; } -void EveChildFogVolume::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) -{ -} - void EveChildFogVolume::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { UpdateTransformFromParent( params ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h index 9e1d49362..86293a9f2 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h +++ b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "ITr2Renderable.h" #include "Tr2DebugRenderer.h" @@ -14,7 +14,7 @@ BLUE_DECLARE_IVECTOR( IEveVolume ); BLUE_CLASS( EveChildFogVolume ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public IInitialize, public ITr2DebugRenderable, @@ -29,19 +29,12 @@ BLUE_CLASS( EveChildFogVolume ) : void RebuildBoundingSphere(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - void GetRenderables( std::vector & renderables ) override{}; + // EveSpaceObjectChild bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query ) const override; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; - void ChangeLOD( Tr2Lod lod ) override {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; bool IsAlwaysOn() const override; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override {}; void RegisterComponents() override; void UnRegisterComponents() override; @@ -62,7 +55,6 @@ BLUE_CLASS( EveChildFogVolume ) : private: void UpdateTransformFromParent( const EveChildUpdateParams& params ); - BlueSharedString m_name; PIEveVolumeVector m_volumes; float m_intensity; diff --git a/trinity/Eve/SpaceObject/Children/EveChildFogVolume_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildFogVolume_Blue.cpp index 76f0c2582..cf5c6097c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildFogVolume_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildFogVolume_Blue.cpp @@ -11,6 +11,7 @@ const Be::ClassInfo* EveChildFogVolume::ExposeToBlue() EXPOSURE_BEGIN( EveChildFogVolume, "" ) MAP_INTERFACE( ITr2FroxelFogSettings ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) @@ -54,6 +55,8 @@ const Be::ClassInfo* EveChildFogVolume::ExposeToBlue() MAP_ATTRIBUTE( "boundingSphereCenter", m_boundingSphere.center, "", Be::READ ) MAP_ATTRIBUTE( "boundingSphereRadius", m_boundingSphere.radius, "", Be::READ ) MAP_ATTRIBUTE( "volumes", m_volumes, "", Be::READ | Be::PERSIST ) - + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp index 0d67cf3f0..e20b56091 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp @@ -54,16 +54,8 @@ EveChildInstanceContainer::EveChildInstanceContainer( IRoot* lockobj ) : EveChildInstanceContainer::~EveChildInstanceContainer() { -} - -const char* EveChildInstanceContainer::GetName() const -{ - return m_name.c_str(); -} - -void EveChildInstanceContainer::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); + UnregisterChildren( m_instances ); + UnregisterChild( m_source ); } bool EveChildInstanceContainer::OnModified( Be::Var* value ) @@ -121,25 +113,27 @@ void EveChildInstanceContainer::UnRegisterComponents() } } -void EveChildInstanceContainer::SetSourceEffect( IEveSpaceObjectChildPtr sourceEffect ) +void EveChildInstanceContainer::SetSourceEffect( EveSpaceObjectChildPtr sourceEffect ) { SetSource( sourceEffect ); m_reset = true; } -IEveSpaceObjectChildPtr EveChildInstanceContainer::GetSource() +EveSpaceObjectChildPtr EveChildInstanceContainer::GetSource() { return m_source; } -void EveChildInstanceContainer::SetSource( IEveSpaceObjectChild* source ) +void EveChildInstanceContainer::SetSource( EveSpaceObjectChild* source ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_source ) ) { entity->UnRegister( registry ); } + UnregisterChild( m_source ); m_source = source; + RegisterChild( m_source ); if( m_instances.empty() && !m_disableEditMode ) { if( EveEntityPtr entity = BlueCastPtr( m_source ) ) @@ -247,7 +241,7 @@ void EveChildInstanceContainer::CreateInstance( const Vector3& scale, const Quat EveChildContainerPtr translationParent; translationParent.CreateInstance(); - IEveSpaceObjectChildPtr instance; + EveSpaceObjectChildPtr instance; if( !BeClasses->CopyTo( m_source, (IRoot**)&instance ) ) { @@ -280,14 +274,20 @@ void EveChildInstanceContainer::CreateInstance( const Vector3& scale, const Quat boneParent->AddToEffectChildrenList( translationParent ); boneParent->RegisterWithQuadRenderer( *Tr2QuadRenderer::Instance() ); boneParent->Register( GetComponentRegistry() ); + boneParent->SetOwner( GetOwner() ); + boneParent->SetParent( this ); + boneParent->SetPartTag( GetPartTag() ); - m_instances.Append( (IEveSpaceObjectChildPtr)boneParent ); + m_instances.Append( boneParent->GetRawRoot() ); } else { translationParent->RegisterWithQuadRenderer( *Tr2QuadRenderer::Instance() ); translationParent->Register( GetComponentRegistry() ); - m_instances.Append( (IEveSpaceObjectChildPtr)translationParent ); + translationParent->SetOwner( GetOwner() ); + translationParent->SetParent( this ); + translationParent->SetPartTag( GetPartTag() ); + m_instances.Append( translationParent->GetRawRoot() ); } return; @@ -300,7 +300,7 @@ void EveChildInstanceContainer::CreateInstance( const Vector3& scale, const Quat // -------------------------------------------------------------------------------------- void EveChildInstanceContainer::UpdateInstance( const uint32_t index, const Vector3& scale, const Quaternion& rotation, const Vector3& translation ) { - auto instance = (IEveSpaceObjectChild*)m_instances.GetAt( index ); + auto instance = static_cast( m_instances.GetAt( index ) ); if( instance == nullptr ) { return; @@ -313,9 +313,9 @@ void EveChildInstanceContainer::UpdateInstance( const uint32_t index, const Vect // A helper method to run a function on the source (if the instances are not valid) or // on the instances // Arguments: -// func - The function to run, takes a single parameter which is an IEveSpaceObjectChild* +// func - The function to run, takes a single parameter which is an EveSpaceObjectChild* // -------------------------------------------------------------------------------------- -void EveChildInstanceContainer::RunOnInstances( std::function func ) const +void EveChildInstanceContainer::RunOnInstances( std::function func ) const { if( m_instances.empty() && m_source && !m_disableEditMode ) { @@ -339,6 +339,7 @@ void EveChildInstanceContainer::DisableEditMode( bool disable ) void EveChildInstanceContainer::ClearInstanceList() { UnRegisterComponents(); + UnregisterChildren( m_instances ); m_instances.Clear(); } @@ -353,7 +354,8 @@ void EveChildInstanceContainer::PopFront() front->UnRegister( GetComponentRegistry() ); } } - + m_instances[0]->SetOwner( nullptr ); + m_instances[0]->SetParent( nullptr ); m_instances.Remove( 0 ); } } @@ -370,7 +372,7 @@ void EveChildInstanceContainer::GetRenderables( std::vector& re return; } - RunOnInstances( [&renderables]( IEveSpaceObjectChild* c ) { c->GetRenderables( renderables ); } ); + RunOnInstances( [&renderables]( EveSpaceObjectChild* c ) { c->GetRenderables( renderables ); } ); } @@ -381,7 +383,7 @@ void EveChildInstanceContainer::UpdateVisibility( const EveUpdateContext& update return; } - RunOnInstances( [&updateContext, &parentTransform, parentLod]( IEveSpaceObjectChild* c ) { c->UpdateVisibility( updateContext, parentTransform, parentLod ); } ); + RunOnInstances( [&updateContext, &parentTransform, parentLod]( EveSpaceObjectChild* c ) { c->UpdateVisibility( updateContext, parentTransform, parentLod ); } ); } void EveChildInstanceContainer::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) @@ -405,7 +407,7 @@ void EveChildInstanceContainer::UpdateSyncronous( const EveUpdateContext& update newParams.childParent = this; newParams.localToWorldTransform = m_worldTransform; - RunOnInstances( [&updateContext, &newParams]( IEveSpaceObjectChild* c ) { c->UpdateSyncronous( updateContext, newParams ); } ); + RunOnInstances( [&updateContext, &newParams]( EveSpaceObjectChild* c ) { c->UpdateSyncronous( updateContext, newParams ); } ); } void EveChildInstanceContainer::AddTransformModifier( IEveChildTransformModifier* modifier ) @@ -430,7 +432,7 @@ void EveChildInstanceContainer::UpdateAsyncronous( const EveUpdateContext& updat newParams.childParent = this; newParams.localToWorldTransform = m_worldTransform; - RunOnInstances( [&updateContext, &newParams]( IEveSpaceObjectChild* c ) { c->UpdateAsyncronous( updateContext, newParams ); } ); + RunOnInstances( [&updateContext, &newParams]( EveSpaceObjectChild* c ) { c->UpdateAsyncronous( updateContext, newParams ); } ); if( params.spaceObjectParent && !params.childParent ) @@ -458,7 +460,7 @@ bool EveChildInstanceContainer::GetBoundingSphere( Vector4& sphere, BoundingSphe return true; } - RunOnInstances( [&sphere, &query]( IEveSpaceObjectChild* c ) { c->GetBoundingSphere( sphere, query ); } ); + RunOnInstances( [&sphere, &query]( EveSpaceObjectChild* c ) { c->GetBoundingSphere( sphere, query ); } ); return true; } @@ -473,12 +475,12 @@ void EveChildInstanceContainer::RegisterWithQuadRenderer( Tr2QuadRenderer& quadR void EveChildInstanceContainer::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const { - RunOnInstances( [&frustum, &quadRenderer]( IEveSpaceObjectChild* c ) { c->AddQuadsToQuadRenderer( frustum, quadRenderer ); } ); + RunOnInstances( [&frustum, &quadRenderer]( EveSpaceObjectChild* c ) { c->AddQuadsToQuadRenderer( frustum, quadRenderer ); } ); } void EveChildInstanceContainer::ChangeLOD( Tr2Lod lod ) { - RunOnInstances( [&lod]( IEveSpaceObjectChild* c ) { c->ChangeLOD( lod ); } ); + RunOnInstances( [&lod]( EveSpaceObjectChild* c ) { c->ChangeLOD( lod ); } ); } void EveChildInstanceContainer::SetOrigin( Origin origin ) @@ -488,7 +490,7 @@ void EveChildInstanceContainer::SetOrigin( Origin origin ) void EveChildInstanceContainer::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - RunOnInstances( [&name, &value]( IEveSpaceObjectChild* c ) { c->SetShaderOption( name, value ); } ); + RunOnInstances( [&name, &value]( EveSpaceObjectChild* c ) { c->SetShaderOption( name, value ); } ); } bool EveChildInstanceContainer::IsAlwaysOn() const @@ -509,18 +511,18 @@ void EveChildInstanceContainer::GetWorldVelocity( Vector3& velocity ) const velocity = m_worldVelocity; } -IEveSpaceObjectChildPtr EveChildInstanceContainer::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildInstanceContainer::GetEffectChildByName( const char* name ) const { // don't really know what to do here... return nullptr; } -void EveChildInstanceContainer::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildInstanceContainer::AddToEffectChildrenList( EveSpaceObjectChild* child ) { // do nothing for now } -void EveChildInstanceContainer::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildInstanceContainer::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { // do nothing for now } @@ -540,17 +542,17 @@ void EveChildInstanceContainer::SetControllerVariable( const char* name, float v { found->second = value; } - RunOnInstances( [&name, &value]( IEveSpaceObjectChild* c ) { c->SetControllerVariable( name, value ); } ); + RunOnInstances( [&name, &value]( EveSpaceObjectChild* c ) { c->SetControllerVariable( name, value ); } ); } void EveChildInstanceContainer::HandleControllerEvent( const char* name ) { - RunOnInstances( [name]( IEveSpaceObjectChild* c ) { c->HandleControllerEvent( name ); } ); + RunOnInstances( [name]( EveSpaceObjectChild* c ) { c->HandleControllerEvent( name ); } ); } void EveChildInstanceContainer::StartControllers() { - RunOnInstances( []( IEveSpaceObjectChild* c ) { c->StartControllers(); } ); + RunOnInstances( []( EveSpaceObjectChild* c ) { c->StartControllers(); } ); } void EveChildInstanceContainer::SetControllerVariableForInstance( const uint32_t index, const char* name, float value ) @@ -577,7 +579,7 @@ void EveChildInstanceContainer::HandleControllerEventForInstance( const uint32_t void EveChildInstanceContainer::PlayCurveSet( const std::string& name, const std::string& rangeName ) { - RunOnInstances( [&name, &rangeName]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&name, &rangeName]( EveSpaceObjectChild* c ) { ITr2CurveSetOwnerPtr cso = BlueCastPtr( c->GetRootObject() ); if( cso != nullptr ) { @@ -588,7 +590,7 @@ void EveChildInstanceContainer::PlayCurveSet( const std::string& name, const std void EveChildInstanceContainer::StopCurveSet( const std::string& name ) { - RunOnInstances( [&name]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&name]( EveSpaceObjectChild* c ) { ITr2CurveSetOwnerPtr cso = BlueCastPtr( c->GetRootObject() ); if( cso != nullptr ) @@ -600,7 +602,7 @@ void EveChildInstanceContainer::StopCurveSet( const std::string& name ) void EveChildInstanceContainer::UpdateCurveSet( const std::string& name, Be::Time time ) { - RunOnInstances( [&name, time]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&name, time]( EveSpaceObjectChild* c ) { ITr2CurveSetOwnerPtr cso = BlueCastPtr( c->GetRootObject() ); if( cso != nullptr ) { @@ -635,7 +637,7 @@ float EveChildInstanceContainer::GetRangeDuration( const std::string& name, cons void EveChildInstanceContainer::PlayAllCurveSets() { - RunOnInstances( []( IEveSpaceObjectChild* c ) { + RunOnInstances( []( EveSpaceObjectChild* c ) { EveChildContainerPtr cc = BlueCastPtr( c->GetRootObject() ); if( cc != nullptr ) { @@ -646,7 +648,7 @@ void EveChildInstanceContainer::PlayAllCurveSets() void EveChildInstanceContainer::StopAllCurveSets() { - RunOnInstances( []( IEveSpaceObjectChild* c ) { + RunOnInstances( []( EveSpaceObjectChild* c ) { EveChildContainerPtr cc = BlueCastPtr( c->GetRootObject() ); if( cc != nullptr ) { @@ -657,7 +659,7 @@ void EveChildInstanceContainer::StopAllCurveSets() void EveChildInstanceContainer::GetDebugOptions( Tr2DebugRendererOptions& options ) { - RunOnInstances( [&options]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&options]( EveSpaceObjectChild* c ) { if( auto dr = dynamic_cast( c ) ) { dr->GetDebugOptions( options ); @@ -667,10 +669,42 @@ void EveChildInstanceContainer::GetDebugOptions( Tr2DebugRendererOptions& option void EveChildInstanceContainer::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - RunOnInstances( [&renderer]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&renderer]( EveSpaceObjectChild* c ) { if( auto dr = dynamic_cast( c ) ) { dr->RenderDebugInfo( renderer ); } } ); } + +void EveChildInstanceContainer::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + for( auto& child : m_instances ) + { + child->SetOwner( owner ); + } + if( m_source ) + { + m_source->SetOwner( owner ); + } + } +} + +void EveChildInstanceContainer::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + for( auto& child : m_instances ) + { + child->SetPartTag( tag ); + } + if( m_source ) + { + m_source->SetPartTag( tag ); + } + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h index 42fce1a86..9da27de71 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -28,11 +28,11 @@ BLUE_DECLARE( EveChildInheritProperties ); // -------------------------------------------------------------------------------------- // Description: -// A child container that copies a source IEveSpaceObjectChild across locatorsets +// A child container that copies a source EveSpaceObjectChild across locatorsets // and or transforms // -------------------------------------------------------------------------------------- BLUE_CLASS( EveChildInstanceContainer ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2CurveSetOwner, public INotify, public IEveEffectChildrenOwner, @@ -53,9 +53,7 @@ BLUE_CLASS( EveChildInstanceContainer ) : float GetOwnerMaxSpeed() const; ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -73,12 +71,14 @@ BLUE_CLASS( EveChildInstanceContainer ) : void GetWorldVelocity( Vector3 & velocity ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); void AddTransformModifier( IEveChildTransformModifier * modifier ) override; + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -125,19 +125,18 @@ BLUE_CLASS( EveChildInstanceContainer ) : void PopFront(); void DisableEditMode( bool disable ); - void SetSourceEffect( IEveSpaceObjectChildPtr sourceEffect ); + void SetSourceEffect( EveSpaceObjectChildPtr sourceEffect ); void AddInstanceTransform( const Vector3& scale, const Quaternion& rotation, const Vector3& translation, int32_t boneIndex = -1 ); void UpdateInstance( const uint32_t index, const Vector3& scale, const Quaternion& rotation, const Vector3& translation ); - IEveSpaceObjectChildPtr GetSource(); - void SetSource( IEveSpaceObjectChild * source ); + EveSpaceObjectChildPtr GetSource(); + void SetSource( EveSpaceObjectChild * source ); protected: void CreateInstances( IEveSpaceObject2 * parent ); - void RunOnInstances( std::function func ) const; + void RunOnInstances( std::function func ) const; protected: - BlueSharedString m_name; Vector3 m_worldVelocity; float m_ownerMaxSpeed; bool m_display; @@ -152,8 +151,8 @@ BLUE_CLASS( EveChildInstanceContainer ) : Origin m_origin; std::vector> m_controllerVariables; - IEveSpaceObjectChildPtr m_source; - PIEveSpaceObjectChildVector m_instances; + EveSpaceObjectChildPtr m_source; + PEveSpaceObjectChildVector m_instances; bool m_reset; BlueSharedString m_locatorSetName; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp index 1dd3207d2..4dc4f8e1e 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp @@ -6,61 +6,66 @@ BLUE_DEFINE( EveChildInstanceContainer ); BLUE_DECLARE_INTERFACE( ITr2DebugRenderable ); -const Be::ClassInfo* EveChildInstanceContainer::ExposeToBlue() { +const Be::ClassInfo* EveChildInstanceContainer::ExposeToBlue() +{ EXPOSURE_BEGIN( EveChildInstanceContainer, "" ) MAP_INTERFACE( EveChildInstanceContainer ) - MAP_INTERFACE( IEveSpaceObjectChild ) - MAP_INTERFACE( ITr2CurveSetOwner ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IEveEffectChildrenOwner ) - MAP_INTERFACE( IShaderConfigurer ) - MAP_INTERFACE( ITr2ControllerOwner ) - MAP_INTERFACE( IListNotify ) - MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) + MAP_INTERFACE( IEveSpaceObjectChild ) + MAP_INTERFACE( ITr2CurveSetOwner ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IEveEffectChildrenOwner ) + MAP_INTERFACE( IShaderConfigurer ) + MAP_INTERFACE( ITr2ControllerOwner ) + MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "alwaysOn", m_isAlwaysOn, "If false this will be hidden if a spaceobjects activation strength < 0.5. If True then it is always on.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ); + MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "alwaysOn", m_isAlwaysOn, "If false this will be hidden if a spaceobjects activation strength < 0.5. If True then it is always on.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "inheritProperties", m_inheritProperties, "Properties inherited from the parent ship when loaded through SOF", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "origin", m_origin, "Where did this effect originate from", Be::READ ) + MAP_ATTRIBUTE( "inheritProperties", m_inheritProperties, "Properties inherited from the parent ship when loaded through SOF", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "origin", m_origin, "Where did this effect originate from", Be::READ ) - MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) + MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) - MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "useSRT", m_useSRT, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "useStaticRotation", m_useStaticRotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "useSRT", m_useSRT, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "useStaticRotation", m_useStaticRotation, "", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "SetControllerVariable", - SetControllerVariable, - "Set variable for all applicable controllers\n" - ":param name: variable name\n" - ":param value: new variable value\n" ) + MAP_METHOD_AND_WRAP( + "SetControllerVariable", + SetControllerVariable, + "Set variable for all applicable controllers\n" + ":param name: variable name\n" + ":param value: new variable value\n" ) - MAP_METHOD_AND_WRAP( - "HandleControllerEvent", - HandleControllerEvent, - "Pass an event to controllers\n" - ":param name: event name" ) + MAP_METHOD_AND_WRAP( + "HandleControllerEvent", + HandleControllerEvent, + "Pass an event to controllers\n" + ":param name: event name" ) - MAP_METHOD_AND_WRAP( - "StartControllers", - StartControllers, - "Start all controllers" ) + MAP_METHOD_AND_WRAP( + "StartControllers", + StartControllers, + "Start all controllers" ) - MAP_ATTRIBUTE( "source", m_source, "The sourceObject to instance", Be::PERSISTONLY ) - MAP_PROPERTY( "source", GetSource, SetSource, "The sourceObject to instance" ) + MAP_ATTRIBUTE( "source", m_source, "The sourceObject to instance", Be::PERSISTONLY ) + MAP_PROPERTY( "source", GetSource, SetSource, "The sourceObject to instance" ) - MAP_ATTRIBUTE( "locatorSet", m_locatorSetName, "The name of the locatorset to distribute across", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "reset", m_reset, "Redistributes the source", Be::READWRITE ) - MAP_ATTRIBUTE( "instances", m_instances, "The generated instances\n:jessica-skip-validation:", Be::READ ) - MAP_ATTRIBUTE( "transforms", m_transforms, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, "", Be::READ | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "locatorSet", m_locatorSetName, "The name of the locatorset to distribute across", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "reset", m_reset, "Redistributes the source", Be::READWRITE ) + MAP_ATTRIBUTE( "instances", m_instances, "The generated instances\n:jessica-skip-validation:", Be::READ ) + MAP_ATTRIBUTE( "transforms", m_transforms, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, "", Be::READ | Be::PERSIST | Be::NOTIFY ) - EXPOSURE_END() + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) + EXPOSURE_END() }; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h index 0a9c2929d..b08878313 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" #include "TriRenderBatch.h" diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp index cb209e33b..4a97f370d 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp @@ -21,6 +21,7 @@ const Be::ClassInfo* EveChildInstanceMeshRenderer::ExposeToBlue() MAP_INTERFACE( EveChildInstanceMeshRenderer ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( EveChildMesh ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) @@ -42,5 +43,8 @@ const Be::ClassInfo* EveChildInstanceMeshRenderer::ExposeToBlue() MAP_METHOD_AND_WRAP( "RefreshStaticGeometry", RefreshStaticGeometry, "if static geo parameters were changed during authoring: refresh here\n:jessica-placement: TOOLBAR" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp index 4bc9ddbef..cc6915557 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp @@ -170,16 +170,6 @@ void EveChildInstancedMeshes::PushRtGeometry( Tr2RaytracingManager& rtManager ) } -const char* EveChildInstancedMeshes::GetName() const -{ - return m_name.c_str(); -} - -void EveChildInstancedMeshes::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildInstancedMeshes::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { m_lastCameraFrustum = updateContext.GetFrustum(); @@ -336,10 +326,6 @@ void EveChildInstancedMeshes::Setup( const Vector3* scale, const Quaternion* rot { } -void EveChildInstancedMeshes::ChangeLOD( Tr2Lod lod ) -{ -} - void EveChildInstancedMeshes::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { for( auto& mesh : m_meshes ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h index 5a25e441d..6248b4aa8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "../../EveInstancedMeshManager.h" BLUE_DECLARE( TriGeometryRes ); @@ -10,7 +10,7 @@ BLUE_DECLARE( Tr2Effect ); BLUE_CLASS( EveChildInstancedMeshes ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveEntity, public IBlueAsyncResNotifyTarget, public IEveShadowCaster, @@ -25,9 +25,7 @@ BLUE_CLASS( EveChildInstancedMeshes ) : ~EveChildInstancedMeshes(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void GetRenderables( std::vector & renderables ) override; bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; @@ -35,7 +33,6 @@ BLUE_CLASS( EveChildInstancedMeshes ) : void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; - void ChangeLOD( Tr2Lod lod ) override; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; @@ -137,7 +134,6 @@ BLUE_CLASS( EveChildInstancedMeshes ) : void ReleaseResources( TriStorage s ) override; bool OnPrepareResources() override; - BlueSharedString m_name; Matrix m_worldTransform = IdentityMatrix(); EveSpacePerObjectData m_perObjectData; EveInstancedMeshManager::PerObjectDataHandle m_perObjectDataHandle; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp index 59c4d83b7..0cd88e865 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp @@ -11,6 +11,7 @@ const Be::ClassInfo* EveChildInstancedMeshes::ExposeToBlue() { EXPOSURE_BEGIN( EveChildInstancedMeshes, "" ) MAP_INTERFACE( EveChildInstancedMeshes ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( IEveShadowCaster ) @@ -59,5 +60,8 @@ const Be::ClassInfo* EveChildInstancedMeshes::ExposeToBlue() ":param display: True to render the mesh, False to hide it\n" ":rtype: None" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp index 23bfe5459..3283e2fc4 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp @@ -90,16 +90,6 @@ void EveChildLightingOverride::RebuildBoundingSphere() } } -const char* EveChildLightingOverride::GetName() const -{ - return m_name.c_str(); -} - -void EveChildLightingOverride::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - bool EveChildLightingOverride::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { sphere.GetXYZ() = m_boundingSphere.center; @@ -108,10 +98,6 @@ bool EveChildLightingOverride::GetBoundingSphere( Vector4& sphere, BoundingSpher return true; } -void EveChildLightingOverride::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) -{ -} - void EveChildLightingOverride::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { Matrix localToWorldTransform = params.localToWorldTransform; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h index c786b7f34..a6a4980ac 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "Eve/EveEntity.h" #include "PostProcess/Tr2PostProcessEnums.h" @@ -37,7 +37,7 @@ REGISTER_COMPONENT_TYPE( "EveLightingOverride", IEveLightingOverride ); BLUE_CLASS( EveChildLightingOverride ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public IEveLightingOverride, public IInitialize, public ITr2DebugRenderable, @@ -52,19 +52,12 @@ BLUE_CLASS( EveChildLightingOverride ) : OverrideInfo GetOverrides() const override; ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override {}; - void GetRenderables( std::vector & renderables ) override{}; + // EveSpaceObjectChild bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query ) const override; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; - void ChangeLOD( Tr2Lod lod ) override {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; bool IsAlwaysOn() const override; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override {}; void RegisterComponents() override; void UnRegisterComponents() override; @@ -82,8 +75,6 @@ BLUE_CLASS( EveChildLightingOverride ) : private: void RebuildBoundingSphere(); - BlueSharedString m_name; - OverrideInfo m_overrides; PIEveVolumeVector m_volumes; float m_intensity; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride_Blue.cpp index 737d043e7..6c6dbe5f8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride_Blue.cpp @@ -13,6 +13,7 @@ const Be::ClassInfo* EveChildLightingOverride::ExposeToBlue() { EXPOSURE_BEGIN( EveChildLightingOverride, "" ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IEveLightingOverride ) MAP_INTERFACE( IInitialize ) @@ -56,5 +57,8 @@ const Be::ClassInfo* EveChildLightingOverride::ExposeToBlue() m_volumes, "The volumes that affect the light overrides", Be::READ | Be::PERSIST ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildLineSet.cpp b/trinity/Eve/SpaceObject/Children/EveChildLineSet.cpp index 843db76dd..7ccd6c3ed 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLineSet.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLineSet.cpp @@ -186,16 +186,6 @@ void EveChildLineSet::UpdateBoundingSphere( bool reCalculateChildren ) m_boundingSphere = sphere; } -const char* EveChildLineSet::GetName() const -{ - return m_name.c_str(); -} - -void EveChildLineSet::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildLineSet::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { if( !m_display ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildLineSet.h b/trinity/Eve/SpaceObject/Children/EveChildLineSet.h index 56146263b..61e1d2afe 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLineSet.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLineSet.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" #include "TriRenderBatch.h" @@ -17,8 +17,8 @@ class ChildLineSetInstancingBatch; BLUE_CLASS( EveChildLineSet ) : + public EveSpaceObjectChild, public IInitialize, - public IEveSpaceObjectChild, public Tr2DeviceResource, public ITr2Renderable, public EveChildTransform, @@ -40,9 +40,7 @@ BLUE_CLASS( EveChildLineSet ) : bool OnModified( Be::Var * value ) override; ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; + // EveSpaceObjectChild void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; bool IsAlwaysOn() const override; @@ -51,9 +49,7 @@ BLUE_CLASS( EveChildLineSet ) : bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override {}; void GetRenderables( std::vector & renderables ) override; - void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override{}; ///////////////////////////////////////////////////////////////////////////////////// // Tr2DeviceResource @@ -105,7 +101,6 @@ BLUE_CLASS( EveChildLineSet ) : void GenerateManagedPoints(); void UpdateBoundingSphere( bool reCalculateChildren = true ); - BlueSharedString m_name; Vector3 m_worldVelocity; float m_ownerMaxSpeed; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp index 63fd188f8..b6eb83374 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp @@ -18,6 +18,7 @@ const Be::ClassInfo* EveChildLineSet::ExposeToBlue() { EXPOSURE_BEGIN( EveChildLineSet, "" ) MAP_INTERFACE( EveChildLineSet ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -48,5 +49,8 @@ const Be::ClassInfo* EveChildLineSet::ExposeToBlue() MAP_ATTRIBUTE( "lineSet", m_lineSet, ":jessica-hidden: True", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "mesh", m_mesh, "the rendered mesh", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildLink.h b/trinity/Eve/SpaceObject/Children/EveChildLink.h index bcfeb78a3..00509a37c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLink.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLink.h @@ -22,7 +22,7 @@ BLUE_CLASS( EveChildLink ) : ~EveChildLink(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + // EveSpaceObjectChild void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp b/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp index a9efa903e..2593a7ac4 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp @@ -204,16 +204,6 @@ bool EveChildMesh::OnModified( Be::Var* val ) return true; } -const char* EveChildMesh::GetName() const -{ - return m_name.c_str(); -} - -void EveChildMesh::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildMesh::InitializeAnimation() { if( m_animationUpdater && m_animationUpdater->GetResPath().empty() ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh.h b/trinity/Eve/SpaceObject/Children/EveChildMesh.h index 54d5e1b52..23fa6116a 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh.h +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh.h @@ -4,7 +4,7 @@ #ifndef EveChildMesh_H #define EveChildMesh_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "Eve/SpaceObject/EveSpaceObject2.h" #include "Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h" @@ -54,7 +54,7 @@ enum class MorphTargetAnimationFilter : uint8_t }; BLUE_CLASS( EveChildMesh ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public IInitialize, @@ -78,9 +78,7 @@ BLUE_CLASS( EveChildMesh ) : ~EveChildMesh(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -205,9 +203,6 @@ BLUE_CLASS( EveChildMesh ) : std::pair GetMorphTargets( MorphTargetAnimationFilter filter ); void UpdateMorphAnimationBuffer(); - // general data - BlueSharedString m_name; - // the mesh Tr2MeshBasePtr m_mesh; Tr2InstancedMeshPtr m_instancedMesh; // Cached downcast of m_mesh diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp index de99e6f6a..69816dd72 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp @@ -3,6 +3,7 @@ #include "StdAfx.h" #include "EveChildMesh.h" +BLUE_DEFINE_INTERFACE( IMultiPartObjectElement ); BLUE_DEFINE( EveChildMesh ); const Be::ClassInfo* EveChildMesh::ExposeToBlue() @@ -11,6 +12,7 @@ const Be::ClassInfo* EveChildMesh::ExposeToBlue() MAP_INTERFACE( EveChildMesh ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( IEveSpaceObjectDecalOwner ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) @@ -88,5 +90,8 @@ const Be::ClassInfo* EveChildMesh::ExposeToBlue() "GetMorphTargetWeight( name )\n\n" "Returns the weight of the morph target. Returns 0 if no morph target with that name was found.\n" ":param name: morph target name\n" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp index 6d01b4d4e..828333e46 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp @@ -68,18 +68,6 @@ EveChildParticleSphere::EveChildParticleSphere( IRoot* lockobj ) : { } -// -------------------------------------------------------------------------------- -const char* EveChildParticleSphere::GetName() const -{ - return m_name.c_str(); -} - -// -------------------------------------------------------------------------------- -void EveChildParticleSphere::SetName( const char* name ) -{ - m_name = name; -} - // ----------------------------------------------------------------------------- void EveChildParticleSphere::GetRenderables( std::vector& renderables ) { diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h index 975b379a2..a771f2b60 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h @@ -2,7 +2,7 @@ #pragma once -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "ITr2Renderable.h" #include "Particle/Tr2ParticleElementDeclaration.h" @@ -13,7 +13,7 @@ BLUE_DECLARE( Tr2ParticleSystem ); class EveUpdateContext; BLUE_CLASS( EveChildParticleSphere ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2Renderable { public: @@ -23,9 +23,7 @@ BLUE_CLASS( EveChildParticleSphere ) : ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void GetRenderables( std::vector & renderables ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -33,7 +31,6 @@ BLUE_CLASS( EveChildParticleSphere ) : void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); - void ChangeLOD( Tr2Lod lod ) {}; ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable @@ -66,8 +63,6 @@ BLUE_CLASS( EveChildParticleSphere ) : Matrix m_worldTransform; Vector4 m_boundingSphere; - std::string m_name; - enum { BIND_PENDING, diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp index eb533845c..d28a976bc 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveChildParticleSphere::ExposeToBlue() { EXPOSURE_BEGIN( EveChildParticleSphere, "" ) MAP_INTERFACE( EveChildParticleSphere ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) @@ -35,5 +36,8 @@ const Be::ClassInfo* EveChildParticleSphere::ExposeToBlue() MAP_ATTRIBUTE( "useSpaceObjectData", m_useSpaceObjectData, "", Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "Refresh", Refresh, "Re-binds particle system and re-adds particles" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp index 1fe57bbf2..500721824 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp @@ -77,16 +77,6 @@ bool EveChildParticleSystem::OnModified( Be::Var* value ) return true; } -const char* EveChildParticleSystem::GetName() const -{ - return m_name.c_str(); -} - -void EveChildParticleSystem::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - // -------------------------------------------------------------------------------- // Description: // Setup function to set data from outside, in this case just pass it to diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h index d3197edac..79012e5ff 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h @@ -4,7 +4,7 @@ #ifndef EveChildParticleSystem_H #define EveChildParticleSystem_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "ITr2Renderable.h" @@ -25,7 +25,7 @@ BLUE_DECLARE_INTERFACE( ITr2GenericEmitter ); BLUE_DECLARE_IVECTOR( ITr2GenericEmitter ); BLUE_CLASS( EveChildParticleSystem ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public IInitialize, @@ -40,9 +40,7 @@ BLUE_CLASS( EveChildParticleSystem ) : ~EveChildParticleSystem(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -85,8 +83,6 @@ BLUE_CLASS( EveChildParticleSystem ) : PITr2GenericEmitterVector m_particleEmitters; private: - BlueSharedString m_name; - Vector4 m_boundingSphere; Vector4 m_lodSphere; diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp index 66bdaa945..dadda5153 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildParticleSystem::ExposeToBlue() EXPOSURE_BEGIN( EveChildParticleSystem, "" ) MAP_INTERFACE( EveChildParticleSystem ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) @@ -70,5 +71,8 @@ const Be::ClassInfo* EveChildParticleSystem::ExposeToBlue() MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "Screen size for last frame\n:jessica-group: LOD", Be::READ ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform if useSRT is set." ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp b/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp index 90ab0a190..b0db45722 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp @@ -25,10 +25,12 @@ EveChildPlug::~EveChildPlug() { controller->Unlink( UnlinkReason::DELETING ); } + UnregisterChildren( m_objects ); } bool EveChildPlug::Initialize() { + RegisterChildren( m_objects ); for( auto& controller : m_controllers ) { if( !controller->IsLinked() ) @@ -73,6 +75,7 @@ void EveChildPlug::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* } else if( list == &m_objects && ( event & BELIST_LOADING ) == 0 ) { + HandleChildrenListModified( event, value, m_objects ); if( IsInRegistry() ) { switch( event & BELIST_EVENTMASK ) @@ -153,16 +156,6 @@ void EveChildPlug::UnRegisterComponents() } } -const char* EveChildPlug::GetName() const -{ - return m_name.c_str(); -} - -void EveChildPlug::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildPlug::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { if( !m_display ) @@ -195,7 +188,7 @@ bool EveChildPlug::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if( ( *it )->GetBoundingSphere( bSphere ) ) + if( ( *it )->GetBoundingSphere( bSphere, EVE_BOUNDS_NORMAL ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -271,7 +264,7 @@ void EveChildPlug::SetShaderOption( const BlueSharedString& name, const BlueShar { for( auto it = m_objects.begin(); it != m_objects.end(); ++it ) { - IEveSpaceObjectChild* child = *it; + EveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } } @@ -426,7 +419,7 @@ void EveChildPlug::StartControllers() } } -IEveSpaceObjectChildPtr EveChildPlug::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildPlug::GetEffectChildByName( const char* name ) const { for( auto it = begin( m_objects ); it != end( m_objects ); ++it ) { @@ -439,7 +432,7 @@ IEveSpaceObjectChildPtr EveChildPlug::GetEffectChildByName( const char* name ) c return nullptr; } -void EveChildPlug::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildPlug::AddToEffectChildrenList( EveSpaceObjectChild* child ) { if( IsInRegistry() ) { @@ -451,7 +444,7 @@ void EveChildPlug::AddToEffectChildrenList( IEveSpaceObjectChild* child ) m_objects.Append( child->GetRootObject() ); } -void EveChildPlug::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildPlug::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { auto index = m_objects.FindKey( child ); if( index >= 0 ) @@ -505,3 +498,27 @@ ITr2AudEmitterPtr EveChildPlug::FindSoundEmitter( const char* name ) } return nullptr; } + +void EveChildPlug::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + for( auto& child : m_objects ) + { + child->SetOwner( owner ); + } + } +} + +void EveChildPlug::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + for( auto& child : m_objects ) + { + child->SetPartTag( tag ); + } + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug.h b/trinity/Eve/SpaceObject/Children/EveChildPlug.h index efdabcfb8..37b228850 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug.h @@ -5,7 +5,7 @@ #define EveChildPlug_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -19,7 +19,7 @@ BLUE_DECLARE_VECTOR( Tr2ExternalParameter ); BLUE_CLASS( EveChildPlug ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2CurveSetOwner, public IInitialize, @@ -51,18 +51,15 @@ BLUE_CLASS( EveChildPlug ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; void UnRegisterComponents() override; - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -77,6 +74,9 @@ BLUE_CLASS( EveChildPlug ) : void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; + void PlayAllCurveSets(); void StopAllCurveSets(); void PlayCurveSet( const std::string& name, const std::string& rangeName ); @@ -102,9 +102,7 @@ BLUE_CLASS( EveChildPlug ) : ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; protected: - PIEveSpaceObjectChildVector m_objects; - - BlueSharedString m_name; + PEveSpaceObjectChildVector m_objects; PITr2ControllerVector m_controllers; std::vector> m_controllerVariables; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp index 97d8b9cd5..1ce9a4105 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildPlug::ExposeToBlue() { EXPOSURE_BEGIN( EveChildPlug, "\n:jessica-icon: plug\n:jessica-icon-color: (123, 28, 212)\n:jessica-help-url: https://wiki.ccpgames.com/pages/viewpage.action?spaceKey=TTL&title=Plugs+and+Sockets \n" ) MAP_INTERFACE( EveChildPlug ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -44,5 +45,8 @@ const Be::ClassInfo* EveChildPlug::ExposeToBlue() StartControllers, "Start all controllers" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp index d82375bf8..af7e266ce 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp @@ -70,20 +70,7 @@ void EveChildPostProcessVolume::UnRegisterComponents() } ///////////////////////////////////////////////////////////////////////////////////// -// IEveSpaceObjectChild -const char* EveChildPostProcessVolume::GetName() const -{ - return m_name.c_str(); -} - -void EveChildPostProcessVolume::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - -void EveChildPostProcessVolume::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) -{ -} +// EveSpaceObjectChild bool EveChildPostProcessVolume::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { @@ -93,10 +80,6 @@ bool EveChildPostProcessVolume::GetBoundingSphere( Vector4& sphere, BoundingSphe return true; } -void EveChildPostProcessVolume::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) -{ -} - void EveChildPostProcessVolume::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { CCP_STATS_ZONE( __FUNCTION__ ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h index 10d33b44a..8e45a3058 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h @@ -3,7 +3,7 @@ #pragma once #include "StdAfx.h" -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "ITr2Renderable.h" #include "Tr2DebugRenderer.h" @@ -17,7 +17,7 @@ BLUE_DECLARE_IVECTOR( IEveVolume ); BLUE_CLASS( EveChildPostProcessVolume ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public IInitialize, public ITr2DebugRenderable, @@ -33,19 +33,12 @@ BLUE_CLASS( EveChildPostProcessVolume ) : void RebuildBoundingSphere(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector & renderables ){}; + // EveSpaceObjectChild bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ) {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; bool IsAlwaysOn() const; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) {}; virtual void RegisterComponents(); virtual void UnRegisterComponents(); @@ -66,7 +59,6 @@ BLUE_CLASS( EveChildPostProcessVolume ) : private: void UpdateTransformFromParent( const EveChildUpdateParams& params ); - BlueSharedString m_name; PIEveVolumeVector m_volumes; PIEveVolumeVector m_exclusionVolumes; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp index 32907e00a..d0ffb1142 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp @@ -14,6 +14,7 @@ const Be::ClassInfo* EveChildPostProcessVolume::ExposeToBlue() EXPOSURE_BEGIN( EveChildPostProcessVolume, "" ) MAP_INTERFACE( ITr2PostProcessOwner ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) @@ -24,5 +25,8 @@ const Be::ClassInfo* EveChildPostProcessVolume::ExposeToBlue() MAP_ATTRIBUTE( "exclusionVolumes", m_exclusionVolumes, "", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "postProcessAttributes", m_postProcessAttributes, "", Be::READWRITE | Be::PERSIST ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp b/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp index a4a8eea7e..d7f8ea48d 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp @@ -64,16 +64,6 @@ bool EveChildQuad::Initialize() return true; } -const char* EveChildQuad::GetName() const -{ - return m_name.c_str(); -} - -void EveChildQuad::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - // -------------------------------------------------------------------------------- // Description: // Setup function to set data from outside, in this case just pass it to @@ -100,10 +90,6 @@ void EveChildQuad::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRen } } -void EveChildQuad::GetRenderables( std::vector& renderables ) -{ -} - bool EveChildQuad::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { sphere = Vector4( 0.f, 0.f, 0.f, std::sqrt( 2.f ) ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad.h b/trinity/Eve/SpaceObject/Children/EveChildQuad.h index 926bf64e1..2c072a079 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad.h +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad.h @@ -4,7 +4,7 @@ #ifndef EveChildQuad_H #define EveChildQuad_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "ITr2Renderable.h" @@ -12,7 +12,7 @@ BLUE_DECLARE( Tr2Effect ); BLUE_CLASS( EveChildQuad ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public IInitialize @@ -26,18 +26,14 @@ BLUE_CLASS( EveChildQuad ) : static Tr2VertexDefinition& GetQuadDefinition(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ) {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); ///////////////////////////////////////////////////////////////////////////////////// @@ -66,7 +62,6 @@ BLUE_CLASS( EveChildQuad ) : Float_16 m_brightness[2]; }; - BlueSharedString m_name; Tr2EffectPtr m_effect; unsigned m_effectKey; Quad m_quad; diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp index 1e9f446a0..6bfc4db89 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveChildQuad::ExposeToBlue() { EXPOSURE_BEGIN( EveChildQuad, "" ) MAP_INTERFACE( EveChildQuad ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) @@ -34,5 +35,8 @@ const Be::ClassInfo* EveChildQuad::ExposeToBlue() Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "Screen size for last frame\n:jessica-group: LOD", Be::READ ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform if useSRT is set." ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef.cpp b/trinity/Eve/SpaceObject/Children/EveChildRef.cpp index 23a00cdd8..299fdb622 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildRef.cpp @@ -16,6 +16,7 @@ EveChildRef::EveChildRef( IRoot* lockobj ) : EveChildRef::~EveChildRef() { + UnregisterChild( m_child ); } const char* EveChildRef::GetResPath() const @@ -74,16 +75,6 @@ bool EveChildRef::OnModified( Be::Var* value ) return true; } -const char* EveChildRef::GetName() const -{ - return m_name.c_str(); -} - -void EveChildRef::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildRef::RegisterComponents() { if( IsInRegistry() && m_child != nullptr && m_display ) @@ -106,7 +97,7 @@ void EveChildRef::UnRegisterComponents() } } -IEveSpaceObjectChildPtr EveChildRef::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildRef::GetEffectChildByName( const char* name ) const { if( auto ref = dynamic_cast( m_child.p ) ) { @@ -115,7 +106,7 @@ IEveSpaceObjectChildPtr EveChildRef::GetEffectChildByName( const char* name ) co return nullptr; } -void EveChildRef::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildRef::AddToEffectChildrenList( EveSpaceObjectChild* child ) { if( auto ref = dynamic_cast( m_child.p ) ) { @@ -123,7 +114,7 @@ void EveChildRef::AddToEffectChildrenList( IEveSpaceObjectChild* child ) } } -void EveChildRef::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildRef::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { if( auto ref = dynamic_cast( m_child.p ) ) { @@ -163,7 +154,7 @@ bool EveChildRef::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query { bool success = false; Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); - if( m_child && m_child->GetBoundingSphere( bSphere ) ) + if( m_child && m_child->GetBoundingSphere( bSphere, EVE_BOUNDS_NORMAL ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -352,14 +343,16 @@ bool EveChildRef::LoadChild() { // unregister the old child UnRegisterComponents(); + UnregisterChild( m_child ); CCP_LOG( "Loading child red file %s", m_resPath.c_str() ); - m_child = BeResMan->LoadObject( m_resPath.c_str() ); + m_child = BeResMan->LoadObject( m_resPath.c_str() ); if( !m_child ) { CCP_LOGERR( "Red file %s is invalid or not an Eve Child type.", m_resPath.c_str() ); return false; } + RegisterChild( m_child ); RegisterComponents(); @@ -373,4 +366,28 @@ ITr2AudEmitterPtr EveChildRef::FindSoundEmitter( const char* name ) return owner->FindSoundEmitter( name ); } return nullptr; -} \ No newline at end of file +} + +void EveChildRef::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + if( m_child ) + { + m_child->SetOwner( owner ); + } + } +} + +void EveChildRef::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + if( m_child ) + { + m_child->SetPartTag( tag ); + } + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef.h b/trinity/Eve/SpaceObject/Children/EveChildRef.h index 1ef6ca39d..20b241190 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef.h +++ b/trinity/Eve/SpaceObject/Children/EveChildRef.h @@ -5,7 +5,7 @@ #define EveChildRef_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -16,7 +16,7 @@ BLUE_CLASS( EveChildRef ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2CurveSetOwner, public IInitialize, @@ -52,16 +52,11 @@ BLUE_CLASS( EveChildRef ) : void RegisterComponents() override; void UnRegisterComponents() override; - ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); - ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); void SetProceduralContainerVariable( const char* name, float value ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); @@ -79,6 +74,9 @@ BLUE_CLASS( EveChildRef ) : void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; + void PlayCurveSet( const std::string& name, const std::string& rangeName ); void StopCurveSet( const std::string& name ); void UpdateCurveSet( const std::string& name, Be::Time time ); @@ -104,8 +102,7 @@ BLUE_CLASS( EveChildRef ) : protected: bool LoadChild(); - IEveSpaceObjectChildPtr m_child; - BlueSharedString m_name; + EveSpaceObjectChildPtr m_child; std::string m_resPath; bool m_loadChildAutomatically; diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp index ed5256332..9a6999058 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildRef::ExposeToBlue() { EXPOSURE_BEGIN( EveChildRef, "\n:jessica-icon: alicorn\n:jessica-icon-color: (123, 28, 212)\n:jessica-help-url: https://wiki.ccpgames.com/pages/viewpage.action?spaceKey=TTL&title=Plugs+and+Sockets \n" ) MAP_INTERFACE( EveChildRef ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -62,5 +63,8 @@ const Be::ClassInfo* EveChildRef::ExposeToBlue() Reload, 1, "Reload the effect child.\n" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp b/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp index 8c89fb919..e35db336c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp @@ -15,7 +15,6 @@ EveChildSocket::EveChildSocket( IRoot* lockobj ) : PARENTLOCK( m_parameters ), m_plug(), - m_name(), m_plugResPath(), m_display( true ) { @@ -23,6 +22,7 @@ EveChildSocket::EveChildSocket( IRoot* lockobj ) : EveChildSocket::~EveChildSocket() { + UnregisterChild( m_plug ); } const char* EveChildSocket::GetPlugResPath() const @@ -236,17 +236,7 @@ void EveChildSocket::UnRegisterComponents() } -const char* EveChildSocket::GetName() const -{ - return m_name.c_str(); -} - -void EveChildSocket::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - -IEveSpaceObjectChildPtr EveChildSocket::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildSocket::GetEffectChildByName( const char* name ) const { if( m_plug ) { @@ -255,11 +245,11 @@ IEveSpaceObjectChildPtr EveChildSocket::GetEffectChildByName( const char* name ) return nullptr; } -void EveChildSocket::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildSocket::AddToEffectChildrenList( EveSpaceObjectChild* child ) { } -void EveChildSocket::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildSocket::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { } @@ -490,6 +480,7 @@ bool EveChildSocket::LoadChild() { // unregister the current child UnRegisterComponents(); + UnregisterChild( m_plug ); CCP_LOG( "Loading child red file %s", m_plugResPath.c_str() ); m_plug = BeResMan->LoadObject( m_plugResPath.c_str() ); @@ -498,6 +489,7 @@ bool EveChildSocket::LoadChild() CCP_LOGERR( "Red file %s is invalid or not an Eve Child type.", m_plugResPath.c_str() ); return false; } + RegisterChild( m_plug ); RegisterComponents(); @@ -512,3 +504,27 @@ ITr2AudEmitterPtr EveChildSocket::FindSoundEmitter( const char* name ) } return nullptr; } + +void EveChildSocket::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + if( m_plug ) + { + m_plug->SetOwner( owner ); + } + } +} + +void EveChildSocket::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + if( m_plug ) + { + m_plug->SetPartTag( tag ); + } + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket.h b/trinity/Eve/SpaceObject/Children/EveChildSocket.h index 0827ae425..225de887f 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket.h +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket.h @@ -4,7 +4,7 @@ #ifndef EveChildSocket_H #define EveChildSocket_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -19,7 +19,7 @@ BLUE_DECLARE_IVECTOR( IEveSocketParameter ); BLUE_CLASS( EveChildSocket ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2CurveSetOwner, public IInitialize, @@ -52,16 +52,11 @@ BLUE_CLASS( EveChildSocket ) : // INotify virtual bool OnModified( Be::Var * value ); - ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); - ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -82,6 +77,9 @@ BLUE_CLASS( EveChildSocket ) : void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; + void PlayAllCurveSets(); void StopAllCurveSets(); void PlayCurveSet( const std::string& name, const std::string& rangeName ); @@ -109,7 +107,6 @@ BLUE_CLASS( EveChildSocket ) : EveChildPlugPtr m_plug; - BlueSharedString m_name; std::string m_plugResPath; bool m_display; diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp index 109731c0e..2aaf872c1 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildSocket::ExposeToBlue() { EXPOSURE_BEGIN( EveChildSocket, "\n:jessica-icon:blender-phone\n:jessica-icon-color: (123, 28, 212)\n:jessica-help-url: https://wiki.ccpgames.com/pages/viewpage.action?spaceKey=TTL&title=Plugs+and+Sockets \n" ) MAP_INTERFACE( EveChildSocket ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -69,5 +70,8 @@ const Be::ClassInfo* EveChildSocket::ExposeToBlue() ":jessica-placement:\n" ":jessica-icon: far-sync\n" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h b/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h index 3b9f501a3..0317a23b5 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h +++ b/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h @@ -37,7 +37,7 @@ BLUE_CLASS( EveChildSpherePin ) : ~EveChildSpherePin(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + // EveSpaceObjectChild void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); diff --git a/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h b/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h index b7a510709..d5aa1b5f9 100644 --- a/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h +++ b/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h @@ -3,13 +3,13 @@ #pragma once -BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); BLUE_INTERFACE( IEveEffectChildrenOwner ) : public IRoot { - virtual IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const = 0; - virtual void AddToEffectChildrenList( IEveSpaceObjectChild * child ) = 0; - virtual void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ) = 0; + virtual EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const = 0; + virtual void AddToEffectChildrenList( EveSpaceObjectChild * child ) = 0; + virtual void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ) = 0; }; \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h b/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h index 8a8cd6c73..9f635f921 100644 --- a/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h +++ b/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h @@ -12,6 +12,7 @@ class EveUpdateContext; class Tr2LightManager; BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); BLUE_DECLARE_INTERFACE( IEveChildTransformModifier ); struct EveChildUpdateParams @@ -31,7 +32,7 @@ struct EveChildUpdateParams } IEveSpaceObject2* spaceObjectParent; - IEveSpaceObjectChild* childParent; + EveSpaceObjectChild* childParent; size_t boneCount; const Float4x3* bones; float ownerMaxSpeed; @@ -42,56 +43,12 @@ struct EveChildUpdateParams Vector3 worldVelocity; }; +/** + * @brief Deprecated interface for EveSpaceObjectChild. Classes deriving from EveSpaceObjectChild should still declare + * this interface in MAP_INTERFACE macro for backward compatibility with Python code, but otherwise this interface should not be used directly. + */ BLUE_INTERFACE( IEveSpaceObjectChild ) : - public IRoot -{ - enum Origin - { - SPACE, - SOF, - }; - - virtual const char* GetName() const = 0; - virtual void SetName( const char* name ) = 0; - - virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) = 0; - virtual void GetRenderables( std::vector & renderables ) = 0; - virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const = 0; - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) - { - } - virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const - { - } - - virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) = 0; - virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) = 0; - - virtual void GetLocalToWorldTransform( Matrix & transform ) const = 0; - - virtual bool IsAlwaysOn() const - { - return false; - }; - - virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) = 0; - - virtual void ChangeLOD( Tr2Lod lod ) = 0; - - virtual void SetControllerVariable( const char* name, float value ) {}; - virtual void HandleControllerEvent( const char* name ) {}; - virtual void StartControllers() {}; - - virtual void SetProceduralContainerVariable( const char* name, float value ) {}; - - virtual void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) {}; - - virtual void SetOrigin( Origin origin ) {}; - - virtual void AddTransformModifier( IEveChildTransformModifier * modifier ){}; - - virtual void SetMute( bool isMuted ) {}; -}; + public IRoot{}; BLUE_DECLARE_IVECTOR( IEveSpaceObjectChild ); diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp index d47fb4bb0..fdcc10596 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp @@ -14,16 +14,7 @@ EveChildProceduralContainer::EveChildProceduralContainer( IRoot* lockobj ) : EveChildProceduralContainer::~EveChildProceduralContainer() { -} - -const char* EveChildProceduralContainer::GetName() const -{ - return m_name.c_str(); -} - -void EveChildProceduralContainer::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); + UnregisterChild( m_selectedObject ); } bool EveChildProceduralContainer::Initialize() @@ -60,7 +51,7 @@ bool EveChildProceduralContainer::GetBoundingSphere( Vector4& sphere, BoundingSp { bool success = false; Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); - if( m_selectedObject && m_selectedObject->GetBoundingSphere( bSphere ) ) + if( m_selectedObject && m_selectedObject->GetBoundingSphere( bSphere, EVE_BOUNDS_NORMAL ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -148,7 +139,9 @@ void EveChildProceduralContainer::ConfigureSelectedObject() { entity->UnRegister( registry ); } + UnregisterChild( m_selectedObject ); m_selectedObject = child; + RegisterChild( m_selectedObject ); if( EveEntityPtr entity = BlueCastPtr( m_selectedObject ) ) { entity->Register( registry ); @@ -388,4 +381,28 @@ void EveChildProceduralContainer::RenderDebugInfo( ITr2DebugRenderer2& renderer } } } +} + +void EveChildProceduralContainer::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + if( m_selectedObject ) + { + m_selectedObject->SetOwner( owner ); + } + } +} + +void EveChildProceduralContainer::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + if( m_selectedObject ) + { + m_selectedObject->SetPartTag( tag ); + } + } } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h index 122ee0afc..8a370b44c 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h @@ -2,7 +2,7 @@ #pragma once -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Eve/SpaceObject/Children/IEveEffectChildrenOwner.h" #include "Eve/SpaceObject/Children/EveChildTransform.h" #include "Eve/SpaceObject/Children/TransformModifiers/IEveChildTransformModifier.h" @@ -13,7 +13,7 @@ BLUE_CLASS( EveChildProceduralContainer ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2CurveSetOwner, public IEveInheritPropertiesOwner, public EveChildTransform, @@ -31,9 +31,6 @@ BLUE_CLASS( EveChildProceduralContainer ) : EveChildProceduralContainer( IRoot* lockobj = NULL ); ~EveChildProceduralContainer(); - const char* GetName() const override; - void SetName( const char* name ) override; - void ConfigureSelectedObject(); const char* GetMethodVariableName(); @@ -50,7 +47,7 @@ BLUE_CLASS( EveChildProceduralContainer ) : void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ) override; ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChildOwner + // EveSpaceObjectChildOwner void AddTransformModifier( IEveChildTransformModifier * modifier ) override; void SetProceduralContainerVariable( const char* name, float value ); @@ -71,7 +68,7 @@ BLUE_CLASS( EveChildProceduralContainer ) : void StopAllCurveSets() override; ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void GetRenderables( std::vector & renderables ) override; bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -84,6 +81,8 @@ BLUE_CLASS( EveChildProceduralContainer ) : void ChangeLOD( Tr2Lod lod ) override; ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; void SetInheritProperties( const Color* colorSet ) override; + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; ////////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -100,10 +99,9 @@ BLUE_CLASS( EveChildProceduralContainer ) : void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; protected: - IEveSpaceObjectChildPtr m_selectedObject; + EveSpaceObjectChildPtr m_selectedObject; IEveProceduralSelectionMethodPtr m_selectionMethod; - BlueSharedString m_name; PIEveChildTransformModifierVector m_transformModifiers; TrackableStdUnorderedMap m_proceduralContainerVariables; bool m_display; diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp index e86efdcb0..3bbe124cf 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp @@ -8,6 +8,7 @@ const Be::ClassInfo* EveChildProceduralContainer::ExposeToBlue() { EXPOSURE_BEGIN( EveChildProceduralContainer, "" ) MAP_INTERFACE( EveChildProceduralContainer ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -42,5 +43,8 @@ const Be::ClassInfo* EveChildProceduralContainer::ExposeToBlue() MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, "Start all controllers" ) MAP_METHOD_AND_WRAP( "GetMethodVariableName", GetMethodVariableName, "Get the name of the seed variable being utilized" ) MAP_METHOD_AND_WRAP( "SetProceduralContainerVariable", SetProceduralContainerVariable, "Set variable for all applicable ProceduralContainers\n:param name: variable name\n:param value: new variable value\n" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp index 2cba8fc94..6060c1338 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp @@ -13,16 +13,6 @@ EveChildSmartLightSet::EveChildSmartLightSet( IRoot* lockobj ) : m_lightGroups.SetNotify( this ); } -const char* EveChildSmartLightSet::GetName() const -{ - return m_name.c_str(); -} - -void EveChildSmartLightSet::SetName( const char* name ) -{ - m_name = name; -} - void EveChildSmartLightSet::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ) { if( list == &m_lightGroups && ( event & BELIST_EVENTMASK ) == BELIST_INSERTED ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h index a5b1b1ea2..6e87d569a 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h @@ -3,6 +3,7 @@ #pragma once #include "../EveChildTransform.h" +#include "../EveSpaceObjectChild.h" #include "../EveChildInheritProperties.h" #include "../IEveInheritPropertiesOwner.h" #include "attributeModifiers/IEveSmartLightGroupAttributeModifier.h" @@ -14,7 +15,7 @@ BLUE_DECLARE_INTERFACE( IEveSmartLightGroup ); BLUE_DECLARE_IVECTOR( IEveSmartLightGroup ); BLUE_CLASS( EveChildSmartLightSet ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2DebugRenderable, public IEveInheritPropertiesOwner, @@ -31,22 +32,14 @@ BLUE_CLASS( EveChildSmartLightSet ) : void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; void GetDebugOptions( Tr2DebugRendererOptions & options ) override; - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); - bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const - { - return false; - }; void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const; - void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) {}; - void ChangeLOD( Tr2Lod lod ) {}; void SetControllerVariable( const char* name, float value ) override; ////////////////////////////////////////////////////////////////////////////////////// @@ -65,7 +58,6 @@ BLUE_CLASS( EveChildSmartLightSet ) : private: bool m_display; - std::string m_name; IEveDistributionMethodPtr m_distribution; PIEveSmartLightGroupVector m_lightGroups; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp index cddf27441..24220044c 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveChildSmartLightSet::ExposeToBlue() { EXPOSURE_BEGIN( EveChildSmartLightSet, "\n:jessica-icon: lightbulb-gear\n:jessica-icon-color: (255, 207, 50)\n:jessica-help-url: https://ccpgames.atlassian.net/wiki/spaces/TTL/pages/1308393505/SmartLightSets\n" ) MAP_INTERFACE( EveChildSmartLightSet ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2DebugRenderable ) MAP_INTERFACE( INotify ) @@ -22,5 +23,8 @@ const Be::ClassInfo* EveChildSmartLightSet::ExposeToBlue() MAP_ATTRIBUTE( "distribution", m_distribution, "distributionMethod for entities\n:jessica-icon: map-location-dot\n:jessica-help-url: https://ccpgames.atlassian.net/wiki/spaces/TTL/pages/1311441160/Distributions\n", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "lightGroups", m_lightGroups, "list of lights and light-renderables", Be::READ | Be::PERSIST ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h index 34f63f71e..d7abc3278 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h @@ -5,7 +5,7 @@ #include "IEveSmartLightGroupAttributeModifier.h" #include "Lights/Tr2PointLight.h" #include -#include +#include #include "Curves/Tr2CurveScalar.h" BLUE_DECLARE( Tr2CurveScalar ); diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp index c580579b1..a5c179100 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp @@ -239,6 +239,11 @@ EveSpaceObject2::~EveSpaceObject2() } UnregisterAudioGeometry(); + + for( auto& child : m_effectChildren ) + { + child->SetOwner( nullptr ); + } } bool EveSpaceObject2::Initialize() @@ -249,6 +254,11 @@ bool EveSpaceObject2::Initialize() PrepareForAnimation(); } + for( auto& child : m_effectChildren ) + { + child->SetOwner( this ); + } + for( auto& controller : m_controllers ) { if( !controller->IsLinked() ) @@ -307,8 +317,9 @@ void EveSpaceObject2::OnListModified( long event, ssize_t key, ssize_t key2, IRo switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - if( IEveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) { + child->SetOwner( this ); for( auto it = begin( m_controllerVariables ); it != end( m_controllerVariables ); ++it ) { child->SetControllerVariable( it->first.c_str(), it->second ); @@ -327,6 +338,10 @@ void EveSpaceObject2::OnListModified( long event, ssize_t key, ssize_t key2, IRo { entity->UnRegister( this->GetComponentRegistry() ); } + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + { + child->SetOwner( nullptr ); + } break; case BELIST_UNLOADSTART: if( IsInRegistry() ) @@ -339,6 +354,10 @@ void EveSpaceObject2::OnListModified( long event, ssize_t key, ssize_t key2, IRo } } } + for( auto& child : m_effectChildren ) + { + child->SetOwner( nullptr ); + } break; default: break; @@ -3005,7 +3024,7 @@ void EveSpaceObject2::AddObserver( TriObserverLocalPtr observer ) } // -------------------------------------------------------------------------------- -IEveSpaceObjectChildPtr EveSpaceObject2::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveSpaceObject2::GetEffectChildByName( const char* name ) const { for( auto it = begin( m_effectChildren ); it != end( m_effectChildren ); ++it ) { @@ -3022,7 +3041,7 @@ IEveSpaceObjectChildPtr EveSpaceObject2::GetEffectChildByName( const char* name // Description: // Add a child to the effectChildren list // -------------------------------------------------------------------------------- -void EveSpaceObject2::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveSpaceObject2::AddToEffectChildrenList( EveSpaceObjectChild* child ) { if( m_inheritProperties ) { @@ -3036,7 +3055,7 @@ void EveSpaceObject2::AddToEffectChildrenList( IEveSpaceObjectChild* child ) } // -------------------------------------------------------------------------------- -void EveSpaceObject2::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveSpaceObject2::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { auto index = m_effectChildren.FindKey( child ); if( index >= 0 ) @@ -3858,7 +3877,7 @@ void EveSpaceObject2::SetShaderOption( const BlueSharedString& name, const BlueS for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) { - IEveSpaceObjectChild* child = *it; + EveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } } diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.h b/trinity/Eve/SpaceObject/EveSpaceObject2.h index 19ded272d..d06f06f95 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.h +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.h @@ -21,7 +21,7 @@ #include "Eve/SpaceObject/Attachments/EveMeshOverlayEffect.h" #include "Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h" #include "Eve/SpaceObject/Attachments/EveImpactOverlay.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Eve/SpaceObject/Children/IEveEffectChildrenOwner.h" #include "Eve/SpaceObject/Children/IEveInheritPropertiesOwner.h" #include "Eve/SpaceObject/Attachments/IEveSpaceObjectDecalOwner.h" @@ -385,9 +385,9 @@ BLUE_CLASS( EveSpaceObject2 ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -704,7 +704,7 @@ BLUE_CLASS( EveSpaceObject2 ) : ///////////////////////////////////////////////////////////////////////////////////// // Effect children - PIEveSpaceObjectChildVector m_effectChildren; + PEveSpaceObjectChildVector m_effectChildren; EveChildInheritPropertiesPtr m_inheritProperties; ///////////////////////////////////////////////////////////////////////////////////// diff --git a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h index db557831e..576624e18 100644 --- a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h +++ b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h @@ -3,7 +3,7 @@ #pragma once #include "Eve/EveUpdateContext.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "IEveFxAttribute.h" diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp index b809f11a4..788a34064 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp @@ -273,7 +273,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) EveChildContainerPtr layoutContainer; layoutContainer.CreateInstance(); layoutContainer->SetName( "layouts" ); - layoutContainer->SetOrigin( IEveSpaceObjectChild::SOF ); + layoutContainer->SetOrigin( EveSpaceObjectChild::SOF ); layoutContainer->SetIsPlacementRoot( true ); layoutContainer->SetAlwaysOn( true ); SetupLayout( newObj, layoutContainer, sharedMeshes, dna, centerOffset ); @@ -1719,7 +1719,7 @@ void RecursiveBindParticleEmitters( EveTransform* transform, TriCurveSet* curveS } } -void RecursiveBindParticleEmitters( IEveSpaceObjectChild* child, TriCurveSet* curveSet, Tr2CurveScalar* curve ) +void RecursiveBindParticleEmitters( EveSpaceObjectChild* child, TriCurveSet* curveSet, Tr2CurveScalar* curve ) { if( EveChildContainerPtr container = BlueCastPtr( child ) ) { @@ -1757,7 +1757,7 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild auto postCopy = m_editorMode ? &PostCopyMetadata : nullptr; std::map> childrenToBindTo; - std::map> soChildrenToBindTo; + std::map> soChildrenToBindTo; const std::vector& hullChildren = dna->GetHullChildren(); for( auto childIt = hullChildren.begin(); childIt != hullChildren.end(); ++childIt ) @@ -1805,12 +1805,12 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild obj->AddToChildrenList( transformedChild ); } } - else if( IEveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) + else if( EveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) { size_t index = 0; for( auto& offset : offsets ) { - IEveSpaceObjectChildPtr transformedChild; + EveSpaceObjectChildPtr transformedChild; if( ++index < offsets.size() ) { CCP_STATS_ZONE( "Child Copy" ); @@ -1829,7 +1829,7 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild transformedChild->Setup( &childIt->scaling, &rot, &pos, childIt->lowestLodVisible ); - transformedChild->SetOrigin( IEveSpaceObjectChild::SOF ); + transformedChild->SetOrigin( EveSpaceObjectChild::SOF ); childOwner->AddToEffectChildrenList( transformedChild ); if( childIt->id != -1 ) { @@ -1866,7 +1866,7 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild { RecursiveBindParticleEmitters( ( *transformIt ), curveSet, scalarCurve ); } - std::vector childVector = soChildrenToBindTo[animIt->id]; + std::vector childVector = soChildrenToBindTo[animIt->id]; for( auto childIt = childVector.begin(); childIt != childVector.end(); ++childIt ) { RecursiveBindParticleEmitters( ( *childIt ), curveSet, scalarCurve ); @@ -1971,11 +1971,11 @@ void EveSOF::SetupEffectChildren( EveSpaceObject2Ptr newObj, IEveEffectChildrenO newObj->AddToChildrenList( transformedChild ); } } - else if( IEveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) + else if( EveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) { for( auto& offset : offsets ) { - IEveSpaceObjectChildPtr transformedChild; + EveSpaceObjectChildPtr transformedChild; if( &offset != &offsets.back() ) { BeClasses->CopyTo( effectChild->GetRootObject(), (IRoot**)&transformedChild ); @@ -1993,7 +1993,7 @@ void EveSOF::SetupEffectChildren( EveSpaceObject2Ptr newObj, IEveEffectChildrenO transformedChild->Setup( &childSetItem.scaling, &rot, &pos, childSetItem.lowestLodVisible ); - transformedChild->SetOrigin( IEveSpaceObjectChild::SOF ); + transformedChild->SetOrigin( EveSpaceObjectChild::SOF ); childOwner->AddToEffectChildrenList( transformedChild ); } } @@ -3624,7 +3624,7 @@ void EveSOF::CreatePlacement( { sharedMeshes.CreateInstance(); sharedMeshes->SetName( "SharedInstancedMeshes" ); - sharedMeshes->SetOrigin( IEveSpaceObjectChild::SOF ); + sharedMeshes->SetOrigin( EveSpaceObjectChild::SOF ); parent->AddToEffectChildrenList( sharedMeshes ); } diff --git a/trinity/Eve/Turret/EveTurretFiringFX.h b/trinity/Eve/Turret/EveTurretFiringFX.h index 016359445..667b06389 100644 --- a/trinity/Eve/Turret/EveTurretFiringFX.h +++ b/trinity/Eve/Turret/EveTurretFiringFX.h @@ -15,8 +15,8 @@ BLUE_DECLARE_INTERFACE( IEveFiringEffectElement ); BLUE_DECLARE_IVECTOR( IEveFiringEffectElement ); BLUE_DECLARE_INTERFACE( IEveEffectChildrenOwner ); -BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); -BLUE_DECLARE_IVECTOR( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); +BLUE_DECLARE_VECTOR( EveSpaceObjectChild ); BLUE_DECLARE( TriCurveSet ); BLUE_DECLARE( TriObserverLocal ); BLUE_DECLARE( Tr2QuadRenderer ); diff --git a/trinity/Eve/Turret/EveTurretSet.cpp b/trinity/Eve/Turret/EveTurretSet.cpp index 87efc0812..d6107a0d8 100644 --- a/trinity/Eve/Turret/EveTurretSet.cpp +++ b/trinity/Eve/Turret/EveTurretSet.cpp @@ -18,7 +18,7 @@ #include "EveTurretFiringFX.h" #include "include/TriMath.h" #include "Tr2QuadRenderer.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" CCP_STATS_DECLARED_ELSEWHERE( primitiveCount ); @@ -461,7 +461,7 @@ bool EveTurretSet::IsAmbientVisible() const } -IEveSpaceObjectChild* EveTurretSet::GetAmbientEffectOrGeneratedEffect() const +EveSpaceObjectChild* EveTurretSet::GetAmbientEffectOrGeneratedEffect() const { if( m_ambientEffectEditingMode ) { @@ -3654,12 +3654,12 @@ void EveTurretSet::SetFiringEffect( EveTurretFiringFX* firingEffect ) InitializeFiringEffect(); } -IEveSpaceObjectChild* EveTurretSet::GetAmbientEffect() +EveSpaceObjectChild* EveTurretSet::GetAmbientEffect() { return m_ambientEffect; } -void EveTurretSet::SetAmbientEffect( IEveSpaceObjectChild* ambientEffect ) +void EveTurretSet::SetAmbientEffect( EveSpaceObjectChild* ambientEffect ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_ambientEffect ) ) diff --git a/trinity/Eve/Turret/EveTurretSet.h b/trinity/Eve/Turret/EveTurretSet.h index baa640760..169157903 100644 --- a/trinity/Eve/Turret/EveTurretSet.h +++ b/trinity/Eve/Turret/EveTurretSet.h @@ -283,7 +283,7 @@ BLUE_CLASS( EveTurretSet ) : void InitializeFiringEffect(); // setup the attached ambient effect void InitializeAmbientEffect(); - IEveSpaceObjectChild* GetAmbientEffectOrGeneratedEffect() const; + EveSpaceObjectChild* GetAmbientEffectOrGeneratedEffect() const; void SetAmbientEffectControllerVariableOnInstance( int index, const char* name, float value ); bool IsAmbientVisible() const; @@ -323,8 +323,8 @@ BLUE_CLASS( EveTurretSet ) : EveTurretFiringFX* GetFiringEffect(); void SetFiringEffect( EveTurretFiringFX * firingEffect ); - IEveSpaceObjectChild* GetAmbientEffect(); - void SetAmbientEffect( IEveSpaceObjectChild * ambientEffect ); + EveSpaceObjectChild* GetAmbientEffect(); + void SetAmbientEffect( EveSpaceObjectChild * ambientEffect ); // name std::string m_name; @@ -491,7 +491,7 @@ BLUE_CLASS( EveTurretSet ) : bool m_randomizeExplosionRotation; // ambient effects - IEveSpaceObjectChildPtr m_ambientEffect; + EveSpaceObjectChildPtr m_ambientEffect; EveChildInstanceContainerPtr m_generatedDistributedAmbientEffect; Matrix m_ambientOffsetMatrix; // used while editing bool m_ambientEffectEditingMode; // used for editing diff --git a/trinity/Eve/UI/EveEllipseSet.cpp b/trinity/Eve/UI/EveEllipseSet.cpp index 4e04b6070..3fde5324b 100644 --- a/trinity/Eve/UI/EveEllipseSet.cpp +++ b/trinity/Eve/UI/EveEllipseSet.cpp @@ -127,16 +127,6 @@ bool EveEllipseSet::AddEllipse( const Vector3& center, float semiMajor, float se return true; } -const char* EveEllipseSet::GetName() const -{ - return m_name.c_str(); -} - -void EveEllipseSet::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - EveEllipseSet::~EveEllipseSet() { // Specs may outlive via Python references @@ -400,10 +390,6 @@ void EveEllipseSet::Setup( const Vector3* scale, const Quaternion* rotation, con m_lowestLodVisible = lowestLodVisible; } -void EveEllipseSet::ChangeLOD( Tr2Lod lod ) -{ -} - IRoot* EveEllipseSet::GetID( uint16_t ) { return GetRawRoot(); diff --git a/trinity/Eve/UI/EveEllipseSet.h b/trinity/Eve/UI/EveEllipseSet.h index 2c1639d16..7a8b516e2 100644 --- a/trinity/Eve/UI/EveEllipseSet.h +++ b/trinity/Eve/UI/EveEllipseSet.h @@ -11,12 +11,12 @@ #include "Shader/Tr2EffectStateManager.h" #include "Tr2BufferAL.h" #include "EveEllipseDefinition.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" BLUE_DECLARE( EveEllipseSet ); BLUE_CLASS( EveEllipseSet ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public IListNotify, @@ -36,9 +36,7 @@ BLUE_CLASS( EveEllipseSet ) : bool AddEllipse( const Vector3& center, float semiMajor, float semiMinor, const Vector3& planeNormal, float rotationDegrees ); ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void GetRenderables( std::vector & renderables ) override; bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; @@ -46,7 +44,6 @@ BLUE_CLASS( EveEllipseSet ) : void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; - void ChangeLOD( Tr2Lod lod ) override; ////////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable @@ -72,7 +69,6 @@ BLUE_CLASS( EveEllipseSet ) : // INotify bool OnModified( Be::Var * val ) override; - BlueSharedString m_name; bool m_display = true; bool m_enablePicking = true; float m_depthOffset = 0.f; diff --git a/trinity/Eve/UI/EveEllipseSet_Blue.cpp b/trinity/Eve/UI/EveEllipseSet_Blue.cpp index ade0c2f04..5de0c8c52 100644 --- a/trinity/Eve/UI/EveEllipseSet_Blue.cpp +++ b/trinity/Eve/UI/EveEllipseSet_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveEllipseSet::ExposeToBlue() { EXPOSURE_BEGIN( EveEllipseSet, "" ) MAP_INTERFACE( EveEllipseSet ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( ITr2Pickable ) @@ -33,5 +34,8 @@ const Be::ClassInfo* EveEllipseSet::ExposeToBlue() AddEllipse, "Adds a closed elliptical orbit in the given plane (center, semiMajor, semiMinor, planeNormal, rotationDegrees)" ); MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initializes the EveEllipseSet" ); + MAP_ATTRIBUTE( "partTag", m_partTag, "Part tag for multi-part space objects", Be::READ ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/trinity.cpp b/trinity/trinity.cpp index 11142507b..8e0380eb6 100644 --- a/trinity/trinity.cpp +++ b/trinity/trinity.cpp @@ -34,7 +34,7 @@ BLUE_DEFINE_INTERFACE( IBlueObjectProxy ); #include "TriSettingsRegistrar.h" #include "Eve/IEveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #ifndef TRINITYNAME #error Please add TRINITYNAME= to compiler preprocessor definitions (/D) @@ -400,7 +400,7 @@ MAP_FUNCTION_AND_WRAP( "GetGrannyProductVersion", GetGrannyProductVersion, "Retu static BlueStdResult GetObjectWorldTransform( IRoot* object, Matrix& result ) { - if( IEveSpaceObjectChildPtr child = BlueCastPtr( object ) ) + if( EveSpaceObjectChildPtr child = BlueCastPtr( object ) ) { child->GetLocalToWorldTransform( result ); return BlueStdResult( BLUE_STD_RESULT_OK ); @@ -418,7 +418,7 @@ MAP_FUNCTION_AND_WRAP( "GetObjectWorldTransform", GetObjectWorldTransform, "Returns world transform for some supported object interfaces. Currently only\n" - "IEveSpaceObject2 and IEveSpaceObjectChild interfaces are supported.\n" + "IEveSpaceObject2 and EveSpaceObjectChild interfaces are supported.\n" ":param obj: blue object to get world transform from\n" ":raies TypeError: if the function does not support the object type" ); From cf19ad9f1301800e030a4c66e4ba91ffdad44ae1 Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Mon, 20 Jul 2026 09:02:11 +0000 Subject: [PATCH 02/29] Add the important files --- .../Children/EveSpaceObjectChild.cpp | 151 +++++++++ .../Children/EveSpaceObjectChild.h | 319 ++++++++++++++++++ .../Children/EveSpaceObjectChild_Blue.cpp | 19 ++ 3 files changed, 489 insertions(+) create mode 100644 trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp create mode 100644 trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h create mode 100644 trinity/Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp new file mode 100644 index 000000000..26c34fa10 --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp @@ -0,0 +1,151 @@ +// Copyright © 2026 CCP ehf. + +#include "StdAfx.h" +#include "EveSpaceObjectChild.h" + + +EveSpaceObjectChild::EveSpaceObjectChild( IRoot* ) +{ +} + +const char* EveSpaceObjectChild::GetName() const +{ + return m_name.c_str(); +} + +void EveSpaceObjectChild::SetName( const char* name ) +{ + m_name = BlueSharedString( name ); +} + +void EveSpaceObjectChild::UpdateVisibility( const EveUpdateContext&, const Matrix&, Tr2Lod ) +{ +} + +void EveSpaceObjectChild::GetRenderables( std::vector& ) +{ +} + +bool EveSpaceObjectChild::GetBoundingSphere( Vector4&, BoundingSphereQuery ) const +{ + return false; +} + +void EveSpaceObjectChild::RegisterWithQuadRenderer( Tr2QuadRenderer& ) +{ +} + +void EveSpaceObjectChild::AddQuadsToQuadRenderer( const TriFrustum&, Tr2QuadRenderer& ) const +{ +} + +void EveSpaceObjectChild::UpdateSyncronous( const EveUpdateContext&, const EveChildUpdateParams& ) +{ +} + +void EveSpaceObjectChild::UpdateAsyncronous( const EveUpdateContext&, const EveChildUpdateParams& ) +{ +} + +void EveSpaceObjectChild::GetLocalToWorldTransform( Matrix& ) const +{ +} + +bool EveSpaceObjectChild::IsAlwaysOn() const +{ + return false; +}; + +void EveSpaceObjectChild::Setup( const Vector3*, const Quaternion*, const Vector3*, Tr2Lod ) +{ +} + +void EveSpaceObjectChild::ChangeLOD( Tr2Lod ) +{ +} + +void EveSpaceObjectChild::SetControllerVariable( const char*, float ) +{ +} + +void EveSpaceObjectChild::HandleControllerEvent( const char* ) +{ +} + +void EveSpaceObjectChild::StartControllers() +{ +} + +void EveSpaceObjectChild::SetProceduralContainerVariable( const char*, float ) +{ +} + +void EveSpaceObjectChild::SetShaderOption( const BlueSharedString&, const BlueSharedString& ) +{ +} + +void EveSpaceObjectChild::SetOrigin( Origin ) +{ +} + +void EveSpaceObjectChild::AddTransformModifier( IEveChildTransformModifier* ) +{ +} + +void EveSpaceObjectChild::SetMute( bool isMuted ) +{ +} + +EveSpaceObjectChild::PartTag EveSpaceObjectChild::GetPartTag() const +{ + return m_partTag; +} + +void EveSpaceObjectChild::SetPartTag( PartTag tag ) +{ + m_partTag = tag; +} + +void EveSpaceObjectChild::SetOwner( IEveSpaceObject2* owner ) +{ + m_owner = owner; +} + +IEveSpaceObject2* EveSpaceObjectChild::GetOwner() const +{ + return m_owner; +} + +void EveSpaceObjectChild::SetParent( EveSpaceObjectChild* parent ) +{ + m_parent = parent; +} + +EveSpaceObjectChild* EveSpaceObjectChild::GetParent() const +{ + return m_parent; +} + +void EveSpaceObjectChild::RegisterChild( EveSpaceObjectChild* child ) +{ + if( child ) + { + child->SetParent( this ); + child->SetOwner( m_owner ); + if( m_partTag != EveSpaceObjectChild::NO_PART_TAG ) + { + child->SetPartTag( m_partTag ); + } + } +} + +void EveSpaceObjectChild::UnregisterChild( EveSpaceObjectChild* child ) +{ + if( child ) + { + CCP_ASSERT( child->GetParent() == this ); + child->SetParent( nullptr ); + child->SetOwner( nullptr ); + // No reason to reset the part tag as it is meaningless outside the hierarchy of the parent object + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h new file mode 100644 index 000000000..25651598c --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h @@ -0,0 +1,319 @@ +// Copyright © 2026 CCP ehf. + +#pragma once + +#include "IEveSpaceObjectChild.h" + +BLUE_CLASS_IMPL( EveSpaceObjectChild ); + +/** + * @brief Base class for all space object children. This class provides common functionality and properties for all child objects in the space object hierarchy. + */ +class EveSpaceObjectChild : public IEveSpaceObjectChild +{ +public: + EXPOSE_TO_BLUE(); + + /// @brief Enum representing the origin of the space object child, i.e. how it was created: using SOF or otherwise. + enum Origin + { + SPACE, + SOF, + }; + + /// @brief Type representing a part tag, which is used to identify parts of a modular space object. + using PartTag = uint32_t; + + /// @brief Constant representing a part tag for children that are not part of a modular space object. + static const PartTag NO_PART_TAG = 0; + + EveSpaceObjectChild( IRoot* lockobj = nullptr ); + + /** + * @brief Returns the name of the space object child. This name is used for identification and debugging purposes. + */ + const char* GetName() const; + + /** + * @brief Sets the name of the space object child. This name is used for identification and debugging purposes. + * @param name The new name to set for the space object child. + */ + virtual void SetName( const char* name ); + + /** + * @brief Updates the internal visibility state (frustum culling, LOD, etc.) of the object. This method is called during rendering before GetRenderables() to determine if the object should be rendered. + * Note, that this method is called from worker threads, so care should be taken when accessing shared data. + * The default implementation does nothing, derived classes should override this method to implement visibility logic if needed. + * @param updateContext Scene-wide update context containing timing and other relevant information for the update. + * @param parentTransform Parent transformation matrix to world coordinates. + * @param parentLod Owner space object's LOD level. + */ + virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); + + /** + * @brief Pushes owned renderables to the provided vector. This method is called during rendering to collect all renderable objects for the current frame. + * The default implementation does nothing, derived classes implementing renderable features should override this method to provide their renderables. + * @param renderables Vector to which the renderables will be added. + */ + virtual void GetRenderables( std::vector& renderables ); + + /** + * @brief Retrieves the bounding sphere of the object. This method is used for frustum culling and LOD estimation. + * The default implementation does nothing, derived classes should override this method to provide their bounding sphere if available. + * @param sphere Vector4 to store the bounding sphere (x, y, z for center, w for radius). + * @param query Type of bounding sphere query. + * @return True if the bounding sphere is valid, false otherwise. + */ + virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const; + + /** + * @brief Registers effects with the quad renderer. This method is called when the child is added to the scene to allow it to register any effects that need to be rendered as quads. + * The default implementation does nothing, derived classes implementing quad rendering should override this method to register their effects with the quad renderer. + * @param quadRenderer Quad renderer to register effects with. + */ + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + + /** + * @brief Adds quads to the quad renderer for rendering. This method is called during rendering to allow the child to add any quads that need to be rendered. + * Note, that this method is called from worker threads, so care should be taken when accessing shared data. + * The default implementation does nothing, derived classes implementing quad rendering should override this method to add their quads to the quad renderer. + * @param frustum Frustum used for culling and visibility checks. + * @param quadRenderer Quad renderer to which quads will be added. + */ + virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; + + /** + * @brief Updates the state of the object. This method is called every frame from the main thread to allow the child to update its internal state, animations, etc. + * The default implementation does nothing, derived classes implementing quad rendering should override this method to add their quads to the quad renderer. + * @param updateContext Scene-wide update context containing timing and other relevant information for the update. + * @param params Space object and parent child information relevant for the update. + */ + virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); + + /** + * @brief Updates the state of the object asynchronously. This method is called from worker threads to allow the child to update its internal state, animations, etc. + * The default implementation does nothing, derived classes implementing quad rendering should override this method to add their quads to the quad renderer. + * @param updateContext Scene-wide update context containing timing and other relevant information for the update. + * @param params Space object and parent child information relevant for the update. + */ + virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); + + /** + * @brief Retrieves the local to world transformation matrix of the object. This method is poorly designed. Avoid using it if possible. Not every child has a local + * to world transformation, and this method has no way to return the failure state. The default implementation does nothing, derived classes should override this + * method to provide their local to world transformation if available. + * @param transform Matrix to store the local to world transformation. + */ + virtual void GetLocalToWorldTransform( Matrix& transform ) const; + + /** + * @brief Exotic method that is used to determine if the child needs to be always updated/rendered regardless of the owner's space object "activation strength". + * @return True if the child should always be updated/rendered, false otherwise. + */ + virtual bool IsAlwaysOn() const; + + /** + * @brief Sets up the child transform and LOD. This methods is called by the SOF when creating a child object. + * The default implementation does nothing. If the child has a transform, it should override this method to set up the transform and LOD. + * @param scale Optional scale factors (x, y, z) for the child transform. If nullptr, scaling is unaffected. + * @param rotation Optional rotation for the child transform. If nullptr, rotation is unaffected. + * @param translation Optional translation for the child transform. If nullptr, translation is unaffected. + * @param lowestLodVisible Lowest level of detail (LOD) of the owner space object that is visible for the child. + */ + virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + + /** + * @brief Notifies the child object that the level of detail (LOD) of the owner space object has changed. + * The default implementation does nothing. If the child has LOD-dependent behavior, it should override this method to respond to LOD changes. + * @param lod New level of detail (LOD) of the owner space object. + */ + virtual void ChangeLOD( Tr2Lod lod ); + + /** + * @brief Sets a controller variable for the child object. This method is called by the owner space object to update controller variables that affect the child's behavior. + * If the child owns controllers, it should override this method to propagate the variable to its controllers. Also, if the object owns other children, it should propagate the + * controller variable change to them as well. + * The default implementation does nothing. + * @param name Name of the controller variable. + * @param value Value to set for the controller variable. + */ + virtual void SetControllerVariable( const char* name, float value ); + + /** + * @brief Notifies child controllers that a controller event has occurred. This method is called by the owner space object to notify the child of controller events that may affect its behavior. + * If the child owns controllers, it should override this method to propagate the event to its controllers. Also, if the object owns other children, it should propagate the + * controller event to them as well. + * The default implementation does nothing. + * @param name Name of the controller event. + */ + virtual void HandleControllerEvent( const char* name ); + + /** + * @brief Starts controllers owned by the child object. If the child owns controllers, it should override this method to start them. Also, if the object owns other children, it should propagate the + * start command to them as well. + * The default implementation does nothing. + */ + virtual void StartControllers(); + + /** + * @brief Sets a "procedural container" variable. This method is very specific to EveChildProceduralContainer. Derived classes that own other children should override this method to propagate the call to them. + * The default implementation does nothing. + * @param name Name of the procedural container variable. + * @param value Value to set for the procedural container variable. + */ + virtual void SetProceduralContainerVariable( const char* name, float value ); + + /** + * @brief Sets a shader option for effects managed by the child object. Derived classes that manage effects (or meshes) should override this methods to set the shader option for their effects. Also, if the object + * owns other children, it should override this method to propagate the call to them. + * The default implementation does nothing. + * @param name Name of the shader option. + * @param value Value to set for the shader option. + */ + virtual void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ); + + /** + * @brief Sets the origin (creation method) of the child object. This method is called by the SOF to set the creation method of the object. + * The default implementation does nothing. + * @param origin Origin (creation method) of the child object. + */ + virtual void SetOrigin( Origin origin ); + + /** + * @brief Adds a transform modifier to the child object. If the child object supports transform modifiers, it can override this method to add the modifier to its list of modifiers. + * The default implementation does nothing. + * @param modifier New transform modifier. + */ + virtual void AddTransformModifier( IEveChildTransformModifier* modifier ); + + /** + * @brief Sets the muted state for audio emitters owned by the child object. If the child object owns audio emitters, it can override this method to set their muted state. + * Also, if the object owns other children, it should override this method to propagate the call to them. + * The default implementation does nothing. + * @param isMuted Should the audio emitters be muted (true) or unmuted (false). + */ + virtual void SetMute( bool isMuted ); + + /** + * @brief Returns the part tag of the child object for multi-part space objects. + * @return Part tag of the child object, or NO_PART_TAG if not applicable. + */ + PartTag GetPartTag() const; + + /** + * @brief Sets the part tag of the child object for multi-part space objects. Descendent classes that own other children should override this method to propagate the part tag to them. + * @param tag Part tag to set for the child object. + */ + virtual void SetPartTag( PartTag tag ); + + /** + * @brief Returns the owner space object of the child. It may return nullptr if the child is not currently attached to an owner space object. + * @return Owner space object of the child, or nullptr if not attached. + */ + IEveSpaceObject2* GetOwner() const; + + /** + * @brief Sets the owner space object of the child. Descendent classes that own other children should override this method to propagate the owner to them. + * @param owner Owner space object to set for the child. + */ + virtual void SetOwner( IEveSpaceObject2* owner ); + + /** + * @brief Returns the parent child object of this child. It may return nullptr if the child is not currently attached to a parent child object. + * @return Parent child object of this child, or nullptr if not attached. + */ + EveSpaceObjectChild* GetParent() const; + + /** + * @brief Sets the parent child object of this child. + * @param parent Parent child object to set for this child. + */ + void SetParent( EveSpaceObjectChild* parent ); + +protected: + /** + * @brief Helper function that registers a child object with this parent. Assigns the parent, owner and part tag to the child. + * @param child Child object to register. If the child is nullptr, the method does nothing. + */ + void RegisterChild( EveSpaceObjectChild* child ); + + /** + * @brief Helper function that unregisters a child object with this parent. Resets the parent and owner pointers of the child. + * @param child Child object to unregister. If the child is nullptr, the method does nothing. + */ + void UnregisterChild( EveSpaceObjectChild* child ); + + /** + * @brief Helper function that registers a sequence of child objects with this parent. Assigns the parent, owner and part tag to each child. + * @param children Sequence of child objects to register. + */ + template + void RegisterChildren( const ChildList& children ) + { + for( auto& child : children ) + { + this->RegisterChild( child ); + } + } + + /** + * @brief Helper function that unregisters a sequence of child objects with this parent. Resets the parent and owner pointers of each child. + * @param children Sequence of child objects to unregister. + */ + template + void UnregisterChildren( const ChildList& children ) + { + for( auto& child : children ) + { + this->UnregisterChild( child ); + } + } + + /** + * @brief Helper function that handles list modification notifications for a list of child objects to register and unregister children. + * @tparam ChildList Type of the list of child objects. + * @param event Event type indicating the modification. See BLUELISTEVENT for possible values. + * @param value Value associated with the event. + * @param children List of child objects for which the notification is being sent. + */ + template + void HandleChildrenListModified( + long event, // BLUELISTEVENT values + IRoot* value, + const ChildList& children ) + { + switch( event & BELIST_EVENTMASK ) + { + case BELIST_INSERTED: + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + { + this->RegisterChild( child ); + } + break; + case BELIST_REMOVED: + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + { + this->UnregisterChild( child ); + } + break; + case BELIST_UNLOADSTART: + for( auto& child : children ) + { + this->UnregisterChild( child ); + } + break; + default: + break; + } + } + + BlueSharedString m_name; +private: + IEveSpaceObject2* m_owner = nullptr; + EveSpaceObjectChild* m_parent = nullptr; + PartTag m_partTag = NO_PART_TAG; +}; + +BLUE_DECLARE_VECTOR( EveSpaceObjectChild ); + +TYPEDEF_BLUECLASS( EveSpaceObjectChild ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp new file mode 100644 index 000000000..f5a5a72d9 --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp @@ -0,0 +1,19 @@ +// Copyright © 2026 CCP ehf. + +#include "StdAfx.h" +#include "EveSpaceObjectChild.h" + +BLUE_DEFINE_ABSTRACT( EveSpaceObjectChild ); + +const Be::ClassInfo* EveSpaceObjectChild::ExposeToBlue() +{ + EXPOSURE_BEGIN( EveSpaceObjectChild, "" ) + MAP_INTERFACE( EveSpaceObjectChild ) + + MAP_ATTRIBUTE( "name", m_name, "Name of the space object child", Be::READWRITE | Be::PERSIST ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) + + EXPOSURE_END() +} From ce895840654d660257e6b4d494230ce9791f2e1f Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Mon, 20 Jul 2026 09:05:46 +0000 Subject: [PATCH 03/29] Format files --- trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp | 2 +- trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp index 26c34fa10..464de622b 100644 --- a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp @@ -38,7 +38,7 @@ void EveSpaceObjectChild::RegisterWithQuadRenderer( Tr2QuadRenderer& ) void EveSpaceObjectChild::AddQuadsToQuadRenderer( const TriFrustum&, Tr2QuadRenderer& ) const { } - + void EveSpaceObjectChild::UpdateSyncronous( const EveUpdateContext&, const EveChildUpdateParams& ) { } diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h index 25651598c..ef8721a7a 100644 --- a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h @@ -308,6 +308,7 @@ class EveSpaceObjectChild : public IEveSpaceObjectChild } BlueSharedString m_name; + private: IEveSpaceObject2* m_owner = nullptr; EveSpaceObjectChild* m_parent = nullptr; From 28e689026719d02e2be94778648598be420ce7ac Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Mon, 20 Jul 2026 09:07:30 +0000 Subject: [PATCH 04/29] Use property to access the part tag --- trinity/Eve/UI/EveEllipseSet_Blue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trinity/Eve/UI/EveEllipseSet_Blue.cpp b/trinity/Eve/UI/EveEllipseSet_Blue.cpp index 5de0c8c52..c25726485 100644 --- a/trinity/Eve/UI/EveEllipseSet_Blue.cpp +++ b/trinity/Eve/UI/EveEllipseSet_Blue.cpp @@ -34,7 +34,7 @@ const Be::ClassInfo* EveEllipseSet::ExposeToBlue() AddEllipse, "Adds a closed elliptical orbit in the given plane (center, semiMajor, semiMinor, planeNormal, rotationDegrees)" ); MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initializes the EveEllipseSet" ); - MAP_ATTRIBUTE( "partTag", m_partTag, "Part tag for multi-part space objects", Be::READ ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() From 3173b93455cb9ed81398897efb81e67cbb659ab4 Mon Sep 17 00:00:00 2001 From: filipppavlov Date: Mon, 20 Jul 2026 11:21:01 +0000 Subject: [PATCH 05/29] Potential fix for pull request finding Use `UnregisterChild` helper method Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp index e20b56091..d87867607 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp @@ -354,8 +354,7 @@ void EveChildInstanceContainer::PopFront() front->UnRegister( GetComponentRegistry() ); } } - m_instances[0]->SetOwner( nullptr ); - m_instances[0]->SetParent( nullptr ); + UnregisterChild( m_instances[0] ); m_instances.Remove( 0 ); } } From 93843038ec47f302f2fe6344824b16354774b4c0 Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Fri, 17 Jul 2026 15:25:56 +0000 Subject: [PATCH 06/29] Refactor IEveSpaceObjectChild interface into a base class The new base class has support "owner", "parent" and "part tag" shared attributes. --- trinity/CMakeLists.txt | 3 + .../Actions/Tr2ActionChildEffect.cpp | 4 +- .../Actions/Tr2ActionChildEffect.h | 4 +- .../Actions/Tr2ActionPlayCurveSet.cpp | 1 - trinity/Eve/EveEffectRoot2.cpp | 29 ++++- trinity/Eve/EveEffectRoot2.h | 12 +- .../Eve/Renderable/Stretch/EveStretch3.cpp | 52 ++++---- trinity/Eve/Renderable/Stretch/EveStretch3.h | 32 ++--- .../SpaceObject/Children/EveChildAudio.cpp | 41 +------ .../Eve/SpaceObject/Children/EveChildAudio.h | 15 +-- .../Children/EveChildAudio_Blue.cpp | 4 + .../Children/EveChildBehaviorSystem.cpp | 20 +-- .../Children/EveChildBehaviorSystem.h | 10 +- .../Children/EveChildBehaviorSystem_Blue.cpp | 4 + .../Children/EveChildBulletStorm.cpp | 28 ----- .../Children/EveChildBulletStorm.h | 15 +-- .../Children/EveChildBulletStorm_Blue.cpp | 4 + .../SpaceObject/Children/EveChildCloud.cpp | 10 -- .../Eve/SpaceObject/Children/EveChildCloud.h | 13 +- .../SpaceObject/Children/EveChildCloud2.cpp | 18 --- .../Eve/SpaceObject/Children/EveChildCloud2.h | 17 +-- .../Children/EveChildCloud2_Blue.cpp | 4 + .../Children/EveChildCloud_Blue.cpp | 4 + .../Children/EveChildContainer.cpp | 48 +++++--- .../SpaceObject/Children/EveChildContainer.h | 20 ++- .../Children/EveChildContainer_Blue.cpp | 10 +- .../Children/EveChildEffectPropagator.cpp | 6 +- .../Children/EveChildEffectPropagator.h | 1 - .../EveChildEffectPropagator_Blue.cpp | 4 + .../Children/EveChildExplosion.cpp | 8 +- .../SpaceObject/Children/EveChildExplosion.h | 12 +- .../Children/EveChildExplosion_Blue.cpp | 4 + .../Children/EveChildFogVolume.cpp | 20 +-- .../SpaceObject/Children/EveChildFogVolume.h | 14 +-- .../Children/EveChildFogVolume_Blue.cpp | 5 +- .../Children/EveChildInstanceContainer.cpp | 116 +++++++++++------- .../Children/EveChildInstanceContainer.h | 31 +++-- .../EveChildInstanceContainer_Blue.cpp | 95 +++++++------- .../Children/EveChildInstanceMeshRenderer.h | 2 +- .../EveChildInstanceMeshRenderer_Blue.cpp | 4 + .../Children/EveChildInstancedMeshes.cpp | 14 --- .../Children/EveChildInstancedMeshes.h | 10 +- .../Children/EveChildInstancedMeshes_Blue.cpp | 4 + .../Children/EveChildLightingOverride.cpp | 14 --- .../Children/EveChildLightingOverride.h | 15 +-- .../EveChildLightingOverride_Blue.cpp | 4 + .../SpaceObject/Children/EveChildLineSet.cpp | 10 -- .../SpaceObject/Children/EveChildLineSet.h | 11 +- .../Children/EveChildLineSet_Blue.cpp | 4 + .../Eve/SpaceObject/Children/EveChildLink.h | 2 +- .../Eve/SpaceObject/Children/EveChildMesh.cpp | 10 -- .../Eve/SpaceObject/Children/EveChildMesh.h | 11 +- .../Children/EveChildMesh_Blue.cpp | 5 + .../Children/EveChildParticleSphere.cpp | 12 -- .../Children/EveChildParticleSphere.h | 11 +- .../Children/EveChildParticleSphere_Blue.cpp | 4 + .../Children/EveChildParticleSystem.cpp | 10 -- .../Children/EveChildParticleSystem.h | 10 +- .../Children/EveChildParticleSystem_Blue.cpp | 4 + .../Eve/SpaceObject/Children/EveChildPlug.cpp | 47 ++++--- .../Eve/SpaceObject/Children/EveChildPlug.h | 20 ++- .../Children/EveChildPlug_Blue.cpp | 4 + .../Children/EveChildPostProcessVolume.cpp | 19 +-- .../Children/EveChildPostProcessVolume.h | 14 +-- .../EveChildPostProcessVolume_Blue.cpp | 4 + .../Eve/SpaceObject/Children/EveChildQuad.cpp | 14 --- .../Eve/SpaceObject/Children/EveChildQuad.h | 11 +- .../Children/EveChildQuad_Blue.cpp | 4 + .../Eve/SpaceObject/Children/EveChildRef.cpp | 49 +++++--- .../Eve/SpaceObject/Children/EveChildRef.h | 21 ++-- .../SpaceObject/Children/EveChildRef_Blue.cpp | 4 + .../SpaceObject/Children/EveChildSocket.cpp | 44 ++++--- .../Eve/SpaceObject/Children/EveChildSocket.h | 19 ++- .../Children/EveChildSocket_Blue.cpp | 4 + .../SpaceObject/Children/EveChildSpherePin.h | 2 +- .../Children/IEveEffectChildrenOwner.h | 8 +- .../Children/IEveSpaceObjectChild.h | 57 ++------- .../EveChildProceduralContainer.cpp | 39 ++++-- .../EveChildProceduralContainer.h | 16 ++- .../EveChildProceduralContainer_Blue.cpp | 4 + .../SmartLightSets/EveChildSmartLightSet.cpp | 10 -- .../SmartLightSets/EveChildSmartLightSet.h | 14 +-- .../EveChildSmartLightSet_Blue.cpp | 4 + .../EveSmartLightBaseAttributeModifier.h | 2 +- trinity/Eve/SpaceObject/EveSpaceObject2.cpp | 29 ++++- trinity/Eve/SpaceObject/EveSpaceObject2.h | 10 +- .../fxAttributes/EveCameraFxAttributes.h | 2 +- trinity/Eve/SpaceObjectFactory/EveSOF.cpp | 22 ++-- trinity/Eve/Turret/EveTurretFiringFX.h | 4 +- trinity/Eve/Turret/EveTurretSet.cpp | 8 +- trinity/Eve/Turret/EveTurretSet.h | 8 +- trinity/Eve/UI/EveEllipseSet.cpp | 14 --- trinity/Eve/UI/EveEllipseSet.h | 10 +- trinity/Eve/UI/EveEllipseSet_Blue.cpp | 4 + trinity/trinity.cpp | 6 +- 95 files changed, 653 insertions(+), 807 deletions(-) diff --git a/trinity/CMakeLists.txt b/trinity/CMakeLists.txt index dc0e9c6e0..af3d96fab 100644 --- a/trinity/CMakeLists.txt +++ b/trinity/CMakeLists.txt @@ -572,6 +572,9 @@ set(_SOURCES Eve/SpaceObject/Children/EveCloudEditableVolume.cpp Eve/SpaceObject/Children/EveCloudEditableVolume.h Eve/SpaceObject/Children/EveCloudEditableVolume_Blue.cpp + Eve/SpaceObject/Children/EveSpaceObjectChild.cpp + Eve/SpaceObject/Children/EveSpaceObjectChild.h + Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp Eve/SpaceObject/Children/IEveEffectChildrenOwner.h Eve/SpaceObject/Children/IEveSpaceObjectChild.h Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierProcessLifetime.cpp diff --git a/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp b/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp index 637e4b83d..2ff61cfb4 100644 --- a/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp +++ b/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp @@ -4,7 +4,7 @@ #include "Tr2ActionChildEffect.h" #include "Controllers/Tr2Controller.h" #include "Eve/SpaceObject/Children/IEveEffectChildrenOwner.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Eve/EveMultiEffect.h" #include "Eve/EveMultiEffectParameter.h" #include "Eve/Renderable/Stretch/EveStretch3.h" @@ -115,7 +115,7 @@ void Tr2ActionChildEffect::Start( ITr2ActionController& controller ) } if( m_addOnStart && !m_child && !m_path.empty() ) { - m_child = BeResMan->LoadObject( m_path.c_str() ); + m_child = BeResMan->LoadObject( m_path.c_str() ); if( m_child ) { if( !m_childName.empty() ) diff --git a/trinity/Controllers/Actions/Tr2ActionChildEffect.h b/trinity/Controllers/Actions/Tr2ActionChildEffect.h index 10efcb47e..77f53a5b0 100644 --- a/trinity/Controllers/Actions/Tr2ActionChildEffect.h +++ b/trinity/Controllers/Actions/Tr2ActionChildEffect.h @@ -4,7 +4,7 @@ #include "ITr2ControllerAction.h" -BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); BLUE_CLASS( Tr2ActionChildEffect ) : @@ -21,7 +21,7 @@ BLUE_CLASS( Tr2ActionChildEffect ) : private: std::string m_path; std::string m_childName; - IEveSpaceObjectChildPtr m_child; + EveSpaceObjectChildPtr m_child; bool m_addOnStart; bool m_removeOnStop; BlueSharedString m_targetAnotherOwner; diff --git a/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp b/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp index eed76b4ac..ca8b094d5 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp +++ b/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp @@ -7,7 +7,6 @@ #include "Curves/TriCurveSet.h" #include "Eve/SpaceObject/EveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" #include "Eve/EveEffectRoot2.h" diff --git a/trinity/Eve/EveEffectRoot2.cpp b/trinity/Eve/EveEffectRoot2.cpp index b37c60d85..70eb1bdf3 100644 --- a/trinity/Eve/EveEffectRoot2.cpp +++ b/trinity/Eve/EveEffectRoot2.cpp @@ -49,10 +49,18 @@ EveEffectRoot2::~EveEffectRoot2() { controller->Unlink( UnlinkReason::DELETING ); } + for( auto& child : m_effectChildren ) + { + child->SetOwner( nullptr ); + } } bool EveEffectRoot2::Initialize() { + for( auto& child : m_effectChildren ) + { + child->SetOwner( this ); + } for( auto& controller : m_controllers ) { if( !controller->IsLinked() ) @@ -113,8 +121,9 @@ void EveEffectRoot2::OnListModified( long event, ssize_t key, ssize_t key2, IRoo switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - if( IEveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) { + child->SetOwner( this ); for( auto it = begin( m_controllerVariables ); it != end( m_controllerVariables ); ++it ) { child->SetControllerVariable( it->first.c_str(), it->second ); @@ -137,6 +146,10 @@ void EveEffectRoot2::OnListModified( long event, ssize_t key, ssize_t key2, IRoo entity->UnRegister( GetComponentRegistry() ); } } + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + { + child->SetOwner( nullptr ); + } break; case BELIST_UNLOADSTART: if( IsInRegistry() ) @@ -149,6 +162,10 @@ void EveEffectRoot2::OnListModified( long event, ssize_t key, ssize_t key2, IRoo } } } + for( auto& child : m_effectChildren ) + { + child->SetOwner( nullptr ); + } default: break; } @@ -668,7 +685,7 @@ void EveEffectRoot2::GetMissPosition( const Vector3* hit, const Vector3* source, } // ----------------------------------------------------------------------------- -PIEveSpaceObjectChildVector& EveEffectRoot2::GetChildren() +PEveSpaceObjectChildVector& EveEffectRoot2::GetChildren() { return m_effectChildren; } @@ -884,7 +901,7 @@ void EveEffectRoot2::StartControllers() } // -------------------------------------------------------------------------------- -IEveSpaceObjectChildPtr EveEffectRoot2::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveEffectRoot2::GetEffectChildByName( const char* name ) const { for( auto it = begin( m_effectChildren ); it != end( m_effectChildren ); ++it ) { @@ -898,7 +915,7 @@ IEveSpaceObjectChildPtr EveEffectRoot2::GetEffectChildByName( const char* name ) } // -------------------------------------------------------------------------------- -void EveEffectRoot2::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveEffectRoot2::AddToEffectChildrenList( EveSpaceObjectChild* child ) { if( IsInRegistry() && m_display ) { @@ -911,7 +928,7 @@ void EveEffectRoot2::AddToEffectChildrenList( IEveSpaceObjectChild* child ) } // -------------------------------------------------------------------------------- -void EveEffectRoot2::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveEffectRoot2::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { auto index = m_effectChildren.FindKey( child ); if( index >= 0 ) @@ -931,7 +948,7 @@ void EveEffectRoot2::SetShaderOption( const BlueSharedString& name, const BlueSh { for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) { - IEveSpaceObjectChild* child = *it; + EveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } } diff --git a/trinity/Eve/EveEffectRoot2.h b/trinity/Eve/EveEffectRoot2.h index 2f49183c5..7114339a1 100644 --- a/trinity/Eve/EveEffectRoot2.h +++ b/trinity/Eve/EveEffectRoot2.h @@ -9,7 +9,7 @@ #include "EveTransform.h" #include "EveLODHelper.h" #include "IEveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Eve/SpaceObject/Children/IEveEffectChildrenOwner.h" #include "Tr2ShLightingManager.h" #include "Include/ITriTargetable.h" @@ -134,9 +134,9 @@ BLUE_CLASS( EveEffectRoot2 ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; ///////////////////////////////////////////////////////////////////////////////////// @@ -160,7 +160,7 @@ BLUE_CLASS( EveEffectRoot2 ) : void Start(); void Stop(); - PIEveSpaceObjectChildVector& GetChildren(); + PEveSpaceObjectChildVector& GetChildren(); void SetTransform( const Matrix& transform ); @@ -204,7 +204,7 @@ BLUE_CLASS( EveEffectRoot2 ) : std::string m_name; bool m_display; bool m_mute; - PIEveSpaceObjectChildVector m_effectChildren; + PEveSpaceObjectChildVector m_effectChildren; Vector3 m_scaling; Quaternion m_rotation; diff --git a/trinity/Eve/Renderable/Stretch/EveStretch3.cpp b/trinity/Eve/Renderable/Stretch/EveStretch3.cpp index ef4a5711e..f518ca15e 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch3.cpp +++ b/trinity/Eve/Renderable/Stretch/EveStretch3.cpp @@ -13,7 +13,7 @@ #include "Lights/Tr2PointLight.h" #include "Controllers/ITr2Controller.h" #include "Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Audio/Tr2AudioStretchAuto.h" #include "Audio/Tr2AudioStretchBase.h" @@ -123,7 +123,7 @@ void EveStretch3::Rebind( bool onlyUpdateBindings ) } } -void EveStretch3::RunOnComponents( std::function func ) const +void EveStretch3::RunOnComponents( std::function func ) const { if( m_sourceObject ) { @@ -146,7 +146,7 @@ void EveStretch3::RunOnComponents( std::function } } -float EveStretch3::RunOnComponentsGetMax( std::function func ) const +float EveStretch3::RunOnComponentsGetMax( std::function func ) const { float ret = -1.f; if( m_sourceObject ) @@ -211,12 +211,12 @@ std::unordered_map EveStretch3::GetParameterMap() const return parameterMap; } -IEveSpaceObjectChild* EveStretch3::GetSourceObject() +EveSpaceObjectChild* EveStretch3::GetSourceObject() { return m_sourceObject; } -void EveStretch3::SetSourceObject( IEveSpaceObjectChild* sourceObject ) +void EveStretch3::SetSourceObject( EveSpaceObjectChild* sourceObject ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_sourceObject ) ) @@ -230,12 +230,12 @@ void EveStretch3::SetSourceObject( IEveSpaceObjectChild* sourceObject ) } } -IEveSpaceObjectChild* EveStretch3::GetDestObject() +EveSpaceObjectChild* EveStretch3::GetDestObject() { return m_destObject; } -void EveStretch3::SetDestObject( IEveSpaceObjectChild* destObject ) +void EveStretch3::SetDestObject( EveSpaceObjectChild* destObject ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_destObject ) ) @@ -249,12 +249,12 @@ void EveStretch3::SetDestObject( IEveSpaceObjectChild* destObject ) } } -IEveSpaceObjectChild* EveStretch3::GetStretchObject() +EveSpaceObjectChild* EveStretch3::GetStretchObject() { return m_stretchObject; } -void EveStretch3::SetStretchObject( IEveSpaceObjectChild* stretchObject ) +void EveStretch3::SetStretchObject( EveSpaceObjectChild* stretchObject ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_stretchObject ) ) @@ -280,12 +280,12 @@ void EveStretch3::SetStretchObject( IEveSpaceObjectChild* stretchObject ) } } -IEveSpaceObjectChild* EveStretch3::GetMoveObject() +EveSpaceObjectChild* EveStretch3::GetMoveObject() { return m_moveObject; } -void EveStretch3::SetMoveObject( IEveSpaceObjectChild* moveObject ) +void EveStretch3::SetMoveObject( EveSpaceObjectChild* moveObject ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_moveObject ) ) @@ -605,7 +605,7 @@ void EveStretch3::GetRenderables( std::vector& renderables, Tr2 return; } - RunOnComponents( [&renderables]( IEveSpaceObjectChild* c ) { c->GetRenderables( renderables ); } ); + RunOnComponents( [&renderables]( EveSpaceObjectChild* c ) { c->GetRenderables( renderables ); } ); } void EveStretch3::SetDisplay( bool display ) @@ -724,7 +724,7 @@ void EveStretch3::RegisterComponents() if( registry && m_display ) { RunOnComponents( - [this]( IEveSpaceObjectChild* c ) { + [this]( EveSpaceObjectChild* c ) { if( EveEntityPtr entity = BlueCastPtr( c ) ) { entity->Register( GetComponentRegistry() ); @@ -739,7 +739,7 @@ void EveStretch3::UnRegisterComponents() if( registry ) { RunOnComponents( - [this]( IEveSpaceObjectChild* c ) { + [this]( EveSpaceObjectChild* c ) { if( EveEntityPtr entity = BlueCastPtr( c ) ) { entity->UnRegister( GetComponentRegistry() ); @@ -763,7 +763,7 @@ void EveStretch3::GetBindingRoots( std::unordered_map& vari void EveStretch3::SetControllerVariable( const char* name, float value ) { - RunOnComponents( [name, value]( IEveSpaceObjectChild* c ) { c->SetControllerVariable( name, value ); } ); + RunOnComponents( [name, value]( EveSpaceObjectChild* c ) { c->SetControllerVariable( name, value ); } ); for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { @@ -774,7 +774,7 @@ void EveStretch3::SetControllerVariable( const char* name, float value ) void EveStretch3::HandleControllerEvent( const char* name ) { - RunOnComponents( [name]( IEveSpaceObjectChild* c ) { c->HandleControllerEvent( name ); } ); + RunOnComponents( [name]( EveSpaceObjectChild* c ) { c->HandleControllerEvent( name ); } ); for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { @@ -784,7 +784,7 @@ void EveStretch3::HandleControllerEvent( const char* name ) void EveStretch3::StartControllers() { - RunOnComponents( []( IEveSpaceObjectChild* c ) { c->StartControllers(); } ); + RunOnComponents( []( EveSpaceObjectChild* c ) { c->StartControllers(); } ); for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { @@ -799,7 +799,7 @@ void EveStretch3::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) { return; } - RunOnComponents( [&quadRenderer]( IEveSpaceObjectChild* c ) { c->RegisterWithQuadRenderer( quadRenderer ); } ); + RunOnComponents( [&quadRenderer]( EveSpaceObjectChild* c ) { c->RegisterWithQuadRenderer( quadRenderer ); } ); } void EveStretch3::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) @@ -809,7 +809,7 @@ void EveStretch3::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRend return; } - RunOnComponents( [&frustum, &quadRenderer]( IEveSpaceObjectChild* c ) { c->AddQuadsToQuadRenderer( frustum, quadRenderer ); } ); + RunOnComponents( [&frustum, &quadRenderer]( EveSpaceObjectChild* c ) { c->AddQuadsToQuadRenderer( frustum, quadRenderer ); } ); } void EveStretch3::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) @@ -837,7 +837,7 @@ void EveStretch3::SetDestObjectScale( float scale ) void EveStretch3::GetDebugOptions( Tr2DebugRendererOptions& options ) { options.insert( "Lights" ); - RunOnComponents( [&options]( IEveSpaceObjectChild* c ) { + RunOnComponents( [&options]( EveSpaceObjectChild* c ) { auto debugRenderable = dynamic_cast( c ); if( debugRenderable ) { @@ -862,7 +862,7 @@ void EveStretch3::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { return; } - RunOnComponents( [&renderer]( IEveSpaceObjectChild* c ) { + RunOnComponents( [&renderer]( EveSpaceObjectChild* c ) { auto debugRenderable = dynamic_cast( c ); if( debugRenderable ) { @@ -904,7 +904,7 @@ void EveStretch3::PlayCurveSet( const std::string& name, const std::string& rang } } - RunOnComponents( [name, rangeName]( IEveSpaceObjectChild* c ) { + RunOnComponents( [name, rangeName]( EveSpaceObjectChild* c ) { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { @@ -928,7 +928,7 @@ void EveStretch3::StopCurveSet( const std::string& name ) } } - RunOnComponents( [name]( IEveSpaceObjectChild* c ) { + RunOnComponents( [name]( EveSpaceObjectChild* c ) { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { @@ -947,7 +947,7 @@ void EveStretch3::UpdateCurveSet( const std::string& name, Be::Time time ) } } - RunOnComponents( [name, time]( IEveSpaceObjectChild* c ) { + RunOnComponents( [name, time]( EveSpaceObjectChild* c ) { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { @@ -971,7 +971,7 @@ float EveStretch3::GetCurveSetDuration( const std::string& name ) const maxDuration = max( maxDuration, ( *it )->GetMaxCurveDuration() ); } } - float componentMax = RunOnComponentsGetMax( [name]( IEveSpaceObjectChild* c ) -> float { + float componentMax = RunOnComponentsGetMax( [name]( EveSpaceObjectChild* c ) -> float { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { @@ -999,7 +999,7 @@ float EveStretch3::GetRangeDuration( const std::string& name, const std::string& } } - float componentMax = RunOnComponentsGetMax( [name, rangeName]( IEveSpaceObjectChild* c ) -> float { + float componentMax = RunOnComponentsGetMax( [name, rangeName]( EveSpaceObjectChild* c ) -> float { auto curveSetOwner = dynamic_cast( c ); if( curveSetOwner ) { diff --git a/trinity/Eve/Renderable/Stretch/EveStretch3.h b/trinity/Eve/Renderable/Stretch/EveStretch3.h index 1040a537d..75b47d7d9 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch3.h +++ b/trinity/Eve/Renderable/Stretch/EveStretch3.h @@ -12,13 +12,13 @@ #include "Controllers/ITr2ControllerOwner.h" #include "Lights/ITr2LightOwner.h" #include "Lights/Tr2Light.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" BLUE_DECLARE( EveStretch3 ); BLUE_DECLARE( TriFloat ); BLUE_DECLARE( EveChildModifierStretch ); -BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); BLUE_DECLARE_INTERFACE( ITr2Controller ); BLUE_DECLARE_INTERFACE( ITriVectorFunction ); @@ -126,14 +126,14 @@ BLUE_CLASS( EveStretch3 ) : // ITr2SoundEmitterOwner ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; - IEveSpaceObjectChild* GetSourceObject(); - void SetSourceObject( IEveSpaceObjectChild * sourceObject ); - IEveSpaceObjectChild* GetDestObject(); - void SetDestObject( IEveSpaceObjectChild * destObject ); - IEveSpaceObjectChild* GetStretchObject(); - void SetStretchObject( IEveSpaceObjectChild * stretchObject ); - IEveSpaceObjectChild* GetMoveObject(); - void SetMoveObject( IEveSpaceObjectChild * moveObject ); + EveSpaceObjectChild* GetSourceObject(); + void SetSourceObject( EveSpaceObjectChild * sourceObject ); + EveSpaceObjectChild* GetDestObject(); + void SetDestObject( EveSpaceObjectChild * destObject ); + EveSpaceObjectChild* GetStretchObject(); + void SetStretchObject( EveSpaceObjectChild * stretchObject ); + EveSpaceObjectChild* GetMoveObject(); + void SetMoveObject( EveSpaceObjectChild * moveObject ); private: enum StretchState @@ -144,8 +144,8 @@ BLUE_CLASS( EveStretch3 ) : STRETCH_STATE_STOPPING }; - void RunOnComponents( std::function func ) const; - float RunOnComponentsGetMax( std::function func ) const; + void RunOnComponents( std::function func ) const; + float RunOnComponentsGetMax( std::function func ) const; void SetSourceSpaceObject( IEveSpaceObject2 * spaceObject ); void SetDestSpaceObject( IEveSpaceObject2 * spaceObject ); @@ -169,10 +169,10 @@ BLUE_CLASS( EveStretch3 ) : BlueWeakRef m_sourceSpaceObject; BlueWeakRef m_destSpaceObject; - IEveSpaceObjectChildPtr m_sourceObject; - IEveSpaceObjectChildPtr m_destObject; - IEveSpaceObjectChildPtr m_stretchObject; - IEveSpaceObjectChildPtr m_moveObject; + EveSpaceObjectChildPtr m_sourceObject; + EveSpaceObjectChildPtr m_destObject; + EveSpaceObjectChildPtr m_stretchObject; + EveSpaceObjectChildPtr m_moveObject; PTriCurveSetVector m_curveSets; Be::Time m_startTime; diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp b/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp index 0e8c8b2f9..0e7f9b9a0 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp @@ -5,10 +5,10 @@ EveChildAudio::EveChildAudio( IRoot* lockobj ) : - m_name( "EveChildAudio" ), m_mute( false ), m_worldTransform( IdentityMatrix() ) { + m_name = BlueSharedString( "EveChildAudio" ); } bool EveChildAudio::Initialize() @@ -30,7 +30,7 @@ bool EveChildAudio::Initialize() } else { - emitterName = m_name; + emitterName = m_name.c_str(); } m_audioEmitter->Initialize( emitterName, L"", position ); @@ -68,40 +68,17 @@ bool EveChildAudio::OnModified( Be::Var* val ) } else { - SetEmitterName( m_name ); + SetEmitterName( m_name.c_str() ); } } return true; } -const char* EveChildAudio::GetName() const -{ - return m_name.c_str(); -} - -void EveChildAudio::SetName( const char* name ) -{ - m_name = name; -} - void EveChildAudio::GetLocalToWorldTransform( Matrix& transform ) const { transform = m_worldTransform; } -void EveChildAudio::Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) -{ -} - -void EveChildAudio::GetRenderables( std::vector& renderables ) -{ -} - -bool EveChildAudio::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const -{ - return false; -} - void EveChildAudio::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { Matrix localToWorldTransform; @@ -130,10 +107,6 @@ void EveChildAudio::UpdateSyncronous( const EveUpdateContext& updateContext, con } } -void EveChildAudio::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) -{ -} - void EveChildAudio::SetEmitterName( const std::string& name ) { if( m_audioEmitter ) @@ -142,14 +115,6 @@ void EveChildAudio::SetEmitterName( const std::string& name ) } } -void EveChildAudio::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) -{ -} - -void EveChildAudio::ChangeLOD( Tr2Lod lod ) -{ -} - void EveChildAudio::GetDebugOptions( Tr2DebugRendererOptions& options ) { if( ITr2DebugRenderablePtr tmp = BlueCastPtr( m_audioEmitter ) ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio.h b/trinity/Eve/SpaceObject/Children/EveChildAudio.h index cbabd87cb..3b626c383 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio.h +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio.h @@ -3,7 +3,7 @@ #ifndef EVE_CHILD_AUDIO_H #define EVE_CHILD_AUDIO_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 @@ -27,7 +27,7 @@ BLUE_DECLARE( EveChildAudio ); * @brief Audio emitter that can be added as a child to EveChildContainer. */ BLUE_CLASS( EveChildAudio ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public IInitialize, public INotify, @@ -73,24 +73,15 @@ BLUE_CLASS( EveChildAudio ) : */ void SetEmitterName( const std::string& name ); - // Implementing the IEveSpaceObjectChild interface - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector & renderables ); - bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + // Implementing the EveSpaceObjectChild interface void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ); - void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); // ITr2DebugRenderable virtual void GetDebugOptions( Tr2DebugRendererOptions & options ) override; virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; private: - std::string m_name; ///< The name identifier for this audio child. Matrix m_worldTransform; ///< Cached world transformation matrix. bool m_mute; ///< Whether audio playback is muted. ITr2AudEmitterPtr m_audioEmitter; ///< The audio emitter instance. diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp index a156c15ed..1aeb552ad 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildAudio::ExposeToBlue() EXPOSURE_BEGIN( EveChildAudio, "Audio emitter space object child" ) MAP_INTERFACE( EveChildAudio ) MAP_INTERFACE( IEveSpaceObjectChild ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -20,5 +21,8 @@ const Be::ClassInfo* EveChildAudio::ExposeToBlue() MAP_METHOD_AND_WRAP( "SetEmitterName", SetEmitterName, "Sets emitter name" ) MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initialize the audio emitter after contruction/deserialization" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp index 0a2c09176..2cb9b827f 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp @@ -578,7 +578,7 @@ std::vector> EveChildBehaviorSystem::GetVertexElementAddedTh ///////////////////////////////////////////////////////////////////////////////////// -// IEveSpaceObjectChild +// EveSpaceObjectChild void EveChildBehaviorSystem::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { Matrix localToWorldTransform; @@ -615,11 +615,6 @@ void EveChildBehaviorSystem::UpdateAsyncronous( const EveUpdateContext& updateCo m_hasUpdated = true; } -const char* EveChildBehaviorSystem::GetName() const -{ - return m_name; -} - void EveChildBehaviorSystem::Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) { EveChildTransform::Setup( scale, rotation, translation, lowestLodVisible ); @@ -648,10 +643,6 @@ void EveChildBehaviorSystem::GetRenderables( std::vector& rende } } -void EveChildBehaviorSystem::SetName( const char* name ) -{ -} - void EveChildBehaviorSystem::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { if( !m_display ) @@ -665,11 +656,6 @@ void EveChildBehaviorSystem::UpdateVisibility( const EveUpdateContext& updateCon } } -bool EveChildBehaviorSystem::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const -{ - return true; -} - bool EveChildBehaviorSystem::GetInstanceBufferBoundingBox( unsigned int bufferIndex, Vector3& minBounds, Vector3& maxBounds ) const { return false; @@ -679,10 +665,6 @@ void EveChildBehaviorSystem::GetLocalToWorldTransform( Matrix& transform ) const { } -void EveChildBehaviorSystem::ChangeLOD( Tr2Lod lod ) -{ -} - void EveChildBehaviorSystem::RegisterComponents() { if( !m_display ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h index a5a4b4fe3..dcbbac7be 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h @@ -8,7 +8,7 @@ #include "Behaviors/BehaviorGroup.h" #include "Behaviors/SplineTunnelGroup.h" #include "Tr2DeviceResource.h" -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "TriRenderBatch.h" #include "ITr2Renderable.h" @@ -22,7 +22,7 @@ BLUE_DECLARE_VECTOR( BehaviorGroup ); BLUE_CLASS( EveChildBehaviorSystem ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public Tr2DeviceResource, public ITr2Renderable, public IInitialize, @@ -70,16 +70,11 @@ BLUE_CLASS( EveChildBehaviorSystem ) : { } - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); - bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); - void ChangeLOD( Tr2Lod lod ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -112,7 +107,6 @@ BLUE_CLASS( EveChildBehaviorSystem ) : bool OnPrepareResources(); void PassInVertexesToBehaviorGroups(); void PassInTunnelFunctionsToBehaviorGroups(); - char* m_name; bool m_behaviorGroupLoaded; bool m_behaviorGroupLoadedForTunnel; diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp index 7737739c7..1f34f4581 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp @@ -8,6 +8,7 @@ const Be::ClassInfo* EveChildBehaviorSystem::ExposeToBlue() { EXPOSURE_BEGIN( EveChildBehaviorSystem, "" ) MAP_INTERFACE( EveChildBehaviorSystem ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( INotify ) @@ -30,5 +31,8 @@ const Be::ClassInfo* EveChildBehaviorSystem::ExposeToBlue() GetVertexElementAddedThroughCode, "for validation and objects requiring vertex elements added to the shader through code\n:jessica-hidden: True" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp index ddb989ae1..062f2e4d2 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp @@ -77,18 +77,6 @@ bool EveChildBulletStorm::OnModified( Be::Var* val ) return true; } -// -------------------------------------------------------------------------------- -const char* EveChildBulletStorm::GetName() const -{ - return m_name.c_str(); -} - -// -------------------------------------------------------------------------------- -void EveChildBulletStorm::SetName( const char* name ) -{ - m_name = name; -} - // -------------------------------------------------------------------------------- // Description: // Trinity's way of rendering @@ -223,14 +211,6 @@ bool EveChildBulletStorm::GetBoundingSphere( Vector4& sphere, BoundingSphereQuer return true; } -// -------------------------------------------------------------------------------- -// Description: -// Syncronous updates happen here -// -------------------------------------------------------------------------------- -void EveChildBulletStorm::UpdateSyncronous( const EveUpdateContext&, const EveChildUpdateParams& ) -{ -} - void EveChildBulletStorm::StartEffect() { m_clipShereMul = 1.0f; @@ -317,14 +297,6 @@ void EveChildBulletStorm::GetLocalToWorldTransform( Matrix& transform ) const transform = m_worldTransform; } -// -------------------------------------------------------------------------------- -// Description: -// Used by state machine to animate state-related stuff -// -------------------------------------------------------------------------------- -void EveChildBulletStorm::Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) -{ -} - // -------------------------------------------------------------------------------- // Description: // Nothing transparent here, all additive! diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h index f78c16289..52f1c3df3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h @@ -4,7 +4,7 @@ #ifndef EveChildBulletStorm_H #define EveChildBulletStorm_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "ITr2Renderable.h" #include "Eve/SpaceObject/EveSpaceObject2.h" @@ -34,7 +34,7 @@ class EveChildBulletStormPerObjectData : public Tr2PerObjectData // A spaceobject child for rendering swarm like bullets // -------------------------------------------------------------------------------- BLUE_CLASS( EveChildBulletStorm ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2Renderable, public Tr2DeviceResource, public INotify, @@ -55,19 +55,11 @@ BLUE_CLASS( EveChildBulletStorm ) : bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) - { - } + // EveSpaceObjectChild void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ) {}; - void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable @@ -93,7 +85,6 @@ BLUE_CLASS( EveChildBulletStorm ) : private: // general data - std::string m_name; bool m_display; // Has UpdateSyncronous/UpdateAsyncronous been called: until it has, the object cannot be rendered bool m_hasUpdated = false; diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp index 86ba7b4a1..8b51cae94 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveChildBulletStorm::ExposeToBlue() { EXPOSURE_BEGIN( EveChildBulletStorm, "" ) MAP_INTERFACE( EveChildBulletStorm ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( INotify ) @@ -35,5 +36,8 @@ const Be::ClassInfo* EveChildBulletStorm::ExposeToBlue() MAP_METHOD_AND_WRAP( "StopEffect", StopEffect, "Stop Effect" ) MAP_METHOD_AND_WRAP( "CanChangeState", CanChangeState, "Can start or stop the effect without visual errors?" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp index c80462793..83fb8f5ca 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp @@ -208,16 +208,6 @@ bool EveChildCloud::OnModified( Be::Var* value ) return true; } -const char* EveChildCloud::GetName() const -{ - return m_name.c_str(); -} - -void EveChildCloud::SetName( const char* name ) -{ - m_name = name; -} - void EveChildCloud::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { auto& frustum = updateContext.GetFrustum(); diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud.h b/trinity/Eve/SpaceObject/Children/EveChildCloud.h index f6c107e28..27bfa4671 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud.h +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud.h @@ -6,7 +6,7 @@ #include "ITr2Renderable.h" #include "Eve/IEveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Tr2ShLightingManager.h" #include "Tr2DebugRenderer.h" @@ -24,7 +24,7 @@ BLUE_CLASS( EveChildCloud ) : public Tr2DeviceResource, public IInitialize, public INotify, - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2DebugRenderable { public: @@ -42,19 +42,13 @@ BLUE_CLASS( EveChildCloud ) : virtual bool OnModified( Be::Var * value ); ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - virtual const char* GetName() const; - virtual void SetName( const char* name ); + // EveSpaceObjectChild virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); virtual void GetLocalToWorldTransform( Matrix & transform ) const; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); virtual void GetRenderables( std::vector & renderables ); virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) - { - } - virtual void ChangeLOD( Tr2Lod lod ) {}; ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable @@ -94,7 +88,6 @@ BLUE_CLASS( EveChildCloud ) : Tr2BufferAL m_vertexBuffer; TrackableStdVector m_indexBuffers; - std::string m_name; bool m_display; bool m_isVisible; // Has UpdateSyncronous/UpdateAsyncronous been called: until it has, the object cannot be rendered diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp index 3e48803ae..ba6334b74 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp @@ -205,24 +205,6 @@ bool EveChildCloud2::OnModified( Be::Var* value ) return true; } -const char* EveChildCloud2::GetName() const -{ - return m_name.c_str(); -} - -void EveChildCloud2::SetName( const char* name ) -{ - m_name = name; -} - -void EveChildCloud2::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) -{ -} - -void EveChildCloud2::GetRenderables( std::vector& ) -{ -} - bool EveChildCloud2::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery ) const { sphere = Vector4( m_boundingSphere.center, m_boundingSphere.radius ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2.h b/trinity/Eve/SpaceObject/Children/EveChildCloud2.h index 9dce9cbbb..d641b48f4 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2.h +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2.h @@ -4,7 +4,7 @@ #include "ITr2Renderable.h" #include "Eve/IEveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Tr2DebugRenderer.h" #include "Tr2DepthStencil.h" #include "TriFrustumOrtho.h" @@ -27,12 +27,12 @@ BLUE_DECLARE( Tr2TextureAnimation ); // plane at the back of the object's bounding sphere using provided effect. // -------------------------------------------------------------------------------- BLUE_CLASS( EveChildCloud2 ) : + public EveSpaceObjectChild, public ITr2VolumetricRenderable, public Tr2DeviceResource, public IInitialize, public INotify, public IListNotify, - public IEveSpaceObjectChild, public ITr2DebugRenderable, public ITr2Renderable, public ITr2LightOwner, @@ -57,21 +57,11 @@ BLUE_CLASS( EveChildCloud2 ) : void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - virtual const char* GetName() const override; - virtual void SetName( const char* name ) override; + // EveSpaceObjectChild virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; virtual void GetLocalToWorldTransform( Matrix & transform ) const override; - virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - virtual void GetRenderables( std::vector & renderables ) override; virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; - virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override - { - } - virtual void ChangeLOD( Tr2Lod lod ) override - { - } ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner @@ -189,7 +179,6 @@ BLUE_CLASS( EveChildCloud2 ) : Tr2DepthStencilPtr m_shadowMapDS; TriVariable* m_depthShadowMapHandle; - std::string m_name; bool m_display; bool m_castShadows; bool m_receiveShadows; diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp index c4245e970..b9b921289 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp @@ -15,6 +15,7 @@ const Be::ClassInfo* EveChildCloud2::ExposeToBlue() MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( ITr2LightOwner ) @@ -65,5 +66,8 @@ const Be::ClassInfo* EveChildCloud2::ExposeToBlue() MAP_ATTRIBUTE( "mapOffset1", m_mapOffsets[1], "Texture offset 1. Used for debugging camera-attached clouds.\n:jessica-group: Tiling", Be::READ ) MAP_ATTRIBUTE( "mapOffset2", m_mapOffsets[2], "Texture offset 2. Used for debugging camera-attached clouds.\n:jessica-group: Tiling", Be::READ ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp index be2b2c06b..7e02f2205 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp @@ -13,6 +13,7 @@ const Be::ClassInfo* EveChildCloud::ExposeToBlue() MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_ATTRIBUTE( "name", m_name, "The name of the cloud", Be::READWRITE | Be::PERSIST ) @@ -36,5 +37,8 @@ const Be::ClassInfo* EveChildCloud::ExposeToBlue() MAP_ATTRIBUTE( "cellScreenSize", m_cellScreenSize, "Target size of a single cell in a grid on the screen (in pixels)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "currentLod", m_currentIB, "Current cloud LOD", Be::READ ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp b/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp index a0641cb6b..5f29c6b90 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp @@ -59,10 +59,12 @@ EveChildContainer::~EveChildContainer() { controller->Unlink( UnlinkReason::DELETING ); } + UnregisterChildren( m_objects ); } bool EveChildContainer::Initialize() { + RegisterChildren( m_objects ); for( auto& controller : m_controllers ) { if( !controller->IsLinked() ) @@ -142,6 +144,8 @@ void EveChildContainer::OnListModified( long event, ssize_t key, ssize_t key2, I } else if( list == &m_objects && ( event & BELIST_LOADING ) == 0 ) { + HandleChildrenListModified( event, value, m_objects ); + if( IsInRegistry() ) { switch( event & BELIST_EVENTMASK ) @@ -314,7 +318,7 @@ void EveChildContainer::SetShaderOption( const BlueSharedString& name, const Blu { for( auto it = m_objects.begin(); it != m_objects.end(); ++it ) { - IEveSpaceObjectChild* child = *it; + EveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } @@ -366,16 +370,6 @@ bool EveChildContainer::IsUpdating() const return ( m_display || !m_updateOnDisplay ) && ( IsRendering() || m_displayFilter == ONLY_REFLECTIONS ); } -const char* EveChildContainer::GetName() const -{ - return m_name.c_str(); -} - -void EveChildContainer::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildContainer::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { if( !m_display ) @@ -442,7 +436,7 @@ bool EveChildContainer::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if( ( *it )->GetBoundingSphere( bSphere ) ) + if( ( *it )->GetBoundingSphere( bSphere, EVE_BOUNDS_NORMAL ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -966,7 +960,7 @@ void EveChildContainer::StartControllers() } } -IEveSpaceObjectChildPtr EveChildContainer::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildContainer::GetEffectChildByName( const char* name ) const { for( auto it = begin( m_objects ); it != end( m_objects ); ++it ) { @@ -979,7 +973,7 @@ IEveSpaceObjectChildPtr EveChildContainer::GetEffectChildByName( const char* nam return nullptr; } -void EveChildContainer::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildContainer::AddToEffectChildrenList( EveSpaceObjectChild* child ) { auto childRoot = child->GetRootObject(); m_objects.Append( childRoot ); @@ -993,7 +987,7 @@ void EveChildContainer::AddToEffectChildrenList( IEveSpaceObjectChild* child ) } } -void EveChildContainer::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildContainer::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { auto index = m_objects.FindKey( child ); if( index >= 0 ) @@ -1111,6 +1105,30 @@ void EveChildContainer::SetProceduralContainerVariable( const char* name, float } } +void EveChildContainer::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + for( auto& child : m_objects ) + { + child->SetOwner( owner ); + } + } +} + +void EveChildContainer::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + for( auto& child : m_objects ) + { + child->SetPartTag( tag ); + } + } +} + void EveChildContainer::SetAnimationOwner( ITr2GrannyAnimationOwner* animationOwner ) { m_animationOwner = animationOwner; diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer.h b/trinity/Eve/SpaceObject/Children/EveChildContainer.h index e8bdeac85..7fa1faa73 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer.h @@ -4,7 +4,7 @@ #ifndef EveChildContainer_H #define EveChildContainer_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -31,7 +31,7 @@ BLUE_DECLARE_INTERFACE( IEveFxAttribute ); BLUE_DECLARE_IVECTOR( IEveFxAttribute ); BLUE_CLASS( EveChildContainer ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public ITr2CurveSetOwner, @@ -66,17 +66,19 @@ BLUE_CLASS( EveChildContainer ) : virtual bool OnModified( Be::Var * val ); ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + // EveSpaceObjectChild void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; bool IsAlwaysOn() const override; void AddTransformModifier( IEveChildTransformModifier * modifier ) override; void SetProceduralContainerVariable( const char* name, float value ) override; + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -111,9 +113,6 @@ BLUE_CLASS( EveChildContainer ) : uint32_t GetPerObjectDataSize( Tr2RenderContextEnum::ShaderType shaderType ) const; void UpdatePerObjectBuffer( Tr2RenderContextEnum::ShaderType shaderType, uint32_t size, void* ); - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -171,7 +170,7 @@ BLUE_CLASS( EveChildContainer ) : bool Empty() const; - PIEveSpaceObjectChildVector m_objects; + PEveSpaceObjectChildVector m_objects; protected: void DoUpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); @@ -183,7 +182,6 @@ BLUE_CLASS( EveChildContainer ) : bool HasRenderables() const; - BlueSharedString m_name; PTriCurveSetVector m_curveSets; PTriObserverLocalVector m_observers; PTr2LightVector m_lights; diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp index 9e345bbf3..42ac5b7c3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp @@ -5,11 +5,11 @@ Be::VarChooser EveSpaceObjectChildOriginChooser[] = { - { "SPACE", BeCast( IEveSpaceObjectChild::SPACE ), "Origin in Space" }, - { "SOF", BeCast( IEveSpaceObjectChild::SOF ), "Origin in SOF" }, + { "SPACE", BeCast( EveSpaceObjectChild::SPACE ), "Origin in Space" }, + { "SOF", BeCast( EveSpaceObjectChild::SOF ), "Origin in SOF" }, { 0 } }; -BLUE_REGISTER_ENUM_EX( "EveSpaceObjectChildOrigin", IEveSpaceObjectChild::Origin, EveSpaceObjectChildOriginChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); +BLUE_REGISTER_ENUM_EX( "EveSpaceObjectChildOrigin", EveSpaceObjectChild::Origin, EveSpaceObjectChildOriginChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); Be::VarChooser EveChildContainerDataSetShaderChooser[] = { { "None_", BeCast( EveChildContainer::SHADER_ALL ), "Visible to users with all shader settings" }, @@ -33,6 +33,7 @@ const Be::ClassInfo* EveChildContainer::ExposeToBlue() MAP_INTERFACE( EveChildContainer ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( ITr2LightOwner ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -106,5 +107,8 @@ const Be::ClassInfo* EveChildContainer::ExposeToBlue() StartControllers, "Start all controllers" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp index dc5824371..a2091ca8c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp @@ -39,6 +39,7 @@ EveChildEffectPropagator::EveChildEffectPropagator( IRoot* lockobj ) : EveChildEffectPropagator::~EveChildEffectPropagator() { + UnregisterChild( m_effect ); } @@ -130,6 +131,7 @@ void EveChildEffectPropagator::Stop() bool EveChildEffectPropagator::Initialize() { + RegisterChild( m_effect ); if( m_effect != nullptr ) { m_effect->DisableEditMode( true ); @@ -168,7 +170,7 @@ void EveChildEffectPropagator::ManageTriggers() // -------------------------------------------- // Description: -// Implements IEveSpaceObjectChild interface. +// Implements EveSpaceObjectChild interface. // -------------------------------------------- void EveChildEffectPropagator::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { @@ -646,10 +648,12 @@ void EveChildEffectPropagator::SetEffect( EveChildInstanceContainer* effect ) { // unregister the current effect UnRegisterComponents(); + UnregisterChild( m_effect ); m_effect = effect; // register again + RegisterChild( m_effect ); RegisterComponents(); } diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h index 12deb0d46..f4287aafe 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h @@ -98,7 +98,6 @@ BLUE_CLASS( EveChildEffectPropagator ) : float m_playTime; EveChildInstanceContainerPtr m_effect; // Child containing trigger effect - IEveSpaceObjectChildPtr m_effectShared; // Child containing shared parts of the effect (particle systems etc.) Vector3 m_effectScaling; float m_randScaleMin; diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp index 2391292dc..deca8722c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp @@ -27,6 +27,7 @@ const Be::ClassInfo* EveChildEffectPropagator::ExposeToBlue() EXPOSURE_BEGIN( EveChildEffectPropagator, "Specialized explosion propagator object child" ) MAP_INTERFACE( EveChildEffectPropagator ) MAP_INTERFACE( EveChildContainer ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( INotify ) MAP_INTERFACE( EveEntity ) @@ -72,5 +73,8 @@ const Be::ClassInfo* EveChildEffectPropagator::ExposeToBlue() MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform." ) MAP_METHOD_AND_WRAP( "Stop", Stop, "Stops effect playback.\n:jessica-favorite:\n:jessica-icon: timeline/stop.png" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp b/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp index a252e4579..a08bd47bb 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp @@ -174,7 +174,7 @@ void EveChildExplosion::SetGlobalExplosionOffset( const Vector3& offset ) // -------------------------------------------------------------------------------------- // Description: -// Implements IEveSpaceObjectChild interface. If the effect is playing this function +// Implements EveSpaceObjectChild interface. If the effect is playing this function // spawns explosions. // -------------------------------------------------------------------------------------- void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) @@ -224,7 +224,7 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, { if( m_globalExplosionInstances.empty() ) { - IEveSpaceObjectChildPtr instance; + EveSpaceObjectChildPtr instance; if( BeClasses->CopyTo( m_globalExplosion, (IRoot**)&instance.p ) ) { Quaternion rotation = Quaternion( 0.0, 0.0, 0.0, 1.0 ); @@ -261,7 +261,7 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, for( auto it = m_globalExplosions.begin(); it != m_globalExplosions.end(); ++it ) { auto globalExplosion = ( *it ); - IEveSpaceObjectChildPtr instance; + EveSpaceObjectChildPtr instance; if( BeClasses->CopyTo( globalExplosion, (IRoot**)&instance.p ) ) { m_globalExplosionContainer->m_objects.Append( instance ); @@ -460,7 +460,7 @@ void EveChildExplosion::SpawnLocalExplosion( const Matrix& transform ) { return; } - IEveSpaceObjectChildPtr instance; + EveSpaceObjectChildPtr instance; Transform t; Vector3 scale; diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion.h b/trinity/Eve/SpaceObject/Children/EveChildExplosion.h index 42953d774..4362c0319 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion.h +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion.h @@ -74,14 +74,14 @@ BLUE_CLASS( EveChildExplosion ) : // Child containing local explosion effect - IEveSpaceObjectChildPtr m_localExplosion; - PIEveSpaceObjectChildVector m_localExplosions; + EveSpaceObjectChildPtr m_localExplosion; + PEveSpaceObjectChildVector m_localExplosions; // Child containing shared parts of the local explosion effect (particle systems etc.) - IEveSpaceObjectChildPtr m_localExplosionShared; + EveSpaceObjectChildPtr m_localExplosionShared; // Child containing global explosion effect - IEveSpaceObjectChildPtr m_globalExplosion; - PIEveSpaceObjectChildVector m_globalExplosions; - PIEveSpaceObjectChildVector m_globalExplosionInstances; + EveSpaceObjectChildPtr m_globalExplosion; + PEveSpaceObjectChildVector m_globalExplosions; + PEveSpaceObjectChildVector m_globalExplosionInstances; EveChildContainerPtr m_globalExplosionContainer; // Transforms for local explosions diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp index 4a8777e78..e694d8237 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp @@ -12,6 +12,7 @@ const Be::ClassInfo* EveChildExplosion::ExposeToBlue() MAP_INTERFACE( EveChildExplosion ) MAP_INTERFACE( EveChildContainer ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) @@ -141,5 +142,8 @@ const Be::ClassInfo* EveChildExplosion::ExposeToBlue() "Sets the global explosion offset.\n" ":param offset: Vector3 that to be used as the global explosion offset should be in local coordinates" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.cpp b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.cpp index 15f13fbe3..92f9dafbd 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.cpp @@ -77,21 +77,7 @@ void EveChildFogVolume::UnRegisterComponents() } ///////////////////////////////////////////////////////////////////////////////////// -// IEveSpaceObjectChild -const char* EveChildFogVolume::GetName() const -{ - return m_name.c_str(); -} - -void EveChildFogVolume::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - -void EveChildFogVolume::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) -{ -} - +// EveSpaceObjectChild bool EveChildFogVolume::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { sphere.GetXYZ() = m_boundingSphere.center; @@ -100,10 +86,6 @@ bool EveChildFogVolume::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery return true; } -void EveChildFogVolume::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) -{ -} - void EveChildFogVolume::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { UpdateTransformFromParent( params ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h index 9e1d49362..86293a9f2 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h +++ b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "ITr2Renderable.h" #include "Tr2DebugRenderer.h" @@ -14,7 +14,7 @@ BLUE_DECLARE_IVECTOR( IEveVolume ); BLUE_CLASS( EveChildFogVolume ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public IInitialize, public ITr2DebugRenderable, @@ -29,19 +29,12 @@ BLUE_CLASS( EveChildFogVolume ) : void RebuildBoundingSphere(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - void GetRenderables( std::vector & renderables ) override{}; + // EveSpaceObjectChild bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query ) const override; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; - void ChangeLOD( Tr2Lod lod ) override {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; bool IsAlwaysOn() const override; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override {}; void RegisterComponents() override; void UnRegisterComponents() override; @@ -62,7 +55,6 @@ BLUE_CLASS( EveChildFogVolume ) : private: void UpdateTransformFromParent( const EveChildUpdateParams& params ); - BlueSharedString m_name; PIEveVolumeVector m_volumes; float m_intensity; diff --git a/trinity/Eve/SpaceObject/Children/EveChildFogVolume_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildFogVolume_Blue.cpp index 76f0c2582..cf5c6097c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildFogVolume_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildFogVolume_Blue.cpp @@ -11,6 +11,7 @@ const Be::ClassInfo* EveChildFogVolume::ExposeToBlue() EXPOSURE_BEGIN( EveChildFogVolume, "" ) MAP_INTERFACE( ITr2FroxelFogSettings ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) @@ -54,6 +55,8 @@ const Be::ClassInfo* EveChildFogVolume::ExposeToBlue() MAP_ATTRIBUTE( "boundingSphereCenter", m_boundingSphere.center, "", Be::READ ) MAP_ATTRIBUTE( "boundingSphereRadius", m_boundingSphere.radius, "", Be::READ ) MAP_ATTRIBUTE( "volumes", m_volumes, "", Be::READ | Be::PERSIST ) - + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp index 0d67cf3f0..e20b56091 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp @@ -54,16 +54,8 @@ EveChildInstanceContainer::EveChildInstanceContainer( IRoot* lockobj ) : EveChildInstanceContainer::~EveChildInstanceContainer() { -} - -const char* EveChildInstanceContainer::GetName() const -{ - return m_name.c_str(); -} - -void EveChildInstanceContainer::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); + UnregisterChildren( m_instances ); + UnregisterChild( m_source ); } bool EveChildInstanceContainer::OnModified( Be::Var* value ) @@ -121,25 +113,27 @@ void EveChildInstanceContainer::UnRegisterComponents() } } -void EveChildInstanceContainer::SetSourceEffect( IEveSpaceObjectChildPtr sourceEffect ) +void EveChildInstanceContainer::SetSourceEffect( EveSpaceObjectChildPtr sourceEffect ) { SetSource( sourceEffect ); m_reset = true; } -IEveSpaceObjectChildPtr EveChildInstanceContainer::GetSource() +EveSpaceObjectChildPtr EveChildInstanceContainer::GetSource() { return m_source; } -void EveChildInstanceContainer::SetSource( IEveSpaceObjectChild* source ) +void EveChildInstanceContainer::SetSource( EveSpaceObjectChild* source ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_source ) ) { entity->UnRegister( registry ); } + UnregisterChild( m_source ); m_source = source; + RegisterChild( m_source ); if( m_instances.empty() && !m_disableEditMode ) { if( EveEntityPtr entity = BlueCastPtr( m_source ) ) @@ -247,7 +241,7 @@ void EveChildInstanceContainer::CreateInstance( const Vector3& scale, const Quat EveChildContainerPtr translationParent; translationParent.CreateInstance(); - IEveSpaceObjectChildPtr instance; + EveSpaceObjectChildPtr instance; if( !BeClasses->CopyTo( m_source, (IRoot**)&instance ) ) { @@ -280,14 +274,20 @@ void EveChildInstanceContainer::CreateInstance( const Vector3& scale, const Quat boneParent->AddToEffectChildrenList( translationParent ); boneParent->RegisterWithQuadRenderer( *Tr2QuadRenderer::Instance() ); boneParent->Register( GetComponentRegistry() ); + boneParent->SetOwner( GetOwner() ); + boneParent->SetParent( this ); + boneParent->SetPartTag( GetPartTag() ); - m_instances.Append( (IEveSpaceObjectChildPtr)boneParent ); + m_instances.Append( boneParent->GetRawRoot() ); } else { translationParent->RegisterWithQuadRenderer( *Tr2QuadRenderer::Instance() ); translationParent->Register( GetComponentRegistry() ); - m_instances.Append( (IEveSpaceObjectChildPtr)translationParent ); + translationParent->SetOwner( GetOwner() ); + translationParent->SetParent( this ); + translationParent->SetPartTag( GetPartTag() ); + m_instances.Append( translationParent->GetRawRoot() ); } return; @@ -300,7 +300,7 @@ void EveChildInstanceContainer::CreateInstance( const Vector3& scale, const Quat // -------------------------------------------------------------------------------------- void EveChildInstanceContainer::UpdateInstance( const uint32_t index, const Vector3& scale, const Quaternion& rotation, const Vector3& translation ) { - auto instance = (IEveSpaceObjectChild*)m_instances.GetAt( index ); + auto instance = static_cast( m_instances.GetAt( index ) ); if( instance == nullptr ) { return; @@ -313,9 +313,9 @@ void EveChildInstanceContainer::UpdateInstance( const uint32_t index, const Vect // A helper method to run a function on the source (if the instances are not valid) or // on the instances // Arguments: -// func - The function to run, takes a single parameter which is an IEveSpaceObjectChild* +// func - The function to run, takes a single parameter which is an EveSpaceObjectChild* // -------------------------------------------------------------------------------------- -void EveChildInstanceContainer::RunOnInstances( std::function func ) const +void EveChildInstanceContainer::RunOnInstances( std::function func ) const { if( m_instances.empty() && m_source && !m_disableEditMode ) { @@ -339,6 +339,7 @@ void EveChildInstanceContainer::DisableEditMode( bool disable ) void EveChildInstanceContainer::ClearInstanceList() { UnRegisterComponents(); + UnregisterChildren( m_instances ); m_instances.Clear(); } @@ -353,7 +354,8 @@ void EveChildInstanceContainer::PopFront() front->UnRegister( GetComponentRegistry() ); } } - + m_instances[0]->SetOwner( nullptr ); + m_instances[0]->SetParent( nullptr ); m_instances.Remove( 0 ); } } @@ -370,7 +372,7 @@ void EveChildInstanceContainer::GetRenderables( std::vector& re return; } - RunOnInstances( [&renderables]( IEveSpaceObjectChild* c ) { c->GetRenderables( renderables ); } ); + RunOnInstances( [&renderables]( EveSpaceObjectChild* c ) { c->GetRenderables( renderables ); } ); } @@ -381,7 +383,7 @@ void EveChildInstanceContainer::UpdateVisibility( const EveUpdateContext& update return; } - RunOnInstances( [&updateContext, &parentTransform, parentLod]( IEveSpaceObjectChild* c ) { c->UpdateVisibility( updateContext, parentTransform, parentLod ); } ); + RunOnInstances( [&updateContext, &parentTransform, parentLod]( EveSpaceObjectChild* c ) { c->UpdateVisibility( updateContext, parentTransform, parentLod ); } ); } void EveChildInstanceContainer::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) @@ -405,7 +407,7 @@ void EveChildInstanceContainer::UpdateSyncronous( const EveUpdateContext& update newParams.childParent = this; newParams.localToWorldTransform = m_worldTransform; - RunOnInstances( [&updateContext, &newParams]( IEveSpaceObjectChild* c ) { c->UpdateSyncronous( updateContext, newParams ); } ); + RunOnInstances( [&updateContext, &newParams]( EveSpaceObjectChild* c ) { c->UpdateSyncronous( updateContext, newParams ); } ); } void EveChildInstanceContainer::AddTransformModifier( IEveChildTransformModifier* modifier ) @@ -430,7 +432,7 @@ void EveChildInstanceContainer::UpdateAsyncronous( const EveUpdateContext& updat newParams.childParent = this; newParams.localToWorldTransform = m_worldTransform; - RunOnInstances( [&updateContext, &newParams]( IEveSpaceObjectChild* c ) { c->UpdateAsyncronous( updateContext, newParams ); } ); + RunOnInstances( [&updateContext, &newParams]( EveSpaceObjectChild* c ) { c->UpdateAsyncronous( updateContext, newParams ); } ); if( params.spaceObjectParent && !params.childParent ) @@ -458,7 +460,7 @@ bool EveChildInstanceContainer::GetBoundingSphere( Vector4& sphere, BoundingSphe return true; } - RunOnInstances( [&sphere, &query]( IEveSpaceObjectChild* c ) { c->GetBoundingSphere( sphere, query ); } ); + RunOnInstances( [&sphere, &query]( EveSpaceObjectChild* c ) { c->GetBoundingSphere( sphere, query ); } ); return true; } @@ -473,12 +475,12 @@ void EveChildInstanceContainer::RegisterWithQuadRenderer( Tr2QuadRenderer& quadR void EveChildInstanceContainer::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const { - RunOnInstances( [&frustum, &quadRenderer]( IEveSpaceObjectChild* c ) { c->AddQuadsToQuadRenderer( frustum, quadRenderer ); } ); + RunOnInstances( [&frustum, &quadRenderer]( EveSpaceObjectChild* c ) { c->AddQuadsToQuadRenderer( frustum, quadRenderer ); } ); } void EveChildInstanceContainer::ChangeLOD( Tr2Lod lod ) { - RunOnInstances( [&lod]( IEveSpaceObjectChild* c ) { c->ChangeLOD( lod ); } ); + RunOnInstances( [&lod]( EveSpaceObjectChild* c ) { c->ChangeLOD( lod ); } ); } void EveChildInstanceContainer::SetOrigin( Origin origin ) @@ -488,7 +490,7 @@ void EveChildInstanceContainer::SetOrigin( Origin origin ) void EveChildInstanceContainer::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - RunOnInstances( [&name, &value]( IEveSpaceObjectChild* c ) { c->SetShaderOption( name, value ); } ); + RunOnInstances( [&name, &value]( EveSpaceObjectChild* c ) { c->SetShaderOption( name, value ); } ); } bool EveChildInstanceContainer::IsAlwaysOn() const @@ -509,18 +511,18 @@ void EveChildInstanceContainer::GetWorldVelocity( Vector3& velocity ) const velocity = m_worldVelocity; } -IEveSpaceObjectChildPtr EveChildInstanceContainer::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildInstanceContainer::GetEffectChildByName( const char* name ) const { // don't really know what to do here... return nullptr; } -void EveChildInstanceContainer::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildInstanceContainer::AddToEffectChildrenList( EveSpaceObjectChild* child ) { // do nothing for now } -void EveChildInstanceContainer::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildInstanceContainer::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { // do nothing for now } @@ -540,17 +542,17 @@ void EveChildInstanceContainer::SetControllerVariable( const char* name, float v { found->second = value; } - RunOnInstances( [&name, &value]( IEveSpaceObjectChild* c ) { c->SetControllerVariable( name, value ); } ); + RunOnInstances( [&name, &value]( EveSpaceObjectChild* c ) { c->SetControllerVariable( name, value ); } ); } void EveChildInstanceContainer::HandleControllerEvent( const char* name ) { - RunOnInstances( [name]( IEveSpaceObjectChild* c ) { c->HandleControllerEvent( name ); } ); + RunOnInstances( [name]( EveSpaceObjectChild* c ) { c->HandleControllerEvent( name ); } ); } void EveChildInstanceContainer::StartControllers() { - RunOnInstances( []( IEveSpaceObjectChild* c ) { c->StartControllers(); } ); + RunOnInstances( []( EveSpaceObjectChild* c ) { c->StartControllers(); } ); } void EveChildInstanceContainer::SetControllerVariableForInstance( const uint32_t index, const char* name, float value ) @@ -577,7 +579,7 @@ void EveChildInstanceContainer::HandleControllerEventForInstance( const uint32_t void EveChildInstanceContainer::PlayCurveSet( const std::string& name, const std::string& rangeName ) { - RunOnInstances( [&name, &rangeName]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&name, &rangeName]( EveSpaceObjectChild* c ) { ITr2CurveSetOwnerPtr cso = BlueCastPtr( c->GetRootObject() ); if( cso != nullptr ) { @@ -588,7 +590,7 @@ void EveChildInstanceContainer::PlayCurveSet( const std::string& name, const std void EveChildInstanceContainer::StopCurveSet( const std::string& name ) { - RunOnInstances( [&name]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&name]( EveSpaceObjectChild* c ) { ITr2CurveSetOwnerPtr cso = BlueCastPtr( c->GetRootObject() ); if( cso != nullptr ) @@ -600,7 +602,7 @@ void EveChildInstanceContainer::StopCurveSet( const std::string& name ) void EveChildInstanceContainer::UpdateCurveSet( const std::string& name, Be::Time time ) { - RunOnInstances( [&name, time]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&name, time]( EveSpaceObjectChild* c ) { ITr2CurveSetOwnerPtr cso = BlueCastPtr( c->GetRootObject() ); if( cso != nullptr ) { @@ -635,7 +637,7 @@ float EveChildInstanceContainer::GetRangeDuration( const std::string& name, cons void EveChildInstanceContainer::PlayAllCurveSets() { - RunOnInstances( []( IEveSpaceObjectChild* c ) { + RunOnInstances( []( EveSpaceObjectChild* c ) { EveChildContainerPtr cc = BlueCastPtr( c->GetRootObject() ); if( cc != nullptr ) { @@ -646,7 +648,7 @@ void EveChildInstanceContainer::PlayAllCurveSets() void EveChildInstanceContainer::StopAllCurveSets() { - RunOnInstances( []( IEveSpaceObjectChild* c ) { + RunOnInstances( []( EveSpaceObjectChild* c ) { EveChildContainerPtr cc = BlueCastPtr( c->GetRootObject() ); if( cc != nullptr ) { @@ -657,7 +659,7 @@ void EveChildInstanceContainer::StopAllCurveSets() void EveChildInstanceContainer::GetDebugOptions( Tr2DebugRendererOptions& options ) { - RunOnInstances( [&options]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&options]( EveSpaceObjectChild* c ) { if( auto dr = dynamic_cast( c ) ) { dr->GetDebugOptions( options ); @@ -667,10 +669,42 @@ void EveChildInstanceContainer::GetDebugOptions( Tr2DebugRendererOptions& option void EveChildInstanceContainer::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - RunOnInstances( [&renderer]( IEveSpaceObjectChild* c ) { + RunOnInstances( [&renderer]( EveSpaceObjectChild* c ) { if( auto dr = dynamic_cast( c ) ) { dr->RenderDebugInfo( renderer ); } } ); } + +void EveChildInstanceContainer::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + for( auto& child : m_instances ) + { + child->SetOwner( owner ); + } + if( m_source ) + { + m_source->SetOwner( owner ); + } + } +} + +void EveChildInstanceContainer::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + for( auto& child : m_instances ) + { + child->SetPartTag( tag ); + } + if( m_source ) + { + m_source->SetPartTag( tag ); + } + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h index 42fce1a86..9da27de71 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -28,11 +28,11 @@ BLUE_DECLARE( EveChildInheritProperties ); // -------------------------------------------------------------------------------------- // Description: -// A child container that copies a source IEveSpaceObjectChild across locatorsets +// A child container that copies a source EveSpaceObjectChild across locatorsets // and or transforms // -------------------------------------------------------------------------------------- BLUE_CLASS( EveChildInstanceContainer ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2CurveSetOwner, public INotify, public IEveEffectChildrenOwner, @@ -53,9 +53,7 @@ BLUE_CLASS( EveChildInstanceContainer ) : float GetOwnerMaxSpeed() const; ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -73,12 +71,14 @@ BLUE_CLASS( EveChildInstanceContainer ) : void GetWorldVelocity( Vector3 & velocity ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); void AddTransformModifier( IEveChildTransformModifier * modifier ) override; + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -125,19 +125,18 @@ BLUE_CLASS( EveChildInstanceContainer ) : void PopFront(); void DisableEditMode( bool disable ); - void SetSourceEffect( IEveSpaceObjectChildPtr sourceEffect ); + void SetSourceEffect( EveSpaceObjectChildPtr sourceEffect ); void AddInstanceTransform( const Vector3& scale, const Quaternion& rotation, const Vector3& translation, int32_t boneIndex = -1 ); void UpdateInstance( const uint32_t index, const Vector3& scale, const Quaternion& rotation, const Vector3& translation ); - IEveSpaceObjectChildPtr GetSource(); - void SetSource( IEveSpaceObjectChild * source ); + EveSpaceObjectChildPtr GetSource(); + void SetSource( EveSpaceObjectChild * source ); protected: void CreateInstances( IEveSpaceObject2 * parent ); - void RunOnInstances( std::function func ) const; + void RunOnInstances( std::function func ) const; protected: - BlueSharedString m_name; Vector3 m_worldVelocity; float m_ownerMaxSpeed; bool m_display; @@ -152,8 +151,8 @@ BLUE_CLASS( EveChildInstanceContainer ) : Origin m_origin; std::vector> m_controllerVariables; - IEveSpaceObjectChildPtr m_source; - PIEveSpaceObjectChildVector m_instances; + EveSpaceObjectChildPtr m_source; + PEveSpaceObjectChildVector m_instances; bool m_reset; BlueSharedString m_locatorSetName; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp index 1dd3207d2..4dc4f8e1e 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp @@ -6,61 +6,66 @@ BLUE_DEFINE( EveChildInstanceContainer ); BLUE_DECLARE_INTERFACE( ITr2DebugRenderable ); -const Be::ClassInfo* EveChildInstanceContainer::ExposeToBlue() { +const Be::ClassInfo* EveChildInstanceContainer::ExposeToBlue() +{ EXPOSURE_BEGIN( EveChildInstanceContainer, "" ) MAP_INTERFACE( EveChildInstanceContainer ) - MAP_INTERFACE( IEveSpaceObjectChild ) - MAP_INTERFACE( ITr2CurveSetOwner ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IEveEffectChildrenOwner ) - MAP_INTERFACE( IShaderConfigurer ) - MAP_INTERFACE( ITr2ControllerOwner ) - MAP_INTERFACE( IListNotify ) - MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) + MAP_INTERFACE( IEveSpaceObjectChild ) + MAP_INTERFACE( ITr2CurveSetOwner ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IEveEffectChildrenOwner ) + MAP_INTERFACE( IShaderConfigurer ) + MAP_INTERFACE( ITr2ControllerOwner ) + MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "alwaysOn", m_isAlwaysOn, "If false this will be hidden if a spaceobjects activation strength < 0.5. If True then it is always on.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ); + MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "alwaysOn", m_isAlwaysOn, "If false this will be hidden if a spaceobjects activation strength < 0.5. If True then it is always on.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "inheritProperties", m_inheritProperties, "Properties inherited from the parent ship when loaded through SOF", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "origin", m_origin, "Where did this effect originate from", Be::READ ) + MAP_ATTRIBUTE( "inheritProperties", m_inheritProperties, "Properties inherited from the parent ship when loaded through SOF", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "origin", m_origin, "Where did this effect originate from", Be::READ ) - MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) + MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) - MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "useSRT", m_useSRT, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "useStaticRotation", m_useStaticRotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "useSRT", m_useSRT, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "useStaticRotation", m_useStaticRotation, "", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "SetControllerVariable", - SetControllerVariable, - "Set variable for all applicable controllers\n" - ":param name: variable name\n" - ":param value: new variable value\n" ) + MAP_METHOD_AND_WRAP( + "SetControllerVariable", + SetControllerVariable, + "Set variable for all applicable controllers\n" + ":param name: variable name\n" + ":param value: new variable value\n" ) - MAP_METHOD_AND_WRAP( - "HandleControllerEvent", - HandleControllerEvent, - "Pass an event to controllers\n" - ":param name: event name" ) + MAP_METHOD_AND_WRAP( + "HandleControllerEvent", + HandleControllerEvent, + "Pass an event to controllers\n" + ":param name: event name" ) - MAP_METHOD_AND_WRAP( - "StartControllers", - StartControllers, - "Start all controllers" ) + MAP_METHOD_AND_WRAP( + "StartControllers", + StartControllers, + "Start all controllers" ) - MAP_ATTRIBUTE( "source", m_source, "The sourceObject to instance", Be::PERSISTONLY ) - MAP_PROPERTY( "source", GetSource, SetSource, "The sourceObject to instance" ) + MAP_ATTRIBUTE( "source", m_source, "The sourceObject to instance", Be::PERSISTONLY ) + MAP_PROPERTY( "source", GetSource, SetSource, "The sourceObject to instance" ) - MAP_ATTRIBUTE( "locatorSet", m_locatorSetName, "The name of the locatorset to distribute across", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "reset", m_reset, "Redistributes the source", Be::READWRITE ) - MAP_ATTRIBUTE( "instances", m_instances, "The generated instances\n:jessica-skip-validation:", Be::READ ) - MAP_ATTRIBUTE( "transforms", m_transforms, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, "", Be::READ | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "locatorSet", m_locatorSetName, "The name of the locatorset to distribute across", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "reset", m_reset, "Redistributes the source", Be::READWRITE ) + MAP_ATTRIBUTE( "instances", m_instances, "The generated instances\n:jessica-skip-validation:", Be::READ ) + MAP_ATTRIBUTE( "transforms", m_transforms, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, "", Be::READ | Be::PERSIST | Be::NOTIFY ) - EXPOSURE_END() + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) + EXPOSURE_END() }; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h index 0a9c2929d..b08878313 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" #include "TriRenderBatch.h" diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp index cb209e33b..4a97f370d 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp @@ -21,6 +21,7 @@ const Be::ClassInfo* EveChildInstanceMeshRenderer::ExposeToBlue() MAP_INTERFACE( EveChildInstanceMeshRenderer ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( EveChildMesh ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) @@ -42,5 +43,8 @@ const Be::ClassInfo* EveChildInstanceMeshRenderer::ExposeToBlue() MAP_METHOD_AND_WRAP( "RefreshStaticGeometry", RefreshStaticGeometry, "if static geo parameters were changed during authoring: refresh here\n:jessica-placement: TOOLBAR" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp index 4bc9ddbef..cc6915557 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp @@ -170,16 +170,6 @@ void EveChildInstancedMeshes::PushRtGeometry( Tr2RaytracingManager& rtManager ) } -const char* EveChildInstancedMeshes::GetName() const -{ - return m_name.c_str(); -} - -void EveChildInstancedMeshes::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildInstancedMeshes::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { m_lastCameraFrustum = updateContext.GetFrustum(); @@ -336,10 +326,6 @@ void EveChildInstancedMeshes::Setup( const Vector3* scale, const Quaternion* rot { } -void EveChildInstancedMeshes::ChangeLOD( Tr2Lod lod ) -{ -} - void EveChildInstancedMeshes::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { for( auto& mesh : m_meshes ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h index 5a25e441d..6248b4aa8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "../../EveInstancedMeshManager.h" BLUE_DECLARE( TriGeometryRes ); @@ -10,7 +10,7 @@ BLUE_DECLARE( Tr2Effect ); BLUE_CLASS( EveChildInstancedMeshes ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveEntity, public IBlueAsyncResNotifyTarget, public IEveShadowCaster, @@ -25,9 +25,7 @@ BLUE_CLASS( EveChildInstancedMeshes ) : ~EveChildInstancedMeshes(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void GetRenderables( std::vector & renderables ) override; bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; @@ -35,7 +33,6 @@ BLUE_CLASS( EveChildInstancedMeshes ) : void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; - void ChangeLOD( Tr2Lod lod ) override; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; @@ -137,7 +134,6 @@ BLUE_CLASS( EveChildInstancedMeshes ) : void ReleaseResources( TriStorage s ) override; bool OnPrepareResources() override; - BlueSharedString m_name; Matrix m_worldTransform = IdentityMatrix(); EveSpacePerObjectData m_perObjectData; EveInstancedMeshManager::PerObjectDataHandle m_perObjectDataHandle; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp index 59c4d83b7..0cd88e865 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp @@ -11,6 +11,7 @@ const Be::ClassInfo* EveChildInstancedMeshes::ExposeToBlue() { EXPOSURE_BEGIN( EveChildInstancedMeshes, "" ) MAP_INTERFACE( EveChildInstancedMeshes ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( IEveShadowCaster ) @@ -59,5 +60,8 @@ const Be::ClassInfo* EveChildInstancedMeshes::ExposeToBlue() ":param display: True to render the mesh, False to hide it\n" ":rtype: None" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp index 23bfe5459..3283e2fc4 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp @@ -90,16 +90,6 @@ void EveChildLightingOverride::RebuildBoundingSphere() } } -const char* EveChildLightingOverride::GetName() const -{ - return m_name.c_str(); -} - -void EveChildLightingOverride::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - bool EveChildLightingOverride::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { sphere.GetXYZ() = m_boundingSphere.center; @@ -108,10 +98,6 @@ bool EveChildLightingOverride::GetBoundingSphere( Vector4& sphere, BoundingSpher return true; } -void EveChildLightingOverride::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) -{ -} - void EveChildLightingOverride::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { Matrix localToWorldTransform = params.localToWorldTransform; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h index c786b7f34..a6a4980ac 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "Eve/EveEntity.h" #include "PostProcess/Tr2PostProcessEnums.h" @@ -37,7 +37,7 @@ REGISTER_COMPONENT_TYPE( "EveLightingOverride", IEveLightingOverride ); BLUE_CLASS( EveChildLightingOverride ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public IEveLightingOverride, public IInitialize, public ITr2DebugRenderable, @@ -52,19 +52,12 @@ BLUE_CLASS( EveChildLightingOverride ) : OverrideInfo GetOverrides() const override; ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override {}; - void GetRenderables( std::vector & renderables ) override{}; + // EveSpaceObjectChild bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query ) const override; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; - void ChangeLOD( Tr2Lod lod ) override {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; bool IsAlwaysOn() const override; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override {}; void RegisterComponents() override; void UnRegisterComponents() override; @@ -82,8 +75,6 @@ BLUE_CLASS( EveChildLightingOverride ) : private: void RebuildBoundingSphere(); - BlueSharedString m_name; - OverrideInfo m_overrides; PIEveVolumeVector m_volumes; float m_intensity; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride_Blue.cpp index 737d043e7..6c6dbe5f8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride_Blue.cpp @@ -13,6 +13,7 @@ const Be::ClassInfo* EveChildLightingOverride::ExposeToBlue() { EXPOSURE_BEGIN( EveChildLightingOverride, "" ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IEveLightingOverride ) MAP_INTERFACE( IInitialize ) @@ -56,5 +57,8 @@ const Be::ClassInfo* EveChildLightingOverride::ExposeToBlue() m_volumes, "The volumes that affect the light overrides", Be::READ | Be::PERSIST ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildLineSet.cpp b/trinity/Eve/SpaceObject/Children/EveChildLineSet.cpp index 843db76dd..7ccd6c3ed 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLineSet.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLineSet.cpp @@ -186,16 +186,6 @@ void EveChildLineSet::UpdateBoundingSphere( bool reCalculateChildren ) m_boundingSphere = sphere; } -const char* EveChildLineSet::GetName() const -{ - return m_name.c_str(); -} - -void EveChildLineSet::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildLineSet::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { if( !m_display ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildLineSet.h b/trinity/Eve/SpaceObject/Children/EveChildLineSet.h index 56146263b..61e1d2afe 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLineSet.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLineSet.h @@ -2,7 +2,7 @@ #pragma once -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" #include "TriRenderBatch.h" @@ -17,8 +17,8 @@ class ChildLineSetInstancingBatch; BLUE_CLASS( EveChildLineSet ) : + public EveSpaceObjectChild, public IInitialize, - public IEveSpaceObjectChild, public Tr2DeviceResource, public ITr2Renderable, public EveChildTransform, @@ -40,9 +40,7 @@ BLUE_CLASS( EveChildLineSet ) : bool OnModified( Be::Var * value ) override; ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; + // EveSpaceObjectChild void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; bool IsAlwaysOn() const override; @@ -51,9 +49,7 @@ BLUE_CLASS( EveChildLineSet ) : bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override {}; void GetRenderables( std::vector & renderables ) override; - void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override{}; ///////////////////////////////////////////////////////////////////////////////////// // Tr2DeviceResource @@ -105,7 +101,6 @@ BLUE_CLASS( EveChildLineSet ) : void GenerateManagedPoints(); void UpdateBoundingSphere( bool reCalculateChildren = true ); - BlueSharedString m_name; Vector3 m_worldVelocity; float m_ownerMaxSpeed; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp index 63fd188f8..b6eb83374 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp @@ -18,6 +18,7 @@ const Be::ClassInfo* EveChildLineSet::ExposeToBlue() { EXPOSURE_BEGIN( EveChildLineSet, "" ) MAP_INTERFACE( EveChildLineSet ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -48,5 +49,8 @@ const Be::ClassInfo* EveChildLineSet::ExposeToBlue() MAP_ATTRIBUTE( "lineSet", m_lineSet, ":jessica-hidden: True", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "mesh", m_mesh, "the rendered mesh", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildLink.h b/trinity/Eve/SpaceObject/Children/EveChildLink.h index bcfeb78a3..00509a37c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLink.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLink.h @@ -22,7 +22,7 @@ BLUE_CLASS( EveChildLink ) : ~EveChildLink(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + // EveSpaceObjectChild void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp b/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp index c76586eb9..82b5a8704 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp @@ -204,16 +204,6 @@ bool EveChildMesh::OnModified( Be::Var* val ) return true; } -const char* EveChildMesh::GetName() const -{ - return m_name.c_str(); -} - -void EveChildMesh::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildMesh::InitializeAnimation() { if( m_animationUpdater && m_animationUpdater->GetResPath().empty() ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh.h b/trinity/Eve/SpaceObject/Children/EveChildMesh.h index 54d5e1b52..23fa6116a 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh.h +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh.h @@ -4,7 +4,7 @@ #ifndef EveChildMesh_H #define EveChildMesh_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "Eve/SpaceObject/EveSpaceObject2.h" #include "Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h" @@ -54,7 +54,7 @@ enum class MorphTargetAnimationFilter : uint8_t }; BLUE_CLASS( EveChildMesh ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public IInitialize, @@ -78,9 +78,7 @@ BLUE_CLASS( EveChildMesh ) : ~EveChildMesh(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -205,9 +203,6 @@ BLUE_CLASS( EveChildMesh ) : std::pair GetMorphTargets( MorphTargetAnimationFilter filter ); void UpdateMorphAnimationBuffer(); - // general data - BlueSharedString m_name; - // the mesh Tr2MeshBasePtr m_mesh; Tr2InstancedMeshPtr m_instancedMesh; // Cached downcast of m_mesh diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp index de99e6f6a..69816dd72 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp @@ -3,6 +3,7 @@ #include "StdAfx.h" #include "EveChildMesh.h" +BLUE_DEFINE_INTERFACE( IMultiPartObjectElement ); BLUE_DEFINE( EveChildMesh ); const Be::ClassInfo* EveChildMesh::ExposeToBlue() @@ -11,6 +12,7 @@ const Be::ClassInfo* EveChildMesh::ExposeToBlue() MAP_INTERFACE( EveChildMesh ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( IEveSpaceObjectDecalOwner ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) @@ -88,5 +90,8 @@ const Be::ClassInfo* EveChildMesh::ExposeToBlue() "GetMorphTargetWeight( name )\n\n" "Returns the weight of the morph target. Returns 0 if no morph target with that name was found.\n" ":param name: morph target name\n" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp index 6d01b4d4e..828333e46 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp @@ -68,18 +68,6 @@ EveChildParticleSphere::EveChildParticleSphere( IRoot* lockobj ) : { } -// -------------------------------------------------------------------------------- -const char* EveChildParticleSphere::GetName() const -{ - return m_name.c_str(); -} - -// -------------------------------------------------------------------------------- -void EveChildParticleSphere::SetName( const char* name ) -{ - m_name = name; -} - // ----------------------------------------------------------------------------- void EveChildParticleSphere::GetRenderables( std::vector& renderables ) { diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h index 975b379a2..a771f2b60 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h @@ -2,7 +2,7 @@ #pragma once -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "ITr2Renderable.h" #include "Particle/Tr2ParticleElementDeclaration.h" @@ -13,7 +13,7 @@ BLUE_DECLARE( Tr2ParticleSystem ); class EveUpdateContext; BLUE_CLASS( EveChildParticleSphere ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2Renderable { public: @@ -23,9 +23,7 @@ BLUE_CLASS( EveChildParticleSphere ) : ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void GetRenderables( std::vector & renderables ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -33,7 +31,6 @@ BLUE_CLASS( EveChildParticleSphere ) : void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); - void ChangeLOD( Tr2Lod lod ) {}; ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable @@ -66,8 +63,6 @@ BLUE_CLASS( EveChildParticleSphere ) : Matrix m_worldTransform; Vector4 m_boundingSphere; - std::string m_name; - enum { BIND_PENDING, diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp index eb533845c..d28a976bc 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveChildParticleSphere::ExposeToBlue() { EXPOSURE_BEGIN( EveChildParticleSphere, "" ) MAP_INTERFACE( EveChildParticleSphere ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) @@ -35,5 +36,8 @@ const Be::ClassInfo* EveChildParticleSphere::ExposeToBlue() MAP_ATTRIBUTE( "useSpaceObjectData", m_useSpaceObjectData, "", Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "Refresh", Refresh, "Re-binds particle system and re-adds particles" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp index 8134510ae..037c04d20 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp @@ -77,16 +77,6 @@ bool EveChildParticleSystem::OnModified( Be::Var* value ) return true; } -const char* EveChildParticleSystem::GetName() const -{ - return m_name.c_str(); -} - -void EveChildParticleSystem::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - // -------------------------------------------------------------------------------- // Description: // Setup function to set data from outside, in this case just pass it to diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h index d3197edac..79012e5ff 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h @@ -4,7 +4,7 @@ #ifndef EveChildParticleSystem_H #define EveChildParticleSystem_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "ITr2Renderable.h" @@ -25,7 +25,7 @@ BLUE_DECLARE_INTERFACE( ITr2GenericEmitter ); BLUE_DECLARE_IVECTOR( ITr2GenericEmitter ); BLUE_CLASS( EveChildParticleSystem ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public IInitialize, @@ -40,9 +40,7 @@ BLUE_CLASS( EveChildParticleSystem ) : ~EveChildParticleSystem(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -85,8 +83,6 @@ BLUE_CLASS( EveChildParticleSystem ) : PITr2GenericEmitterVector m_particleEmitters; private: - BlueSharedString m_name; - Vector4 m_boundingSphere; Vector4 m_lodSphere; diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp index 66bdaa945..dadda5153 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildParticleSystem::ExposeToBlue() EXPOSURE_BEGIN( EveChildParticleSystem, "" ) MAP_INTERFACE( EveChildParticleSystem ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) @@ -70,5 +71,8 @@ const Be::ClassInfo* EveChildParticleSystem::ExposeToBlue() MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "Screen size for last frame\n:jessica-group: LOD", Be::READ ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform if useSRT is set." ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp b/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp index 90ab0a190..b0db45722 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp @@ -25,10 +25,12 @@ EveChildPlug::~EveChildPlug() { controller->Unlink( UnlinkReason::DELETING ); } + UnregisterChildren( m_objects ); } bool EveChildPlug::Initialize() { + RegisterChildren( m_objects ); for( auto& controller : m_controllers ) { if( !controller->IsLinked() ) @@ -73,6 +75,7 @@ void EveChildPlug::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* } else if( list == &m_objects && ( event & BELIST_LOADING ) == 0 ) { + HandleChildrenListModified( event, value, m_objects ); if( IsInRegistry() ) { switch( event & BELIST_EVENTMASK ) @@ -153,16 +156,6 @@ void EveChildPlug::UnRegisterComponents() } } -const char* EveChildPlug::GetName() const -{ - return m_name.c_str(); -} - -void EveChildPlug::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildPlug::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { if( !m_display ) @@ -195,7 +188,7 @@ bool EveChildPlug::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if( ( *it )->GetBoundingSphere( bSphere ) ) + if( ( *it )->GetBoundingSphere( bSphere, EVE_BOUNDS_NORMAL ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -271,7 +264,7 @@ void EveChildPlug::SetShaderOption( const BlueSharedString& name, const BlueShar { for( auto it = m_objects.begin(); it != m_objects.end(); ++it ) { - IEveSpaceObjectChild* child = *it; + EveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } } @@ -426,7 +419,7 @@ void EveChildPlug::StartControllers() } } -IEveSpaceObjectChildPtr EveChildPlug::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildPlug::GetEffectChildByName( const char* name ) const { for( auto it = begin( m_objects ); it != end( m_objects ); ++it ) { @@ -439,7 +432,7 @@ IEveSpaceObjectChildPtr EveChildPlug::GetEffectChildByName( const char* name ) c return nullptr; } -void EveChildPlug::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildPlug::AddToEffectChildrenList( EveSpaceObjectChild* child ) { if( IsInRegistry() ) { @@ -451,7 +444,7 @@ void EveChildPlug::AddToEffectChildrenList( IEveSpaceObjectChild* child ) m_objects.Append( child->GetRootObject() ); } -void EveChildPlug::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildPlug::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { auto index = m_objects.FindKey( child ); if( index >= 0 ) @@ -505,3 +498,27 @@ ITr2AudEmitterPtr EveChildPlug::FindSoundEmitter( const char* name ) } return nullptr; } + +void EveChildPlug::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + for( auto& child : m_objects ) + { + child->SetOwner( owner ); + } + } +} + +void EveChildPlug::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + for( auto& child : m_objects ) + { + child->SetPartTag( tag ); + } + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug.h b/trinity/Eve/SpaceObject/Children/EveChildPlug.h index efdabcfb8..37b228850 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug.h @@ -5,7 +5,7 @@ #define EveChildPlug_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -19,7 +19,7 @@ BLUE_DECLARE_VECTOR( Tr2ExternalParameter ); BLUE_CLASS( EveChildPlug ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2CurveSetOwner, public IInitialize, @@ -51,18 +51,15 @@ BLUE_CLASS( EveChildPlug ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; void UnRegisterComponents() override; - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -77,6 +74,9 @@ BLUE_CLASS( EveChildPlug ) : void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; + void PlayAllCurveSets(); void StopAllCurveSets(); void PlayCurveSet( const std::string& name, const std::string& rangeName ); @@ -102,9 +102,7 @@ BLUE_CLASS( EveChildPlug ) : ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; protected: - PIEveSpaceObjectChildVector m_objects; - - BlueSharedString m_name; + PEveSpaceObjectChildVector m_objects; PITr2ControllerVector m_controllers; std::vector> m_controllerVariables; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp index 97d8b9cd5..1ce9a4105 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildPlug::ExposeToBlue() { EXPOSURE_BEGIN( EveChildPlug, "\n:jessica-icon: plug\n:jessica-icon-color: (123, 28, 212)\n:jessica-help-url: https://wiki.ccpgames.com/pages/viewpage.action?spaceKey=TTL&title=Plugs+and+Sockets \n" ) MAP_INTERFACE( EveChildPlug ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -44,5 +45,8 @@ const Be::ClassInfo* EveChildPlug::ExposeToBlue() StartControllers, "Start all controllers" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp index d82375bf8..af7e266ce 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp @@ -70,20 +70,7 @@ void EveChildPostProcessVolume::UnRegisterComponents() } ///////////////////////////////////////////////////////////////////////////////////// -// IEveSpaceObjectChild -const char* EveChildPostProcessVolume::GetName() const -{ - return m_name.c_str(); -} - -void EveChildPostProcessVolume::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - -void EveChildPostProcessVolume::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) -{ -} +// EveSpaceObjectChild bool EveChildPostProcessVolume::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { @@ -93,10 +80,6 @@ bool EveChildPostProcessVolume::GetBoundingSphere( Vector4& sphere, BoundingSphe return true; } -void EveChildPostProcessVolume::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) -{ -} - void EveChildPostProcessVolume::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { CCP_STATS_ZONE( __FUNCTION__ ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h index 10d33b44a..8e45a3058 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h @@ -3,7 +3,7 @@ #pragma once #include "StdAfx.h" -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "ITr2Renderable.h" #include "Tr2DebugRenderer.h" @@ -17,7 +17,7 @@ BLUE_DECLARE_IVECTOR( IEveVolume ); BLUE_CLASS( EveChildPostProcessVolume ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public IInitialize, public ITr2DebugRenderable, @@ -33,19 +33,12 @@ BLUE_CLASS( EveChildPostProcessVolume ) : void RebuildBoundingSphere(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector & renderables ){}; + // EveSpaceObjectChild bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ) {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; bool IsAlwaysOn() const; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) {}; virtual void RegisterComponents(); virtual void UnRegisterComponents(); @@ -66,7 +59,6 @@ BLUE_CLASS( EveChildPostProcessVolume ) : private: void UpdateTransformFromParent( const EveChildUpdateParams& params ); - BlueSharedString m_name; PIEveVolumeVector m_volumes; PIEveVolumeVector m_exclusionVolumes; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp index 32907e00a..d0ffb1142 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp @@ -14,6 +14,7 @@ const Be::ClassInfo* EveChildPostProcessVolume::ExposeToBlue() EXPOSURE_BEGIN( EveChildPostProcessVolume, "" ) MAP_INTERFACE( ITr2PostProcessOwner ) MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) @@ -24,5 +25,8 @@ const Be::ClassInfo* EveChildPostProcessVolume::ExposeToBlue() MAP_ATTRIBUTE( "exclusionVolumes", m_exclusionVolumes, "", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "postProcessAttributes", m_postProcessAttributes, "", Be::READWRITE | Be::PERSIST ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp b/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp index a4a8eea7e..d7f8ea48d 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp @@ -64,16 +64,6 @@ bool EveChildQuad::Initialize() return true; } -const char* EveChildQuad::GetName() const -{ - return m_name.c_str(); -} - -void EveChildQuad::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - // -------------------------------------------------------------------------------- // Description: // Setup function to set data from outside, in this case just pass it to @@ -100,10 +90,6 @@ void EveChildQuad::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRen } } -void EveChildQuad::GetRenderables( std::vector& renderables ) -{ -} - bool EveChildQuad::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { sphere = Vector4( 0.f, 0.f, 0.f, std::sqrt( 2.f ) ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad.h b/trinity/Eve/SpaceObject/Children/EveChildQuad.h index 926bf64e1..2c072a079 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad.h +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad.h @@ -4,7 +4,7 @@ #ifndef EveChildQuad_H #define EveChildQuad_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "EveChildTransform.h" #include "ITr2Renderable.h" @@ -12,7 +12,7 @@ BLUE_DECLARE( Tr2Effect ); BLUE_CLASS( EveChildQuad ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public IInitialize @@ -26,18 +26,14 @@ BLUE_CLASS( EveChildQuad ) : static Tr2VertexDefinition& GetQuadDefinition(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector & renderables ); bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ) {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); ///////////////////////////////////////////////////////////////////////////////////// @@ -66,7 +62,6 @@ BLUE_CLASS( EveChildQuad ) : Float_16 m_brightness[2]; }; - BlueSharedString m_name; Tr2EffectPtr m_effect; unsigned m_effectKey; Quad m_quad; diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp index 1e9f446a0..6bfc4db89 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveChildQuad::ExposeToBlue() { EXPOSURE_BEGIN( EveChildQuad, "" ) MAP_INTERFACE( EveChildQuad ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) @@ -34,5 +35,8 @@ const Be::ClassInfo* EveChildQuad::ExposeToBlue() Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "Screen size for last frame\n:jessica-group: LOD", Be::READ ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform if useSRT is set." ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef.cpp b/trinity/Eve/SpaceObject/Children/EveChildRef.cpp index 23a00cdd8..299fdb622 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildRef.cpp @@ -16,6 +16,7 @@ EveChildRef::EveChildRef( IRoot* lockobj ) : EveChildRef::~EveChildRef() { + UnregisterChild( m_child ); } const char* EveChildRef::GetResPath() const @@ -74,16 +75,6 @@ bool EveChildRef::OnModified( Be::Var* value ) return true; } -const char* EveChildRef::GetName() const -{ - return m_name.c_str(); -} - -void EveChildRef::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - void EveChildRef::RegisterComponents() { if( IsInRegistry() && m_child != nullptr && m_display ) @@ -106,7 +97,7 @@ void EveChildRef::UnRegisterComponents() } } -IEveSpaceObjectChildPtr EveChildRef::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildRef::GetEffectChildByName( const char* name ) const { if( auto ref = dynamic_cast( m_child.p ) ) { @@ -115,7 +106,7 @@ IEveSpaceObjectChildPtr EveChildRef::GetEffectChildByName( const char* name ) co return nullptr; } -void EveChildRef::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildRef::AddToEffectChildrenList( EveSpaceObjectChild* child ) { if( auto ref = dynamic_cast( m_child.p ) ) { @@ -123,7 +114,7 @@ void EveChildRef::AddToEffectChildrenList( IEveSpaceObjectChild* child ) } } -void EveChildRef::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildRef::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { if( auto ref = dynamic_cast( m_child.p ) ) { @@ -163,7 +154,7 @@ bool EveChildRef::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query { bool success = false; Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); - if( m_child && m_child->GetBoundingSphere( bSphere ) ) + if( m_child && m_child->GetBoundingSphere( bSphere, EVE_BOUNDS_NORMAL ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -352,14 +343,16 @@ bool EveChildRef::LoadChild() { // unregister the old child UnRegisterComponents(); + UnregisterChild( m_child ); CCP_LOG( "Loading child red file %s", m_resPath.c_str() ); - m_child = BeResMan->LoadObject( m_resPath.c_str() ); + m_child = BeResMan->LoadObject( m_resPath.c_str() ); if( !m_child ) { CCP_LOGERR( "Red file %s is invalid or not an Eve Child type.", m_resPath.c_str() ); return false; } + RegisterChild( m_child ); RegisterComponents(); @@ -373,4 +366,28 @@ ITr2AudEmitterPtr EveChildRef::FindSoundEmitter( const char* name ) return owner->FindSoundEmitter( name ); } return nullptr; -} \ No newline at end of file +} + +void EveChildRef::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + if( m_child ) + { + m_child->SetOwner( owner ); + } + } +} + +void EveChildRef::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + if( m_child ) + { + m_child->SetPartTag( tag ); + } + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef.h b/trinity/Eve/SpaceObject/Children/EveChildRef.h index 1ef6ca39d..20b241190 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef.h +++ b/trinity/Eve/SpaceObject/Children/EveChildRef.h @@ -5,7 +5,7 @@ #define EveChildRef_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -16,7 +16,7 @@ BLUE_CLASS( EveChildRef ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2CurveSetOwner, public IInitialize, @@ -52,16 +52,11 @@ BLUE_CLASS( EveChildRef ) : void RegisterComponents() override; void UnRegisterComponents() override; - ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); - ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); void SetProceduralContainerVariable( const char* name, float value ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); @@ -79,6 +74,9 @@ BLUE_CLASS( EveChildRef ) : void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; + void PlayCurveSet( const std::string& name, const std::string& rangeName ); void StopCurveSet( const std::string& name ); void UpdateCurveSet( const std::string& name, Be::Time time ); @@ -104,8 +102,7 @@ BLUE_CLASS( EveChildRef ) : protected: bool LoadChild(); - IEveSpaceObjectChildPtr m_child; - BlueSharedString m_name; + EveSpaceObjectChildPtr m_child; std::string m_resPath; bool m_loadChildAutomatically; diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp index ed5256332..9a6999058 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildRef::ExposeToBlue() { EXPOSURE_BEGIN( EveChildRef, "\n:jessica-icon: alicorn\n:jessica-icon-color: (123, 28, 212)\n:jessica-help-url: https://wiki.ccpgames.com/pages/viewpage.action?spaceKey=TTL&title=Plugs+and+Sockets \n" ) MAP_INTERFACE( EveChildRef ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -62,5 +63,8 @@ const Be::ClassInfo* EveChildRef::ExposeToBlue() Reload, 1, "Reload the effect child.\n" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp b/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp index 8c89fb919..e35db336c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp @@ -15,7 +15,6 @@ EveChildSocket::EveChildSocket( IRoot* lockobj ) : PARENTLOCK( m_parameters ), m_plug(), - m_name(), m_plugResPath(), m_display( true ) { @@ -23,6 +22,7 @@ EveChildSocket::EveChildSocket( IRoot* lockobj ) : EveChildSocket::~EveChildSocket() { + UnregisterChild( m_plug ); } const char* EveChildSocket::GetPlugResPath() const @@ -236,17 +236,7 @@ void EveChildSocket::UnRegisterComponents() } -const char* EveChildSocket::GetName() const -{ - return m_name.c_str(); -} - -void EveChildSocket::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - -IEveSpaceObjectChildPtr EveChildSocket::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveChildSocket::GetEffectChildByName( const char* name ) const { if( m_plug ) { @@ -255,11 +245,11 @@ IEveSpaceObjectChildPtr EveChildSocket::GetEffectChildByName( const char* name ) return nullptr; } -void EveChildSocket::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildSocket::AddToEffectChildrenList( EveSpaceObjectChild* child ) { } -void EveChildSocket::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveChildSocket::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { } @@ -490,6 +480,7 @@ bool EveChildSocket::LoadChild() { // unregister the current child UnRegisterComponents(); + UnregisterChild( m_plug ); CCP_LOG( "Loading child red file %s", m_plugResPath.c_str() ); m_plug = BeResMan->LoadObject( m_plugResPath.c_str() ); @@ -498,6 +489,7 @@ bool EveChildSocket::LoadChild() CCP_LOGERR( "Red file %s is invalid or not an Eve Child type.", m_plugResPath.c_str() ); return false; } + RegisterChild( m_plug ); RegisterComponents(); @@ -512,3 +504,27 @@ ITr2AudEmitterPtr EveChildSocket::FindSoundEmitter( const char* name ) } return nullptr; } + +void EveChildSocket::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + if( m_plug ) + { + m_plug->SetOwner( owner ); + } + } +} + +void EveChildSocket::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + if( m_plug ) + { + m_plug->SetPartTag( tag ); + } + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket.h b/trinity/Eve/SpaceObject/Children/EveChildSocket.h index 0827ae425..225de887f 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket.h +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket.h @@ -4,7 +4,7 @@ #ifndef EveChildSocket_H #define EveChildSocket_H -#include "IEveSpaceObjectChild.h" +#include "EveSpaceObjectChild.h" #include "IEveEffectChildrenOwner.h" #include "EveChildTransform.h" #include "Tr2DebugRenderer.h" @@ -19,7 +19,7 @@ BLUE_DECLARE_IVECTOR( IEveSocketParameter ); BLUE_CLASS( EveChildSocket ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2CurveSetOwner, public IInitialize, @@ -52,16 +52,11 @@ BLUE_CLASS( EveChildSocket ) : // INotify virtual bool OnModified( Be::Var * value ); - ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); - ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -82,6 +77,9 @@ BLUE_CLASS( EveChildSocket ) : void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; + void PlayAllCurveSets(); void StopAllCurveSets(); void PlayCurveSet( const std::string& name, const std::string& rangeName ); @@ -109,7 +107,6 @@ BLUE_CLASS( EveChildSocket ) : EveChildPlugPtr m_plug; - BlueSharedString m_name; std::string m_plugResPath; bool m_display; diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp index 109731c0e..2aaf872c1 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp @@ -10,6 +10,7 @@ const Be::ClassInfo* EveChildSocket::ExposeToBlue() { EXPOSURE_BEGIN( EveChildSocket, "\n:jessica-icon:blender-phone\n:jessica-icon-color: (123, 28, 212)\n:jessica-help-url: https://wiki.ccpgames.com/pages/viewpage.action?spaceKey=TTL&title=Plugs+and+Sockets \n" ) MAP_INTERFACE( EveChildSocket ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -69,5 +70,8 @@ const Be::ClassInfo* EveChildSocket::ExposeToBlue() ":jessica-placement:\n" ":jessica-icon: far-sync\n" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h b/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h index 3b9f501a3..0317a23b5 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h +++ b/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h @@ -37,7 +37,7 @@ BLUE_CLASS( EveChildSpherePin ) : ~EveChildSpherePin(); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + // EveSpaceObjectChild void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); diff --git a/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h b/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h index b7a510709..d5aa1b5f9 100644 --- a/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h +++ b/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h @@ -3,13 +3,13 @@ #pragma once -BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); BLUE_INTERFACE( IEveEffectChildrenOwner ) : public IRoot { - virtual IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const = 0; - virtual void AddToEffectChildrenList( IEveSpaceObjectChild * child ) = 0; - virtual void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ) = 0; + virtual EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const = 0; + virtual void AddToEffectChildrenList( EveSpaceObjectChild * child ) = 0; + virtual void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ) = 0; }; \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h b/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h index 8a8cd6c73..9f635f921 100644 --- a/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h +++ b/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h @@ -12,6 +12,7 @@ class EveUpdateContext; class Tr2LightManager; BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); BLUE_DECLARE_INTERFACE( IEveChildTransformModifier ); struct EveChildUpdateParams @@ -31,7 +32,7 @@ struct EveChildUpdateParams } IEveSpaceObject2* spaceObjectParent; - IEveSpaceObjectChild* childParent; + EveSpaceObjectChild* childParent; size_t boneCount; const Float4x3* bones; float ownerMaxSpeed; @@ -42,56 +43,12 @@ struct EveChildUpdateParams Vector3 worldVelocity; }; +/** + * @brief Deprecated interface for EveSpaceObjectChild. Classes deriving from EveSpaceObjectChild should still declare + * this interface in MAP_INTERFACE macro for backward compatibility with Python code, but otherwise this interface should not be used directly. + */ BLUE_INTERFACE( IEveSpaceObjectChild ) : - public IRoot -{ - enum Origin - { - SPACE, - SOF, - }; - - virtual const char* GetName() const = 0; - virtual void SetName( const char* name ) = 0; - - virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) = 0; - virtual void GetRenderables( std::vector & renderables ) = 0; - virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const = 0; - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) - { - } - virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const - { - } - - virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) = 0; - virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) = 0; - - virtual void GetLocalToWorldTransform( Matrix & transform ) const = 0; - - virtual bool IsAlwaysOn() const - { - return false; - }; - - virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) = 0; - - virtual void ChangeLOD( Tr2Lod lod ) = 0; - - virtual void SetControllerVariable( const char* name, float value ) {}; - virtual void HandleControllerEvent( const char* name ) {}; - virtual void StartControllers() {}; - - virtual void SetProceduralContainerVariable( const char* name, float value ) {}; - - virtual void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) {}; - - virtual void SetOrigin( Origin origin ) {}; - - virtual void AddTransformModifier( IEveChildTransformModifier * modifier ){}; - - virtual void SetMute( bool isMuted ) {}; -}; + public IRoot{}; BLUE_DECLARE_IVECTOR( IEveSpaceObjectChild ); diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp index d47fb4bb0..fdcc10596 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp @@ -14,16 +14,7 @@ EveChildProceduralContainer::EveChildProceduralContainer( IRoot* lockobj ) : EveChildProceduralContainer::~EveChildProceduralContainer() { -} - -const char* EveChildProceduralContainer::GetName() const -{ - return m_name.c_str(); -} - -void EveChildProceduralContainer::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); + UnregisterChild( m_selectedObject ); } bool EveChildProceduralContainer::Initialize() @@ -60,7 +51,7 @@ bool EveChildProceduralContainer::GetBoundingSphere( Vector4& sphere, BoundingSp { bool success = false; Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); - if( m_selectedObject && m_selectedObject->GetBoundingSphere( bSphere ) ) + if( m_selectedObject && m_selectedObject->GetBoundingSphere( bSphere, EVE_BOUNDS_NORMAL ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -148,7 +139,9 @@ void EveChildProceduralContainer::ConfigureSelectedObject() { entity->UnRegister( registry ); } + UnregisterChild( m_selectedObject ); m_selectedObject = child; + RegisterChild( m_selectedObject ); if( EveEntityPtr entity = BlueCastPtr( m_selectedObject ) ) { entity->Register( registry ); @@ -388,4 +381,28 @@ void EveChildProceduralContainer::RenderDebugInfo( ITr2DebugRenderer2& renderer } } } +} + +void EveChildProceduralContainer::SetOwner( IEveSpaceObject2* owner ) +{ + if( GetOwner() != owner ) + { + EveSpaceObjectChild::SetOwner( owner ); + if( m_selectedObject ) + { + m_selectedObject->SetOwner( owner ); + } + } +} + +void EveChildProceduralContainer::SetPartTag( PartTag tag ) +{ + if( GetPartTag() != tag ) + { + EveSpaceObjectChild::SetPartTag( tag ); + if( m_selectedObject ) + { + m_selectedObject->SetPartTag( tag ); + } + } } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h index 122ee0afc..8a370b44c 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h @@ -2,7 +2,7 @@ #pragma once -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Eve/SpaceObject/Children/IEveEffectChildrenOwner.h" #include "Eve/SpaceObject/Children/EveChildTransform.h" #include "Eve/SpaceObject/Children/TransformModifiers/IEveChildTransformModifier.h" @@ -13,7 +13,7 @@ BLUE_CLASS( EveChildProceduralContainer ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public ITr2CurveSetOwner, public IEveInheritPropertiesOwner, public EveChildTransform, @@ -31,9 +31,6 @@ BLUE_CLASS( EveChildProceduralContainer ) : EveChildProceduralContainer( IRoot* lockobj = NULL ); ~EveChildProceduralContainer(); - const char* GetName() const override; - void SetName( const char* name ) override; - void ConfigureSelectedObject(); const char* GetMethodVariableName(); @@ -50,7 +47,7 @@ BLUE_CLASS( EveChildProceduralContainer ) : void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ) override; ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChildOwner + // EveSpaceObjectChildOwner void AddTransformModifier( IEveChildTransformModifier * modifier ) override; void SetProceduralContainerVariable( const char* name, float value ); @@ -71,7 +68,7 @@ BLUE_CLASS( EveChildProceduralContainer ) : void StopAllCurveSets() override; ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void GetRenderables( std::vector & renderables ) override; bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; @@ -84,6 +81,8 @@ BLUE_CLASS( EveChildProceduralContainer ) : void ChangeLOD( Tr2Lod lod ) override; ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; void SetInheritProperties( const Color* colorSet ) override; + void SetOwner( IEveSpaceObject2 * owner ) override; + void SetPartTag( PartTag tag ) override; ////////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -100,10 +99,9 @@ BLUE_CLASS( EveChildProceduralContainer ) : void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; protected: - IEveSpaceObjectChildPtr m_selectedObject; + EveSpaceObjectChildPtr m_selectedObject; IEveProceduralSelectionMethodPtr m_selectionMethod; - BlueSharedString m_name; PIEveChildTransformModifierVector m_transformModifiers; TrackableStdUnorderedMap m_proceduralContainerVariables; bool m_display; diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp index e86efdcb0..3bbe124cf 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp @@ -8,6 +8,7 @@ const Be::ClassInfo* EveChildProceduralContainer::ExposeToBlue() { EXPOSURE_BEGIN( EveChildProceduralContainer, "" ) MAP_INTERFACE( EveChildProceduralContainer ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -42,5 +43,8 @@ const Be::ClassInfo* EveChildProceduralContainer::ExposeToBlue() MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, "Start all controllers" ) MAP_METHOD_AND_WRAP( "GetMethodVariableName", GetMethodVariableName, "Get the name of the seed variable being utilized" ) MAP_METHOD_AND_WRAP( "SetProceduralContainerVariable", SetProceduralContainerVariable, "Set variable for all applicable ProceduralContainers\n:param name: variable name\n:param value: new variable value\n" ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp index 2cba8fc94..6060c1338 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp @@ -13,16 +13,6 @@ EveChildSmartLightSet::EveChildSmartLightSet( IRoot* lockobj ) : m_lightGroups.SetNotify( this ); } -const char* EveChildSmartLightSet::GetName() const -{ - return m_name.c_str(); -} - -void EveChildSmartLightSet::SetName( const char* name ) -{ - m_name = name; -} - void EveChildSmartLightSet::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ) { if( list == &m_lightGroups && ( event & BELIST_EVENTMASK ) == BELIST_INSERTED ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h index a5b1b1ea2..6e87d569a 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h @@ -3,6 +3,7 @@ #pragma once #include "../EveChildTransform.h" +#include "../EveSpaceObjectChild.h" #include "../EveChildInheritProperties.h" #include "../IEveInheritPropertiesOwner.h" #include "attributeModifiers/IEveSmartLightGroupAttributeModifier.h" @@ -14,7 +15,7 @@ BLUE_DECLARE_INTERFACE( IEveSmartLightGroup ); BLUE_DECLARE_IVECTOR( IEveSmartLightGroup ); BLUE_CLASS( EveChildSmartLightSet ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2DebugRenderable, public IEveInheritPropertiesOwner, @@ -31,22 +32,14 @@ BLUE_CLASS( EveChildSmartLightSet ) : void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; void GetDebugOptions( Tr2DebugRendererOptions & options ) override; - // IEveSpaceObjectChild - const char* GetName() const; - void SetName( const char* name ); + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); - bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const - { - return false; - }; void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const; - void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) {}; - void ChangeLOD( Tr2Lod lod ) {}; void SetControllerVariable( const char* name, float value ) override; ////////////////////////////////////////////////////////////////////////////////////// @@ -65,7 +58,6 @@ BLUE_CLASS( EveChildSmartLightSet ) : private: bool m_display; - std::string m_name; IEveDistributionMethodPtr m_distribution; PIEveSmartLightGroupVector m_lightGroups; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp index cddf27441..24220044c 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveChildSmartLightSet::ExposeToBlue() { EXPOSURE_BEGIN( EveChildSmartLightSet, "\n:jessica-icon: lightbulb-gear\n:jessica-icon-color: (255, 207, 50)\n:jessica-help-url: https://ccpgames.atlassian.net/wiki/spaces/TTL/pages/1308393505/SmartLightSets\n" ) MAP_INTERFACE( EveChildSmartLightSet ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2DebugRenderable ) MAP_INTERFACE( INotify ) @@ -22,5 +23,8 @@ const Be::ClassInfo* EveChildSmartLightSet::ExposeToBlue() MAP_ATTRIBUTE( "distribution", m_distribution, "distributionMethod for entities\n:jessica-icon: map-location-dot\n:jessica-help-url: https://ccpgames.atlassian.net/wiki/spaces/TTL/pages/1311441160/Distributions\n", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "lightGroups", m_lightGroups, "list of lights and light-renderables", Be::READ | Be::PERSIST ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h index 34f63f71e..d7abc3278 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h @@ -5,7 +5,7 @@ #include "IEveSmartLightGroupAttributeModifier.h" #include "Lights/Tr2PointLight.h" #include -#include +#include #include "Curves/Tr2CurveScalar.h" BLUE_DECLARE( Tr2CurveScalar ); diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp index c580579b1..a5c179100 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp @@ -239,6 +239,11 @@ EveSpaceObject2::~EveSpaceObject2() } UnregisterAudioGeometry(); + + for( auto& child : m_effectChildren ) + { + child->SetOwner( nullptr ); + } } bool EveSpaceObject2::Initialize() @@ -249,6 +254,11 @@ bool EveSpaceObject2::Initialize() PrepareForAnimation(); } + for( auto& child : m_effectChildren ) + { + child->SetOwner( this ); + } + for( auto& controller : m_controllers ) { if( !controller->IsLinked() ) @@ -307,8 +317,9 @@ void EveSpaceObject2::OnListModified( long event, ssize_t key, ssize_t key2, IRo switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - if( IEveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) { + child->SetOwner( this ); for( auto it = begin( m_controllerVariables ); it != end( m_controllerVariables ); ++it ) { child->SetControllerVariable( it->first.c_str(), it->second ); @@ -327,6 +338,10 @@ void EveSpaceObject2::OnListModified( long event, ssize_t key, ssize_t key2, IRo { entity->UnRegister( this->GetComponentRegistry() ); } + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + { + child->SetOwner( nullptr ); + } break; case BELIST_UNLOADSTART: if( IsInRegistry() ) @@ -339,6 +354,10 @@ void EveSpaceObject2::OnListModified( long event, ssize_t key, ssize_t key2, IRo } } } + for( auto& child : m_effectChildren ) + { + child->SetOwner( nullptr ); + } break; default: break; @@ -3005,7 +3024,7 @@ void EveSpaceObject2::AddObserver( TriObserverLocalPtr observer ) } // -------------------------------------------------------------------------------- -IEveSpaceObjectChildPtr EveSpaceObject2::GetEffectChildByName( const char* name ) const +EveSpaceObjectChildPtr EveSpaceObject2::GetEffectChildByName( const char* name ) const { for( auto it = begin( m_effectChildren ); it != end( m_effectChildren ); ++it ) { @@ -3022,7 +3041,7 @@ IEveSpaceObjectChildPtr EveSpaceObject2::GetEffectChildByName( const char* name // Description: // Add a child to the effectChildren list // -------------------------------------------------------------------------------- -void EveSpaceObject2::AddToEffectChildrenList( IEveSpaceObjectChild* child ) +void EveSpaceObject2::AddToEffectChildrenList( EveSpaceObjectChild* child ) { if( m_inheritProperties ) { @@ -3036,7 +3055,7 @@ void EveSpaceObject2::AddToEffectChildrenList( IEveSpaceObjectChild* child ) } // -------------------------------------------------------------------------------- -void EveSpaceObject2::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) +void EveSpaceObject2::RemoveFromEffectChildrenList( EveSpaceObjectChild* child ) { auto index = m_effectChildren.FindKey( child ); if( index >= 0 ) @@ -3858,7 +3877,7 @@ void EveSpaceObject2::SetShaderOption( const BlueSharedString& name, const BlueS for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) { - IEveSpaceObjectChild* child = *it; + EveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } } diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.h b/trinity/Eve/SpaceObject/EveSpaceObject2.h index 19ded272d..d06f06f95 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.h +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.h @@ -21,7 +21,7 @@ #include "Eve/SpaceObject/Attachments/EveMeshOverlayEffect.h" #include "Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h" #include "Eve/SpaceObject/Attachments/EveImpactOverlay.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "Eve/SpaceObject/Children/IEveEffectChildrenOwner.h" #include "Eve/SpaceObject/Children/IEveInheritPropertiesOwner.h" #include "Eve/SpaceObject/Attachments/IEveSpaceObjectDecalOwner.h" @@ -385,9 +385,9 @@ BLUE_CLASS( EveSpaceObject2 ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner - IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild * child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; + void AddToEffectChildrenList( EveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -704,7 +704,7 @@ BLUE_CLASS( EveSpaceObject2 ) : ///////////////////////////////////////////////////////////////////////////////////// // Effect children - PIEveSpaceObjectChildVector m_effectChildren; + PEveSpaceObjectChildVector m_effectChildren; EveChildInheritPropertiesPtr m_inheritProperties; ///////////////////////////////////////////////////////////////////////////////////// diff --git a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h index db557831e..576624e18 100644 --- a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h +++ b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h @@ -3,7 +3,7 @@ #pragma once #include "Eve/EveUpdateContext.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #include "IEveFxAttribute.h" diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp index b809f11a4..788a34064 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp @@ -273,7 +273,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) EveChildContainerPtr layoutContainer; layoutContainer.CreateInstance(); layoutContainer->SetName( "layouts" ); - layoutContainer->SetOrigin( IEveSpaceObjectChild::SOF ); + layoutContainer->SetOrigin( EveSpaceObjectChild::SOF ); layoutContainer->SetIsPlacementRoot( true ); layoutContainer->SetAlwaysOn( true ); SetupLayout( newObj, layoutContainer, sharedMeshes, dna, centerOffset ); @@ -1719,7 +1719,7 @@ void RecursiveBindParticleEmitters( EveTransform* transform, TriCurveSet* curveS } } -void RecursiveBindParticleEmitters( IEveSpaceObjectChild* child, TriCurveSet* curveSet, Tr2CurveScalar* curve ) +void RecursiveBindParticleEmitters( EveSpaceObjectChild* child, TriCurveSet* curveSet, Tr2CurveScalar* curve ) { if( EveChildContainerPtr container = BlueCastPtr( child ) ) { @@ -1757,7 +1757,7 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild auto postCopy = m_editorMode ? &PostCopyMetadata : nullptr; std::map> childrenToBindTo; - std::map> soChildrenToBindTo; + std::map> soChildrenToBindTo; const std::vector& hullChildren = dna->GetHullChildren(); for( auto childIt = hullChildren.begin(); childIt != hullChildren.end(); ++childIt ) @@ -1805,12 +1805,12 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild obj->AddToChildrenList( transformedChild ); } } - else if( IEveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) + else if( EveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) { size_t index = 0; for( auto& offset : offsets ) { - IEveSpaceObjectChildPtr transformedChild; + EveSpaceObjectChildPtr transformedChild; if( ++index < offsets.size() ) { CCP_STATS_ZONE( "Child Copy" ); @@ -1829,7 +1829,7 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild transformedChild->Setup( &childIt->scaling, &rot, &pos, childIt->lowestLodVisible ); - transformedChild->SetOrigin( IEveSpaceObjectChild::SOF ); + transformedChild->SetOrigin( EveSpaceObjectChild::SOF ); childOwner->AddToEffectChildrenList( transformedChild ); if( childIt->id != -1 ) { @@ -1866,7 +1866,7 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild { RecursiveBindParticleEmitters( ( *transformIt ), curveSet, scalarCurve ); } - std::vector childVector = soChildrenToBindTo[animIt->id]; + std::vector childVector = soChildrenToBindTo[animIt->id]; for( auto childIt = childVector.begin(); childIt != childVector.end(); ++childIt ) { RecursiveBindParticleEmitters( ( *childIt ), curveSet, scalarCurve ); @@ -1971,11 +1971,11 @@ void EveSOF::SetupEffectChildren( EveSpaceObject2Ptr newObj, IEveEffectChildrenO newObj->AddToChildrenList( transformedChild ); } } - else if( IEveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) + else if( EveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) { for( auto& offset : offsets ) { - IEveSpaceObjectChildPtr transformedChild; + EveSpaceObjectChildPtr transformedChild; if( &offset != &offsets.back() ) { BeClasses->CopyTo( effectChild->GetRootObject(), (IRoot**)&transformedChild ); @@ -1993,7 +1993,7 @@ void EveSOF::SetupEffectChildren( EveSpaceObject2Ptr newObj, IEveEffectChildrenO transformedChild->Setup( &childSetItem.scaling, &rot, &pos, childSetItem.lowestLodVisible ); - transformedChild->SetOrigin( IEveSpaceObjectChild::SOF ); + transformedChild->SetOrigin( EveSpaceObjectChild::SOF ); childOwner->AddToEffectChildrenList( transformedChild ); } } @@ -3624,7 +3624,7 @@ void EveSOF::CreatePlacement( { sharedMeshes.CreateInstance(); sharedMeshes->SetName( "SharedInstancedMeshes" ); - sharedMeshes->SetOrigin( IEveSpaceObjectChild::SOF ); + sharedMeshes->SetOrigin( EveSpaceObjectChild::SOF ); parent->AddToEffectChildrenList( sharedMeshes ); } diff --git a/trinity/Eve/Turret/EveTurretFiringFX.h b/trinity/Eve/Turret/EveTurretFiringFX.h index 016359445..667b06389 100644 --- a/trinity/Eve/Turret/EveTurretFiringFX.h +++ b/trinity/Eve/Turret/EveTurretFiringFX.h @@ -15,8 +15,8 @@ BLUE_DECLARE_INTERFACE( IEveFiringEffectElement ); BLUE_DECLARE_IVECTOR( IEveFiringEffectElement ); BLUE_DECLARE_INTERFACE( IEveEffectChildrenOwner ); -BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); -BLUE_DECLARE_IVECTOR( IEveSpaceObjectChild ); +BLUE_DECLARE( EveSpaceObjectChild ); +BLUE_DECLARE_VECTOR( EveSpaceObjectChild ); BLUE_DECLARE( TriCurveSet ); BLUE_DECLARE( TriObserverLocal ); BLUE_DECLARE( Tr2QuadRenderer ); diff --git a/trinity/Eve/Turret/EveTurretSet.cpp b/trinity/Eve/Turret/EveTurretSet.cpp index 87efc0812..d6107a0d8 100644 --- a/trinity/Eve/Turret/EveTurretSet.cpp +++ b/trinity/Eve/Turret/EveTurretSet.cpp @@ -18,7 +18,7 @@ #include "EveTurretFiringFX.h" #include "include/TriMath.h" #include "Tr2QuadRenderer.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" CCP_STATS_DECLARED_ELSEWHERE( primitiveCount ); @@ -461,7 +461,7 @@ bool EveTurretSet::IsAmbientVisible() const } -IEveSpaceObjectChild* EveTurretSet::GetAmbientEffectOrGeneratedEffect() const +EveSpaceObjectChild* EveTurretSet::GetAmbientEffectOrGeneratedEffect() const { if( m_ambientEffectEditingMode ) { @@ -3654,12 +3654,12 @@ void EveTurretSet::SetFiringEffect( EveTurretFiringFX* firingEffect ) InitializeFiringEffect(); } -IEveSpaceObjectChild* EveTurretSet::GetAmbientEffect() +EveSpaceObjectChild* EveTurretSet::GetAmbientEffect() { return m_ambientEffect; } -void EveTurretSet::SetAmbientEffect( IEveSpaceObjectChild* ambientEffect ) +void EveTurretSet::SetAmbientEffect( EveSpaceObjectChild* ambientEffect ) { auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_ambientEffect ) ) diff --git a/trinity/Eve/Turret/EveTurretSet.h b/trinity/Eve/Turret/EveTurretSet.h index baa640760..169157903 100644 --- a/trinity/Eve/Turret/EveTurretSet.h +++ b/trinity/Eve/Turret/EveTurretSet.h @@ -283,7 +283,7 @@ BLUE_CLASS( EveTurretSet ) : void InitializeFiringEffect(); // setup the attached ambient effect void InitializeAmbientEffect(); - IEveSpaceObjectChild* GetAmbientEffectOrGeneratedEffect() const; + EveSpaceObjectChild* GetAmbientEffectOrGeneratedEffect() const; void SetAmbientEffectControllerVariableOnInstance( int index, const char* name, float value ); bool IsAmbientVisible() const; @@ -323,8 +323,8 @@ BLUE_CLASS( EveTurretSet ) : EveTurretFiringFX* GetFiringEffect(); void SetFiringEffect( EveTurretFiringFX * firingEffect ); - IEveSpaceObjectChild* GetAmbientEffect(); - void SetAmbientEffect( IEveSpaceObjectChild * ambientEffect ); + EveSpaceObjectChild* GetAmbientEffect(); + void SetAmbientEffect( EveSpaceObjectChild * ambientEffect ); // name std::string m_name; @@ -491,7 +491,7 @@ BLUE_CLASS( EveTurretSet ) : bool m_randomizeExplosionRotation; // ambient effects - IEveSpaceObjectChildPtr m_ambientEffect; + EveSpaceObjectChildPtr m_ambientEffect; EveChildInstanceContainerPtr m_generatedDistributedAmbientEffect; Matrix m_ambientOffsetMatrix; // used while editing bool m_ambientEffectEditingMode; // used for editing diff --git a/trinity/Eve/UI/EveEllipseSet.cpp b/trinity/Eve/UI/EveEllipseSet.cpp index 4e04b6070..3fde5324b 100644 --- a/trinity/Eve/UI/EveEllipseSet.cpp +++ b/trinity/Eve/UI/EveEllipseSet.cpp @@ -127,16 +127,6 @@ bool EveEllipseSet::AddEllipse( const Vector3& center, float semiMajor, float se return true; } -const char* EveEllipseSet::GetName() const -{ - return m_name.c_str(); -} - -void EveEllipseSet::SetName( const char* name ) -{ - m_name = BlueSharedString( name ); -} - EveEllipseSet::~EveEllipseSet() { // Specs may outlive via Python references @@ -400,10 +390,6 @@ void EveEllipseSet::Setup( const Vector3* scale, const Quaternion* rotation, con m_lowestLodVisible = lowestLodVisible; } -void EveEllipseSet::ChangeLOD( Tr2Lod lod ) -{ -} - IRoot* EveEllipseSet::GetID( uint16_t ) { return GetRawRoot(); diff --git a/trinity/Eve/UI/EveEllipseSet.h b/trinity/Eve/UI/EveEllipseSet.h index 2c1639d16..7a8b516e2 100644 --- a/trinity/Eve/UI/EveEllipseSet.h +++ b/trinity/Eve/UI/EveEllipseSet.h @@ -11,12 +11,12 @@ #include "Shader/Tr2EffectStateManager.h" #include "Tr2BufferAL.h" #include "EveEllipseDefinition.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" BLUE_DECLARE( EveEllipseSet ); BLUE_CLASS( EveEllipseSet ) : - public IEveSpaceObjectChild, + public EveSpaceObjectChild, public EveChildTransform, public ITr2Renderable, public IListNotify, @@ -36,9 +36,7 @@ BLUE_CLASS( EveEllipseSet ) : bool AddEllipse( const Vector3& center, float semiMajor, float semiMinor, const Vector3& planeNormal, float rotationDegrees ); ////////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild - const char* GetName() const override; - void SetName( const char* name ) override; + // EveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void GetRenderables( std::vector & renderables ) override; bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; @@ -46,7 +44,6 @@ BLUE_CLASS( EveEllipseSet ) : void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; - void ChangeLOD( Tr2Lod lod ) override; ////////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable @@ -72,7 +69,6 @@ BLUE_CLASS( EveEllipseSet ) : // INotify bool OnModified( Be::Var * val ) override; - BlueSharedString m_name; bool m_display = true; bool m_enablePicking = true; float m_depthOffset = 0.f; diff --git a/trinity/Eve/UI/EveEllipseSet_Blue.cpp b/trinity/Eve/UI/EveEllipseSet_Blue.cpp index ade0c2f04..5de0c8c52 100644 --- a/trinity/Eve/UI/EveEllipseSet_Blue.cpp +++ b/trinity/Eve/UI/EveEllipseSet_Blue.cpp @@ -9,6 +9,7 @@ const Be::ClassInfo* EveEllipseSet::ExposeToBlue() { EXPOSURE_BEGIN( EveEllipseSet, "" ) MAP_INTERFACE( EveEllipseSet ) + MAP_INTERFACE( EveSpaceObjectChild ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( ITr2Pickable ) @@ -33,5 +34,8 @@ const Be::ClassInfo* EveEllipseSet::ExposeToBlue() AddEllipse, "Adds a closed elliptical orbit in the given plane (center, semiMajor, semiMinor, planeNormal, rotationDegrees)" ); MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initializes the EveEllipseSet" ); + MAP_ATTRIBUTE( "partTag", m_partTag, "Part tag for multi-part space objects", Be::READ ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() } diff --git a/trinity/trinity.cpp b/trinity/trinity.cpp index 11142507b..8e0380eb6 100644 --- a/trinity/trinity.cpp +++ b/trinity/trinity.cpp @@ -34,7 +34,7 @@ BLUE_DEFINE_INTERFACE( IBlueObjectProxy ); #include "TriSettingsRegistrar.h" #include "Eve/IEveSpaceObject2.h" -#include "Eve/SpaceObject/Children/IEveSpaceObjectChild.h" +#include "Eve/SpaceObject/Children/EveSpaceObjectChild.h" #ifndef TRINITYNAME #error Please add TRINITYNAME= to compiler preprocessor definitions (/D) @@ -400,7 +400,7 @@ MAP_FUNCTION_AND_WRAP( "GetGrannyProductVersion", GetGrannyProductVersion, "Retu static BlueStdResult GetObjectWorldTransform( IRoot* object, Matrix& result ) { - if( IEveSpaceObjectChildPtr child = BlueCastPtr( object ) ) + if( EveSpaceObjectChildPtr child = BlueCastPtr( object ) ) { child->GetLocalToWorldTransform( result ); return BlueStdResult( BLUE_STD_RESULT_OK ); @@ -418,7 +418,7 @@ MAP_FUNCTION_AND_WRAP( "GetObjectWorldTransform", GetObjectWorldTransform, "Returns world transform for some supported object interfaces. Currently only\n" - "IEveSpaceObject2 and IEveSpaceObjectChild interfaces are supported.\n" + "IEveSpaceObject2 and EveSpaceObjectChild interfaces are supported.\n" ":param obj: blue object to get world transform from\n" ":raies TypeError: if the function does not support the object type" ); From 98f1653684cac5ba2bbe75fb465bbc649eb2b25c Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Mon, 20 Jul 2026 09:02:11 +0000 Subject: [PATCH 07/29] Add the important files --- .../Children/EveSpaceObjectChild.cpp | 151 +++++++++ .../Children/EveSpaceObjectChild.h | 319 ++++++++++++++++++ .../Children/EveSpaceObjectChild_Blue.cpp | 19 ++ 3 files changed, 489 insertions(+) create mode 100644 trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp create mode 100644 trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h create mode 100644 trinity/Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp new file mode 100644 index 000000000..26c34fa10 --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp @@ -0,0 +1,151 @@ +// Copyright © 2026 CCP ehf. + +#include "StdAfx.h" +#include "EveSpaceObjectChild.h" + + +EveSpaceObjectChild::EveSpaceObjectChild( IRoot* ) +{ +} + +const char* EveSpaceObjectChild::GetName() const +{ + return m_name.c_str(); +} + +void EveSpaceObjectChild::SetName( const char* name ) +{ + m_name = BlueSharedString( name ); +} + +void EveSpaceObjectChild::UpdateVisibility( const EveUpdateContext&, const Matrix&, Tr2Lod ) +{ +} + +void EveSpaceObjectChild::GetRenderables( std::vector& ) +{ +} + +bool EveSpaceObjectChild::GetBoundingSphere( Vector4&, BoundingSphereQuery ) const +{ + return false; +} + +void EveSpaceObjectChild::RegisterWithQuadRenderer( Tr2QuadRenderer& ) +{ +} + +void EveSpaceObjectChild::AddQuadsToQuadRenderer( const TriFrustum&, Tr2QuadRenderer& ) const +{ +} + +void EveSpaceObjectChild::UpdateSyncronous( const EveUpdateContext&, const EveChildUpdateParams& ) +{ +} + +void EveSpaceObjectChild::UpdateAsyncronous( const EveUpdateContext&, const EveChildUpdateParams& ) +{ +} + +void EveSpaceObjectChild::GetLocalToWorldTransform( Matrix& ) const +{ +} + +bool EveSpaceObjectChild::IsAlwaysOn() const +{ + return false; +}; + +void EveSpaceObjectChild::Setup( const Vector3*, const Quaternion*, const Vector3*, Tr2Lod ) +{ +} + +void EveSpaceObjectChild::ChangeLOD( Tr2Lod ) +{ +} + +void EveSpaceObjectChild::SetControllerVariable( const char*, float ) +{ +} + +void EveSpaceObjectChild::HandleControllerEvent( const char* ) +{ +} + +void EveSpaceObjectChild::StartControllers() +{ +} + +void EveSpaceObjectChild::SetProceduralContainerVariable( const char*, float ) +{ +} + +void EveSpaceObjectChild::SetShaderOption( const BlueSharedString&, const BlueSharedString& ) +{ +} + +void EveSpaceObjectChild::SetOrigin( Origin ) +{ +} + +void EveSpaceObjectChild::AddTransformModifier( IEveChildTransformModifier* ) +{ +} + +void EveSpaceObjectChild::SetMute( bool isMuted ) +{ +} + +EveSpaceObjectChild::PartTag EveSpaceObjectChild::GetPartTag() const +{ + return m_partTag; +} + +void EveSpaceObjectChild::SetPartTag( PartTag tag ) +{ + m_partTag = tag; +} + +void EveSpaceObjectChild::SetOwner( IEveSpaceObject2* owner ) +{ + m_owner = owner; +} + +IEveSpaceObject2* EveSpaceObjectChild::GetOwner() const +{ + return m_owner; +} + +void EveSpaceObjectChild::SetParent( EveSpaceObjectChild* parent ) +{ + m_parent = parent; +} + +EveSpaceObjectChild* EveSpaceObjectChild::GetParent() const +{ + return m_parent; +} + +void EveSpaceObjectChild::RegisterChild( EveSpaceObjectChild* child ) +{ + if( child ) + { + child->SetParent( this ); + child->SetOwner( m_owner ); + if( m_partTag != EveSpaceObjectChild::NO_PART_TAG ) + { + child->SetPartTag( m_partTag ); + } + } +} + +void EveSpaceObjectChild::UnregisterChild( EveSpaceObjectChild* child ) +{ + if( child ) + { + CCP_ASSERT( child->GetParent() == this ); + child->SetParent( nullptr ); + child->SetOwner( nullptr ); + // No reason to reset the part tag as it is meaningless outside the hierarchy of the parent object + } +} diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h new file mode 100644 index 000000000..25651598c --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h @@ -0,0 +1,319 @@ +// Copyright © 2026 CCP ehf. + +#pragma once + +#include "IEveSpaceObjectChild.h" + +BLUE_CLASS_IMPL( EveSpaceObjectChild ); + +/** + * @brief Base class for all space object children. This class provides common functionality and properties for all child objects in the space object hierarchy. + */ +class EveSpaceObjectChild : public IEveSpaceObjectChild +{ +public: + EXPOSE_TO_BLUE(); + + /// @brief Enum representing the origin of the space object child, i.e. how it was created: using SOF or otherwise. + enum Origin + { + SPACE, + SOF, + }; + + /// @brief Type representing a part tag, which is used to identify parts of a modular space object. + using PartTag = uint32_t; + + /// @brief Constant representing a part tag for children that are not part of a modular space object. + static const PartTag NO_PART_TAG = 0; + + EveSpaceObjectChild( IRoot* lockobj = nullptr ); + + /** + * @brief Returns the name of the space object child. This name is used for identification and debugging purposes. + */ + const char* GetName() const; + + /** + * @brief Sets the name of the space object child. This name is used for identification and debugging purposes. + * @param name The new name to set for the space object child. + */ + virtual void SetName( const char* name ); + + /** + * @brief Updates the internal visibility state (frustum culling, LOD, etc.) of the object. This method is called during rendering before GetRenderables() to determine if the object should be rendered. + * Note, that this method is called from worker threads, so care should be taken when accessing shared data. + * The default implementation does nothing, derived classes should override this method to implement visibility logic if needed. + * @param updateContext Scene-wide update context containing timing and other relevant information for the update. + * @param parentTransform Parent transformation matrix to world coordinates. + * @param parentLod Owner space object's LOD level. + */ + virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); + + /** + * @brief Pushes owned renderables to the provided vector. This method is called during rendering to collect all renderable objects for the current frame. + * The default implementation does nothing, derived classes implementing renderable features should override this method to provide their renderables. + * @param renderables Vector to which the renderables will be added. + */ + virtual void GetRenderables( std::vector& renderables ); + + /** + * @brief Retrieves the bounding sphere of the object. This method is used for frustum culling and LOD estimation. + * The default implementation does nothing, derived classes should override this method to provide their bounding sphere if available. + * @param sphere Vector4 to store the bounding sphere (x, y, z for center, w for radius). + * @param query Type of bounding sphere query. + * @return True if the bounding sphere is valid, false otherwise. + */ + virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const; + + /** + * @brief Registers effects with the quad renderer. This method is called when the child is added to the scene to allow it to register any effects that need to be rendered as quads. + * The default implementation does nothing, derived classes implementing quad rendering should override this method to register their effects with the quad renderer. + * @param quadRenderer Quad renderer to register effects with. + */ + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + + /** + * @brief Adds quads to the quad renderer for rendering. This method is called during rendering to allow the child to add any quads that need to be rendered. + * Note, that this method is called from worker threads, so care should be taken when accessing shared data. + * The default implementation does nothing, derived classes implementing quad rendering should override this method to add their quads to the quad renderer. + * @param frustum Frustum used for culling and visibility checks. + * @param quadRenderer Quad renderer to which quads will be added. + */ + virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; + + /** + * @brief Updates the state of the object. This method is called every frame from the main thread to allow the child to update its internal state, animations, etc. + * The default implementation does nothing, derived classes implementing quad rendering should override this method to add their quads to the quad renderer. + * @param updateContext Scene-wide update context containing timing and other relevant information for the update. + * @param params Space object and parent child information relevant for the update. + */ + virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); + + /** + * @brief Updates the state of the object asynchronously. This method is called from worker threads to allow the child to update its internal state, animations, etc. + * The default implementation does nothing, derived classes implementing quad rendering should override this method to add their quads to the quad renderer. + * @param updateContext Scene-wide update context containing timing and other relevant information for the update. + * @param params Space object and parent child information relevant for the update. + */ + virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); + + /** + * @brief Retrieves the local to world transformation matrix of the object. This method is poorly designed. Avoid using it if possible. Not every child has a local + * to world transformation, and this method has no way to return the failure state. The default implementation does nothing, derived classes should override this + * method to provide their local to world transformation if available. + * @param transform Matrix to store the local to world transformation. + */ + virtual void GetLocalToWorldTransform( Matrix& transform ) const; + + /** + * @brief Exotic method that is used to determine if the child needs to be always updated/rendered regardless of the owner's space object "activation strength". + * @return True if the child should always be updated/rendered, false otherwise. + */ + virtual bool IsAlwaysOn() const; + + /** + * @brief Sets up the child transform and LOD. This methods is called by the SOF when creating a child object. + * The default implementation does nothing. If the child has a transform, it should override this method to set up the transform and LOD. + * @param scale Optional scale factors (x, y, z) for the child transform. If nullptr, scaling is unaffected. + * @param rotation Optional rotation for the child transform. If nullptr, rotation is unaffected. + * @param translation Optional translation for the child transform. If nullptr, translation is unaffected. + * @param lowestLodVisible Lowest level of detail (LOD) of the owner space object that is visible for the child. + */ + virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + + /** + * @brief Notifies the child object that the level of detail (LOD) of the owner space object has changed. + * The default implementation does nothing. If the child has LOD-dependent behavior, it should override this method to respond to LOD changes. + * @param lod New level of detail (LOD) of the owner space object. + */ + virtual void ChangeLOD( Tr2Lod lod ); + + /** + * @brief Sets a controller variable for the child object. This method is called by the owner space object to update controller variables that affect the child's behavior. + * If the child owns controllers, it should override this method to propagate the variable to its controllers. Also, if the object owns other children, it should propagate the + * controller variable change to them as well. + * The default implementation does nothing. + * @param name Name of the controller variable. + * @param value Value to set for the controller variable. + */ + virtual void SetControllerVariable( const char* name, float value ); + + /** + * @brief Notifies child controllers that a controller event has occurred. This method is called by the owner space object to notify the child of controller events that may affect its behavior. + * If the child owns controllers, it should override this method to propagate the event to its controllers. Also, if the object owns other children, it should propagate the + * controller event to them as well. + * The default implementation does nothing. + * @param name Name of the controller event. + */ + virtual void HandleControllerEvent( const char* name ); + + /** + * @brief Starts controllers owned by the child object. If the child owns controllers, it should override this method to start them. Also, if the object owns other children, it should propagate the + * start command to them as well. + * The default implementation does nothing. + */ + virtual void StartControllers(); + + /** + * @brief Sets a "procedural container" variable. This method is very specific to EveChildProceduralContainer. Derived classes that own other children should override this method to propagate the call to them. + * The default implementation does nothing. + * @param name Name of the procedural container variable. + * @param value Value to set for the procedural container variable. + */ + virtual void SetProceduralContainerVariable( const char* name, float value ); + + /** + * @brief Sets a shader option for effects managed by the child object. Derived classes that manage effects (or meshes) should override this methods to set the shader option for their effects. Also, if the object + * owns other children, it should override this method to propagate the call to them. + * The default implementation does nothing. + * @param name Name of the shader option. + * @param value Value to set for the shader option. + */ + virtual void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ); + + /** + * @brief Sets the origin (creation method) of the child object. This method is called by the SOF to set the creation method of the object. + * The default implementation does nothing. + * @param origin Origin (creation method) of the child object. + */ + virtual void SetOrigin( Origin origin ); + + /** + * @brief Adds a transform modifier to the child object. If the child object supports transform modifiers, it can override this method to add the modifier to its list of modifiers. + * The default implementation does nothing. + * @param modifier New transform modifier. + */ + virtual void AddTransformModifier( IEveChildTransformModifier* modifier ); + + /** + * @brief Sets the muted state for audio emitters owned by the child object. If the child object owns audio emitters, it can override this method to set their muted state. + * Also, if the object owns other children, it should override this method to propagate the call to them. + * The default implementation does nothing. + * @param isMuted Should the audio emitters be muted (true) or unmuted (false). + */ + virtual void SetMute( bool isMuted ); + + /** + * @brief Returns the part tag of the child object for multi-part space objects. + * @return Part tag of the child object, or NO_PART_TAG if not applicable. + */ + PartTag GetPartTag() const; + + /** + * @brief Sets the part tag of the child object for multi-part space objects. Descendent classes that own other children should override this method to propagate the part tag to them. + * @param tag Part tag to set for the child object. + */ + virtual void SetPartTag( PartTag tag ); + + /** + * @brief Returns the owner space object of the child. It may return nullptr if the child is not currently attached to an owner space object. + * @return Owner space object of the child, or nullptr if not attached. + */ + IEveSpaceObject2* GetOwner() const; + + /** + * @brief Sets the owner space object of the child. Descendent classes that own other children should override this method to propagate the owner to them. + * @param owner Owner space object to set for the child. + */ + virtual void SetOwner( IEveSpaceObject2* owner ); + + /** + * @brief Returns the parent child object of this child. It may return nullptr if the child is not currently attached to a parent child object. + * @return Parent child object of this child, or nullptr if not attached. + */ + EveSpaceObjectChild* GetParent() const; + + /** + * @brief Sets the parent child object of this child. + * @param parent Parent child object to set for this child. + */ + void SetParent( EveSpaceObjectChild* parent ); + +protected: + /** + * @brief Helper function that registers a child object with this parent. Assigns the parent, owner and part tag to the child. + * @param child Child object to register. If the child is nullptr, the method does nothing. + */ + void RegisterChild( EveSpaceObjectChild* child ); + + /** + * @brief Helper function that unregisters a child object with this parent. Resets the parent and owner pointers of the child. + * @param child Child object to unregister. If the child is nullptr, the method does nothing. + */ + void UnregisterChild( EveSpaceObjectChild* child ); + + /** + * @brief Helper function that registers a sequence of child objects with this parent. Assigns the parent, owner and part tag to each child. + * @param children Sequence of child objects to register. + */ + template + void RegisterChildren( const ChildList& children ) + { + for( auto& child : children ) + { + this->RegisterChild( child ); + } + } + + /** + * @brief Helper function that unregisters a sequence of child objects with this parent. Resets the parent and owner pointers of each child. + * @param children Sequence of child objects to unregister. + */ + template + void UnregisterChildren( const ChildList& children ) + { + for( auto& child : children ) + { + this->UnregisterChild( child ); + } + } + + /** + * @brief Helper function that handles list modification notifications for a list of child objects to register and unregister children. + * @tparam ChildList Type of the list of child objects. + * @param event Event type indicating the modification. See BLUELISTEVENT for possible values. + * @param value Value associated with the event. + * @param children List of child objects for which the notification is being sent. + */ + template + void HandleChildrenListModified( + long event, // BLUELISTEVENT values + IRoot* value, + const ChildList& children ) + { + switch( event & BELIST_EVENTMASK ) + { + case BELIST_INSERTED: + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + { + this->RegisterChild( child ); + } + break; + case BELIST_REMOVED: + if( EveSpaceObjectChildPtr child = BlueCastPtr( value ) ) + { + this->UnregisterChild( child ); + } + break; + case BELIST_UNLOADSTART: + for( auto& child : children ) + { + this->UnregisterChild( child ); + } + break; + default: + break; + } + } + + BlueSharedString m_name; +private: + IEveSpaceObject2* m_owner = nullptr; + EveSpaceObjectChild* m_parent = nullptr; + PartTag m_partTag = NO_PART_TAG; +}; + +BLUE_DECLARE_VECTOR( EveSpaceObjectChild ); + +TYPEDEF_BLUECLASS( EveSpaceObjectChild ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp new file mode 100644 index 000000000..f5a5a72d9 --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp @@ -0,0 +1,19 @@ +// Copyright © 2026 CCP ehf. + +#include "StdAfx.h" +#include "EveSpaceObjectChild.h" + +BLUE_DEFINE_ABSTRACT( EveSpaceObjectChild ); + +const Be::ClassInfo* EveSpaceObjectChild::ExposeToBlue() +{ + EXPOSURE_BEGIN( EveSpaceObjectChild, "" ) + MAP_INTERFACE( EveSpaceObjectChild ) + + MAP_ATTRIBUTE( "name", m_name, "Name of the space object child", Be::READWRITE | Be::PERSIST ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) + MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) + MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) + + EXPOSURE_END() +} From d125679bab49bdfda8c8c155ee8fdc382be49d45 Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Mon, 20 Jul 2026 09:05:46 +0000 Subject: [PATCH 08/29] Format files --- trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp | 2 +- trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp index 26c34fa10..464de622b 100644 --- a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp @@ -38,7 +38,7 @@ void EveSpaceObjectChild::RegisterWithQuadRenderer( Tr2QuadRenderer& ) void EveSpaceObjectChild::AddQuadsToQuadRenderer( const TriFrustum&, Tr2QuadRenderer& ) const { } - + void EveSpaceObjectChild::UpdateSyncronous( const EveUpdateContext&, const EveChildUpdateParams& ) { } diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h index 25651598c..ef8721a7a 100644 --- a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h @@ -308,6 +308,7 @@ class EveSpaceObjectChild : public IEveSpaceObjectChild } BlueSharedString m_name; + private: IEveSpaceObject2* m_owner = nullptr; EveSpaceObjectChild* m_parent = nullptr; From 6fc4d0e28e81a419645047741dc06be0efc117d6 Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Mon, 20 Jul 2026 09:07:30 +0000 Subject: [PATCH 09/29] Use property to access the part tag --- trinity/Eve/UI/EveEllipseSet_Blue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trinity/Eve/UI/EveEllipseSet_Blue.cpp b/trinity/Eve/UI/EveEllipseSet_Blue.cpp index 5de0c8c52..c25726485 100644 --- a/trinity/Eve/UI/EveEllipseSet_Blue.cpp +++ b/trinity/Eve/UI/EveEllipseSet_Blue.cpp @@ -34,7 +34,7 @@ const Be::ClassInfo* EveEllipseSet::ExposeToBlue() AddEllipse, "Adds a closed elliptical orbit in the given plane (center, semiMajor, semiMinor, planeNormal, rotationDegrees)" ); MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initializes the EveEllipseSet" ); - MAP_ATTRIBUTE( "partTag", m_partTag, "Part tag for multi-part space objects", Be::READ ) + MAP_PROPERTY_READONLY( "partTag", GetPartTag, "Part tag for multi-part space objects" ) MAP_METHOD_AND_WRAP( "GetParent", GetParent, "Returns the parent space object child in the hierarchy" ) MAP_METHOD_AND_WRAP( "GetOwner", GetOwner, "Returns the owner space object" ) EXPOSURE_END() From 5d1cfe0956aa0f43b71d6724e0e8d4bdf9178721 Mon Sep 17 00:00:00 2001 From: filipppavlov Date: Mon, 20 Jul 2026 11:21:01 +0000 Subject: [PATCH 10/29] Potential fix for pull request finding Use `UnregisterChild` helper method Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp index e20b56091..d87867607 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp @@ -354,8 +354,7 @@ void EveChildInstanceContainer::PopFront() front->UnRegister( GetComponentRegistry() ); } } - m_instances[0]->SetOwner( nullptr ); - m_instances[0]->SetParent( nullptr ); + UnregisterChild( m_instances[0] ); m_instances.Remove( 0 ); } } From 8d7e70e3bebb970377e1c3264cfe31bd23a4b303 Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Wed, 22 Jul 2026 09:30:52 +0000 Subject: [PATCH 11/29] Rebase to main --- vendor/github.com/carbonengine/vcpkg-registry | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/github.com/carbonengine/vcpkg-registry b/vendor/github.com/carbonengine/vcpkg-registry index f503eea8c..8bd572152 160000 --- a/vendor/github.com/carbonengine/vcpkg-registry +++ b/vendor/github.com/carbonengine/vcpkg-registry @@ -1 +1 @@ -Subproject commit f503eea8c313ba8f61d97a5bb0f37e7ba69f749c +Subproject commit 8bd572152d56d5d4b26be0e129615c1c43df438e From af391b28c5eebd77abdafbf3cd1440623d7cf554 Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Fri, 24 Jul 2026 15:10:04 +0000 Subject: [PATCH 12/29] Modular object building wip --- trinity/CMakeLists.txt | 3 + trinity/Eve/EveInstancedMeshManager.h | 9 + .../Children/EveChildInstancedMeshes.cpp | 131 +++++++++- .../Children/EveChildInstancedMeshes.h | 6 +- .../SpaceObject/Children/EveChildPartData.cpp | 231 ++++++++++++++++++ .../SpaceObject/Children/EveChildPartData.h | 69 ++++++ .../Children/EveChildPartData_Blue.cpp | 35 +++ trinity/Eve/SpaceObject/EveSpaceObject2.h | 15 +- .../Eve/SpaceObject/Utils/EveLocatorSets.cpp | 10 +- .../Eve/SpaceObject/Utils/EveLocatorSets.h | 4 + trinity/Eve/SpaceObjectFactory/EveSOF.cpp | 204 +++++++++++++++- trinity/Eve/SpaceObjectFactory/EveSOF.h | 3 +- .../Eve/SpaceObjectFactory/EveSOFDataMgr.h | 3 +- 13 files changed, 709 insertions(+), 14 deletions(-) create mode 100644 trinity/Eve/SpaceObject/Children/EveChildPartData.cpp create mode 100644 trinity/Eve/SpaceObject/Children/EveChildPartData.h create mode 100644 trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp diff --git a/trinity/CMakeLists.txt b/trinity/CMakeLists.txt index af3d96fab..01c925d1e 100644 --- a/trinity/CMakeLists.txt +++ b/trinity/CMakeLists.txt @@ -546,6 +546,9 @@ set(_SOURCES Eve/SpaceObject/Children/EveChildMesh.cpp Eve/SpaceObject/Children/EveChildMesh.h Eve/SpaceObject/Children/EveChildMesh_Blue.cpp + Eve/SpaceObject/Children/EveChildPartData.cpp + Eve/SpaceObject/Children/EveChildPartData.h + Eve/SpaceObject/Children/EveChildPartData_Blue.cpp Eve/SpaceObject/Children/EveChildParticleSphere.cpp Eve/SpaceObject/Children/EveChildParticleSphere.h Eve/SpaceObject/Children/EveChildParticleSphere_Blue.cpp diff --git a/trinity/Eve/EveInstancedMeshManager.h b/trinity/Eve/EveInstancedMeshManager.h index 3b4209c66..a92ca39a0 100644 --- a/trinity/Eve/EveInstancedMeshManager.h +++ b/trinity/Eve/EveInstancedMeshManager.h @@ -55,6 +55,15 @@ class EveInstancedMeshManager other.owner = nullptr; other.index = InvalidIndex; } + DataHandle& operator=( DataHandle&& other ) + { + owner = other.owner; + index = other.index; + other.owner = nullptr; + other.index = InvalidIndex; + return *this; + } + operator bool() const { diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp index cc6915557..6dc6a9ff2 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp @@ -355,13 +355,79 @@ void EveChildInstancedMeshes::AddMesh( const Matrix* instanceTransforms, size_t count, const BlueSharedString& sofHullName, - const BlueSharedString& sofLocatorSetName ) + const BlueSharedString& sofLocatorSetName, + EveSpaceObjectChild::PartTag partTag ) { if( areaCount == 0 || count == 0 ) { return; } + for( auto& mesh : m_meshes ) + { + if( mesh.geometryPath != geometryPath || mesh.meshIndex != meshIndex ) + { + continue; + } + if( mesh.flags.GetCastsShadow() != castsShadow || mesh.reflectionMode != reflectionMode ) + { + continue; + } + if( mesh.areas.size() != areaCount ) + { + continue; + } + bool areasEqual = true; + for( size_t i = 0; i < areaCount; ++i ) + { + if( strcmp( mesh.areas[i].effect->GetEffectPathName(), areas[i].effect->GetEffectPathName() ) != 0 || mesh.areas[i].batchType != areas[i].batchType || mesh.areas[i].areaIndex != areas[i].areaIndex || mesh.areas[i].areaCount != areas[i].areaCount ) + { + areasEqual = false; + break; + } + if( mesh.areas[i].effectHash != areas[i].effect->GetHashValue() ) + { + areasEqual = false; + break; + } + } + if( !areasEqual ) + { + continue; + } + if( !( mesh.sofHullName == sofHullName && mesh.sofLocatorSetName == sofLocatorSetName ) ) + { + continue; + } + mesh.instances.reserve( mesh.instances.size() + count ); + mesh.partTags.reserve( mesh.partTags.size() + count ); + for( size_t i = 0; i < count; ++i ) + { + EveInstancedMeshManager::StaticPerInstanceData instanceData; + auto& mat = instanceTransforms[i]; + instanceData.worldTransform[0] = Vector4( mat._11, mat._21, mat._31, mat._41 ); + instanceData.worldTransform[1] = Vector4( mat._12, mat._22, mat._32, mat._42 ); + instanceData.worldTransform[2] = Vector4( mat._13, mat._23, mat._33, mat._43 ); + instanceData.sphereIndex = static_cast( i ); + mesh.instances.push_back( instanceData ); + mesh.partTags.push_back( partTag ); + } + mesh.instanceSpheres.resize( mesh.instances.size() ); + if( mesh.sphereHandle ) + { + mesh.sphereHandle.owner->RemoveBoundingSphereGroup( mesh.sphereHandle ); + } + for( auto& area : mesh.areas ) + { + if( area.meshGroupHandle ) + { + area.meshGroupHandle.owner->RemoveMeshGroup( area.meshGroupHandle ); + } + } + m_allRegistered = false; + return; + } + Mesh& mesh = m_meshes.emplace_back(); mesh.geometryPath = geometryPath; mesh.reflectionMode = reflectionMode; @@ -376,6 +442,7 @@ void EveChildInstancedMeshes::AddMesh( a.effectHash = a.effect ? a.effect->GetHashValue() : 0; } mesh.instances.reserve( count ); + mesh.partTags.reserve( count ); for( size_t i = 0; i < count; ++i ) { EveInstancedMeshManager::StaticPerInstanceData instanceData; @@ -385,6 +452,7 @@ void EveChildInstancedMeshes::AddMesh( instanceData.worldTransform[2] = Vector4( mat._13, mat._23, mat._33, mat._43 ); instanceData.sphereIndex = static_cast( i ); mesh.instances.push_back( instanceData ); + mesh.partTags.push_back( partTag ); } mesh.instanceSpheres.resize( count ); BeResMan->GetResource( mesh.geometryPath, "", mesh.geometry ); @@ -414,6 +482,67 @@ void EveChildInstancedMeshes::AddMesh( m_allRegistered = false; } +void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag partTag ) +{ + for( size_t i = 0; i < m_meshes.size(); ++i ) + { + auto& mesh = m_meshes[i]; + + auto newEnd = std::remove_if( begin( mesh.instances ), end( mesh.instances ), [&]( const EveInstancedMeshManager::StaticPerInstanceData& instance ) { + return mesh.partTags[&instance - mesh.instances.data()] == partTag; + } ); + bool removed = newEnd != end( mesh.instances ); + if( !removed ) + { + continue; + } + if( newEnd == begin( mesh.instances ) ) + { + if( mesh.sphereHandle ) + { + mesh.sphereHandle.owner->RemoveBoundingSphereGroup( mesh.sphereHandle ); + } + for( auto& area : mesh.areas ) + { + if( area.meshGroupHandle ) + { + area.meshGroupHandle.owner->RemoveMeshGroup( area.meshGroupHandle ); + } + } + std::swap( mesh, m_meshes.back() ); + auto seenMesh = find_if( begin( m_meshes ), end( m_meshes ) - 1, [&]( const Mesh& m ) { return m.geometry == mesh.geometry; } ); + if( seenMesh == end( m_meshes ) - 1 ) + { + mesh.geometry->RemoveNotifyTarget( this ); + } + m_meshes.pop_back(); + --i; + continue; + } + mesh.instances.erase( newEnd, end( mesh.instances ) ); + auto newTagEnd = std::remove_if( begin( mesh.partTags ), end( mesh.partTags ), [&]( uint32_t tag ) { + return tag == partTag; + } ); + mesh.partTags.erase( newTagEnd, end( mesh.partTags ) ); + if( removed ) + { + m_allRegistered = false; + mesh.instanceSpheres.resize( mesh.instances.size() ); + if( mesh.sphereHandle ) + { + mesh.sphereHandle.owner->RemoveBoundingSphereGroup( mesh.sphereHandle ); + } + for( auto& area : mesh.areas ) + { + if( area.meshGroupHandle ) + { + area.meshGroupHandle.owner->RemoveMeshGroup( area.meshGroupHandle ); + } + } + } + } +} + void EveChildInstancedMeshes::ReleaseCachedData( BlueAsyncRes* p ) { } diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h index 6248b4aa8..e233a5644 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h @@ -79,7 +79,10 @@ BLUE_CLASS( EveChildInstancedMeshes ) : const Matrix* instanceTransforms, size_t count, const BlueSharedString& sofHullName, - const BlueSharedString& sofLocatorSetName ); + const BlueSharedString& sofLocatorSetName, + EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG ); + + void RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag partTag ); BluePy GetSofSourceLocator( uint32_t areaId ) const; uint32_t GetMeshCount() const; @@ -103,6 +106,7 @@ BLUE_CLASS( EveChildInstancedMeshes ) : std::vector instances; std::vector instanceSpheres; + std::vector partTags; EveInstancedMeshManager::BoundingSphereHandle sphereHandle; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp new file mode 100644 index 000000000..fb109827e --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -0,0 +1,231 @@ +// Copyright © 2026 CCP ehf. + +#include "StdAfx.h" +#include "EveChildPartData.h" +#include "IEveEffectChildrenOwner.h" +#include "../EveStation2.h" +#include "EveChildInstancedMeshes.h" +#include "EveChildContainer.h" + + +EveChildPartData::EveChildPartData( IRoot* ) +{ +} + +EveSpaceObjectChild::PartTag EveChildPartData::GetUnusedPartID() const +{ + return std::accumulate( m_parts.begin(), m_parts.end(), 1u, []( EveSpaceObjectChild::PartTag maxId, const PartData& part ) { + return std::max( maxId, part.partId + 1 ); + } ); +} + + + +void EveModularObjectModifier::Create( SpaceObjectType* object, EveSOF* sof ) +{ + m_object = object; + m_sof = sof; + for( auto& child : object->GetEffectChildren() ) + { + if( EveChildPartDataPtr partData = BlueCastPtr( child ) ) + { + m_data = partData; + break; + } + } + for( auto& child : object->GetEffectChildren() ) + { + if( EveChildInstancedMeshesPtr instancedMeshes = BlueCastPtr( child ) ) + { + m_instancedMeshes = instancedMeshes; + break; + } + } +} + +EveModularObjectModifier::~EveModularObjectModifier() +{ + if ( m_object ) + { + CcpMath::Sphere bounds; + for( auto& part : m_data->m_parts ) + { + bounds.Include( part.boundingSphere ); + } + m_object->SetBoundingSphereInformation( bounds ); + } +} + +EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ) +{ + auto id = m_data->GetUnusedPartID(); + auto size = m_object->GetEffectChildren().size(); + auto dna = std::string( hullName ) + ":" + ( factionName[0] ? factionName : m_data->m_faction.c_str() ) + ":" + ( raceName[0] ? raceName : m_data->m_race.c_str() ); + if ( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ) ) ) + { + // TODO: return error + return 0; + } + + if( !m_instancedMeshes ) + { + for( size_t i = size; i < m_object->GetEffectChildren().size(); ++i ) + { + if( EveChildInstancedMeshesPtr instancedMesh = BlueCastPtr( m_object->GetEffectChildren()[i] ) ) + { + m_instancedMeshes = instancedMesh; + break; + } + } + } + + // SOF will reset the bounding sphere of the object to the one of the part + // Store the part bounding sphere and recalculate the bounding sphere of the modular object after adding all the parts + CcpMath::Sphere sphere{ m_object->GetBoundingSphereCenter(), m_object->GetBoundingSphereRadius() }; + + auto part = EveChildPartData::PartData{ id, position, rotation, scale, sphere }; + m_data->m_parts.emplace_back( part ); + return id; +} + +EveSpaceObjectChild::PartTag EveModularObjectModifier::AddChild( const char* resPath, const Vector3& position, const Quaternion& rotation, const Vector3& scale ) +{ + if( auto child = BeResMan->LoadObject( resPath ) ) + { + child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); + m_object->AddToEffectChildrenList( child ); + auto id = m_data->GetUnusedPartID(); + m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, position, rotation, scale } ); + return id; + } + // TODO: return error + return 0; +} + +BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag partId ) +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + + for( size_t i = 0; i < m_object->GetEffectChildren().size(); ) + { + auto child = m_object->GetEffectChildren()[i]; + if( child->GetPartTag() == partId ) + { + m_object->RemoveFromEffectChildrenList( child ); + continue; + } + ++i; + } + + for ( auto& set : m_object->GetLocatorSets() ) + { + auto& locators = *set->GetLocators(); + auto removed = std::remove_if( locators.begin(), locators.end(), [partId]( const auto& locator ) { + return locator.partTag == partId; + } ); + locators.Resize( std::distance( removed, locators.end() ) ); + } + + if( m_instancedMeshes ) + { + m_instancedMeshes->RemoveInstancesByPartTag( partId ); + } + m_data->m_parts.erase( found ); + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + +BlueStdResult EveModularObjectModifier::SetTransform( EveSpaceObjectChild::PartTag partId, const Vector3& position, const Quaternion& rotation, Vector3 scale ) +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + found->position = position; + found->rotation = rotation; + found->scale = scale; + + for( auto& child : m_object->GetEffectChildren() ) + { + if( child->GetPartTag() == partId ) + { + child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); + } + } + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + +BlueStdResult EveModularObjectModifier::GetPosition( EveSpaceObjectChild::PartTag partId, Vector3& position ) const +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + position = found->position; + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + +BlueStdResult EveModularObjectModifier::GetRotation( EveSpaceObjectChild::PartTag partId, Quaternion& rotation ) const +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + rotation = found->rotation; + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + +BlueStdResult EveModularObjectModifier::GetScale( EveSpaceObjectChild::PartTag partId, Vector3& scale ) const +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + scale = found->scale; + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + + +std::pair CreateModularObject( EveSOF* sof, const char* factionName, const char* raceName ) +{ + EveStation2Ptr object; + object.CreateInstance(); + object->Initialize(); + + EveChildPartDataPtr partData; + partData.CreateInstance(); + partData->m_faction = factionName; + partData->m_race = raceName; + + object->AddToEffectChildrenList( partData ); + + EveModularObjectModifierPtr modifier; + modifier.CreateInstance(); + modifier->Create( object, sof ); + return { IEveSpaceObject2Ptr( object ), modifier }; +} + +EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ) +{ + EveModularObjectModifierPtr modifier; + modifier.CreateInstance(); + modifier->Create( object, sof ); + return modifier; +} \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.h b/trinity/Eve/SpaceObject/Children/EveChildPartData.h new file mode 100644 index 000000000..8dff07dc5 --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.h @@ -0,0 +1,69 @@ +// Copyright © 2026 CCP ehf. + +#pragma once + +#include "EveSpaceObjectChild.h" +#include "../../SpaceObjectFactory/EveSOF.h" + + +BLUE_CLASS_IMPL( EveChildPartData ); +class EveChildPartData : public EveSpaceObjectChild +{ +public: + EveChildPartData( IRoot* lockobj = nullptr ); + + EXPOSE_TO_BLUE(); + + PartTag GetUnusedPartID() const; + + std::string m_faction; + std::string m_race; + + struct PartData + { + PartTag partId; + Vector3 position; + Quaternion rotation; + Vector3 scale; + CcpMath::Sphere boundingSphere; + }; + std::vector m_parts; +}; + +TYPEDEF_BLUECLASS( EveChildPartData ); + + +BLUE_CLASS_IMPL( EveModularObjectModifier ); +class EveModularObjectModifier : public IRoot +{ +public: + using SpaceObjectType = EveSpaceObject2; + + EXPOSE_TO_BLUE(); + + void Create( SpaceObjectType* object, EveSOF* sof ); + ~EveModularObjectModifier(); + + + EveSpaceObjectChild::PartTag AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); + EveSpaceObjectChild::PartTag AddChild( const char* resPath, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); + BlueStdResult Remove( EveSpaceObjectChild::PartTag partId ); + + BlueStdResult SetTransform( EveSpaceObjectChild::PartTag partId, const Vector3& position, const Quaternion& rotation, Vector3 scale ); + BlueStdResult GetPosition( EveSpaceObjectChild::PartTag partId, Vector3& position ) const; + BlueStdResult GetRotation( EveSpaceObjectChild::PartTag partId, Quaternion& rotation ) const; + BlueStdResult GetScale( EveSpaceObjectChild::PartTag partId, Vector3& scale ) const; + +private: + EveChildPartData::PartData* FindPartData( EveSpaceObjectChild::PartTag partId ) const; + + BluePtr m_object; + EveChildPartDataPtr m_data; + EveChildInstancedMeshesPtr m_instancedMeshes; + EveSOFPtr m_sof; +}; + +TYPEDEF_BLUECLASS( EveModularObjectModifier ); + +std::pair CreateModularObject( EveSOF* sof, const char* factionName, const char* raceName ); +EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp new file mode 100644 index 000000000..77834b81c --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp @@ -0,0 +1,35 @@ +// Copyright © 2026 CCP ehf. + +#include "StdAfx.h" +#include "EveChildPartData.h" + + +BLUE_DEFINE( EveChildPartData ); + +const Be::ClassInfo* EveChildPartData::ExposeToBlue() +{ + EXPOSURE_BEGIN( EveChildPartData, "" ) + MAP_INTERFACE( EveSpaceObjectChild ); + MAP_INTERFACE( IEveSpaceObjectChild ) + EXPOSURE_END() +} + + +BLUE_DEFINE_NONEXPOSED( EveModularObjectModifier ); + +const Be::ClassInfo* EveModularObjectModifier::ExposeToBlue() +{ + EXPOSURE_BEGIN( EveModularObjectModifier, "" ) + MAP_METHOD_AND_WRAP( "AddHull", AddHull, "" ); + MAP_METHOD_AND_WRAP( "AddChild", AddChild, "" ) + MAP_METHOD_AND_WRAP( "Remove", Remove, "" ) + MAP_METHOD_AND_WRAP( "SetTransform", SetTransform, "" ) + MAP_METHOD_AND_WRAP( "GetPosition", GetPosition, "" ) + MAP_METHOD_AND_WRAP( "GetRotation", GetRotation, "" ) + MAP_METHOD_AND_WRAP( "GetScale", GetScale, "" ) + + EXPOSURE_END() +} + +MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, "" ); +MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "" ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.h b/trinity/Eve/SpaceObject/EveSpaceObject2.h index d06f06f95..98431480e 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.h +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.h @@ -388,6 +388,10 @@ BLUE_CLASS( EveSpaceObject2 ) : EveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; void AddToEffectChildrenList( EveSpaceObjectChild * child ); void RemoveFromEffectChildrenList( EveSpaceObjectChild * child ); + PEveSpaceObjectChildVector& GetEffectChildren() + { + return m_effectChildren; + } ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -454,6 +458,11 @@ BLUE_CLASS( EveSpaceObject2 ) : const LocatorStructureList* GetLocatorsForSet( const BlueSharedString& setName ) const; void MergeToLocatorSet( const EveLocatorSets& locatorSet ); + PEveLocatorSetsVector& GetLocatorSets() + { + return m_locatorSets; + } + // clear stuff void ClearLocatorSets(); @@ -532,6 +541,9 @@ BLUE_CLASS( EveSpaceObject2 ) : void SetMute( bool isMute ); + float GetBoundingSphereRadius() const; + Vector3 GetBoundingSphereCenter() const; + protected: // Activation-Strength float m_activationStrength; @@ -629,9 +641,6 @@ BLUE_CLASS( EveSpaceObject2 ) : bool m_allAreasCastShadow; void CacheAllAreasCastShadow(); - float GetBoundingSphereRadius() const; - Vector3 GetBoundingSphereCenter() const; - Vector4 CalculateSkinnedBoundingSphere(); std::pair CalculateSkinnedBoundingBoxFromTransform( const Matrix& transform ); diff --git a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp index d59caa871..d3086732e 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp @@ -3,12 +3,15 @@ #include "StdAfx.h" #include "EveLocatorSets.h" -// locator item definition +static_assert( sizeof( EveSpaceObjectChild::PartTag ) == sizeof( uint32_t ), "Size mismatch for PartTag: need to update LocatorStructureDef" ); + + // locator item definition static BlueStructureDefinition LocatorStructureDef[] = { { "position", Be::FLOAT32_3, 0 }, { "direction", Be::FLOAT32_4, 12 }, { "scale", Be::FLOAT32_3, 28 }, { "boneIndex", Be::INT32_1, 40 }, + { "partTag", Be::UINT32_1, 44 }, { 0 } }; @@ -78,6 +81,11 @@ const LocatorStructureList* EveLocatorSets::GetLocators() const return &m_locators; } +LocatorStructureList* EveLocatorSets::GetLocators() +{ + return &m_locators; +} + const char* EveLocatorSets::GetName() const { return m_name.c_str(); diff --git a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h index e844ece6b..f8af43494 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h +++ b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h @@ -4,6 +4,8 @@ #ifndef EveLocatorSets_H #define EveLocatorSets_H +#include "../Children/EveSpaceObjectChild.h" + // decalre structured list here struct Locator { @@ -11,6 +13,7 @@ struct Locator Quaternion direction; Vector3 scale; int boneIndex; + EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG; }; BLUE_DECLARE_STRUCTURE_LIST( Locator ); @@ -37,6 +40,7 @@ BLUE_CLASS( EveLocatorSets ) : bool HasName( const char* name ) const; bool HasName( const BlueSharedString& name ) const; const LocatorStructureList* GetLocators() const; + LocatorStructureList* GetLocators(); const char* GetName() const; void SetName( BlueSharedString name ); diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp index 788a34064..b7afc217a 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp @@ -303,8 +303,199 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) return newObj->GetRawRoot(); } +bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_t partTag, const Matrix& transform ) +{ + std::string s = "BuildChild "; + s += std::string( dnaString ); + CCP_STATS_ZONE( s.c_str() ); + + EveSOFDNAPtr dna = CreateDna( dnaString ); + if( dna == nullptr ) + { + return false; + } + dna->SetParentBoundingSphere( {} ); + dna->SetParentShapeEllipsoidInfo( {} ); + + EveChildInstancedMeshesPtr sharedMeshes; + for( auto& child : newObj->GetEffectChildren() ) + { + if( EveChildInstancedMeshesPtr instancedMeshes = BlueCastPtr( child ) ) + { + sharedMeshes = instancedMeshes; + break; + } + } + + const bool hasChildEffects = ( !dna->GetHullChildSets().empty() && dna->UsingSof6() ) || ( !dna->GetHullChildren().empty() && !dna->UsingSof6() ); + const bool hasControllers = !dna->GetHullControllers().empty(); + const bool hasAnimation = dna->IsHullAnimated(); + const bool hasEmitters = !dna->GetHullSoundEmitters().empty(); + const bool hasLayouts = dna->GetLayoutCount() > 0; + bool hasAttachments = false; + for( size_t hullIdx = 0; hullIdx < dna->GetMultiHullCount(); ++hullIdx ) + { + if( !dna->GetHullSpriteSets( hullIdx ).empty() || + !dna->GetHullSpotlightSets( hullIdx ).empty() || + !dna->GetHullPlaneSets( hullIdx ).empty() || + !dna->GetHullSpriteLineSets( hullIdx ).empty() || + !dna->GetHullHazeSets( hullIdx ).empty() || + !dna->GetHullBanners( hullIdx ).empty() || + !dna->GetHullBannerSets( hullIdx ).empty() || + !dna->GetHullLightSets( hullIdx ).empty() ) + { + hasAttachments = true; + break; + } + } + + std::vector placementOffsets = { transform }; + + const bool needsPlacementContainer = hasControllers || hasAnimation || hasEmitters || hasChildEffects || hasLayouts || hasAttachments; + const uint32_t buildFlags = !hasAnimation ? EveSOFDataHullBuildFilter::INSTANCED_PLACEMENT : EveSOFDataHullBuildFilter::NON_INSTANCED_PLACEMENT; + + Quaternion rotation; + Vector3 translation; + Vector3 scale; + Decompose( scale, rotation, translation, transform ); + + EveChildContainerPtr placementContainer; + if( needsPlacementContainer ) + { + placementContainer.CreateInstance(); + placementContainer->SetName( dna->GetHullNames()[0].c_str() ); + placementContainer->SetPartTag( partTag ); + placementContainer->SetupWithStaticTransform( &scale, &rotation, &translation, Tr2Lod::TR2_LOD_LOW ); + newObj->AddToEffectChildrenList( placementContainer ); + } + + if( hasAnimation ) + { + // create the child normally + // create the non instanced extension mesh + EveChildMeshPtr child; + child.CreateInstance(); + auto mesh = CreateMesh( dna ); + child->SetMesh( mesh ); + child->SetReflectionMode( dna->GetReflectionMode() ); + child->SetCastShadow( dna->CastShadow() ); + child->SetMinScreenSize( MIN_MESH_SCREEN_SIZE ); + child->SetName( dna->GetHullNames()[0].c_str() ); + if( !placementContainer ) + { + child->SetupWithStaticTransform( &scale, &rotation, &translation, Tr2Lod::TR2_LOD_LOW ); + } + child->SetPartTag( partTag ); + + if( m_editorMode ) + { + IWeakObjectPtr weak = BlueCastPtr( child ); + BeObjectMetadata->Set( weak, "SofDna", dna->GetDnaString() ); + } + Tr2GrannyAnimationPtr animationPtr; + animationPtr.CreateInstance(); + child->SetAnimationController( animationPtr ); + // This will set the child as the animation owner of the parent, don't think this will be a problem... + placementContainer->SetAnimationOwner( child ); + + SetupDecalSets( BlueCastPtr( child->GetRawRoot() ), dna ); + SetupAttachments( BlueCastPtr( child->GetRawRoot() ), dna, { IdentityMatrix() }, buildFlags ); + placementContainer->AddToEffectChildrenList( child ); + } + else + { + if( !sharedMeshes ) + { + sharedMeshes.CreateInstance(); + sharedMeshes->SetName( "SharedInstancedMeshes" ); + sharedMeshes->SetOrigin( EveSpaceObjectChild::SOF ); + newObj->AddToEffectChildrenList( sharedMeshes ); + } + + TriBatchType types[] = { + TRIBATCHTYPE_OPAQUE, TRIBATCHTYPE_DECAL, TRIBATCHTYPE_TRANSPARENT, TRIBATCHTYPE_ADDITIVE, TRIBATCHTYPE_DISTORTION + }; + std::vector areas; + for( auto type : types ) + { + CTr2MeshAreaVector meshAreas; + // We are purpusely ignoring multi-hull logic assuming shared instanced meshes are single hull only + FillMeshAreaVector( &meshAreas, type, dna, 0, 0 ); + for( auto area : meshAreas ) + { + auto effect = area->GetMaterialInterface(); + effect->SetOption( BlueSharedString( "SPACE_OBJECT_INSTANCED_ATTACHMENT" ), BlueSharedString( "SOIA_SHARED" ) ); + areas.push_back( EveChildInstancedMeshes::MeshArea{ effect, type == TRIBATCHTYPE_DECAL ? TRIBATCHTYPE_OPAQUE : type, uint32_t( area->GetIndex() ), uint32_t( area->GetCount() ) } ); + } + } + sharedMeshes->AddMesh( + dna->GetHullGeometryResPath().c_str(), + dna->CastShadow(), + dna->GetReflectionMode(), + 0, + areas.data(), + areas.size(), + placementOffsets.data(), + 1, + m_editorMode ? BlueSharedString( dna->GetHullNames()[0].c_str() ) : BlueSharedString(), + BlueSharedString(), + partTag ); + + SetupAttachments( BlueCastPtr( placementContainer ), dna, placementOffsets, buildFlags ); + } + + CcpMath::Sphere instanceSphere( dna->GetHullBoundingSphere() ); + instanceSphere.Transform( transform ); + + // update the bounding sphere of the parent + newObj->SetBoundingSphereInformation( instanceSphere ); + + // update the shield ellipsoid of the parent + { + CcpMath::AxisAlignedBox instanceBox( instanceSphere ); + if( dna->GetHullShapeEllipsoid() ) + { + instanceBox = CcpMath::AxisAlignedBox( dna->GetHullShapeEllipsoid() ); + instanceBox.Transform( transform ); + } + + // include the instance box in the ellipsoid + CcpMath::AxisAlignedEllipsoid updatedEllipsoid; + updatedEllipsoid.IncludeBox( instanceBox ); + newObj->SetShapeEllipsoid( updatedEllipsoid ); + dna->SetParentShapeEllipsoidInfo( updatedEllipsoid ); + } + + if( hasControllers ) + { + // Controllers! + SetupControllers( BlueCastPtr( placementContainer->GetRawRoot() ), dna, buildFlags ); + } + + // And last but not least! AUDIO! + SetupAudio( BlueCastPtr( placementContainer ), dna, transform ); + + + //SetupInstancedMeshes( newObj, dna, placementOffsets ); + + if( hasChildEffects ) + { + SetupEffects( newObj, (IEveEffectChildrenOwnerPtr)placementContainer, dna, placementOffsets, buildFlags ); + } + + //SetupCustomMask( newObj, dna ); + SetupLocatorSets( newObj, dna, placementOffsets, partTag ); + // setup nested layout + SetupLayout( newObj, placementContainer, sharedMeshes, dna, placementOffsets ); + return true; +} + void EveSOF::SetupAttachments( IEveSpaceObjectAttachmentOwnerPtr newObj, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t buildFlags ) const { + if( !newObj ) + { + return; + } // Add all the fluff! SetupSpriteSets( newObj, dna, offsets, buildFlags ); SetupSpotlightSets( newObj, dna, offsets, buildFlags ); @@ -2980,7 +3171,7 @@ void EveSOF::SetupLocators( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) con // Description: // add the hull locator sets to the new ship // -------------------------------------------------------------------------------- -void EveSOF::SetupLocatorSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets ) +void EveSOF::SetupLocatorSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets, EveSpaceObjectChild::PartTag partTag ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -3006,10 +3197,11 @@ void EveSOF::SetupLocatorSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, c distributedLocators.reserve( offsets.size() * locators->size() ); for( auto& offset : offsets ) { - std::transform( ( *locators ).begin(), ( *locators ).end(), std::back_inserter( distributedLocators ), [offset, hullOffset]( EveSOFDataMgr::LocatorDirectionData d ) -> EveSOFDataMgr::LocatorDirectionData { + std::transform( ( *locators ).begin(), ( *locators ).end(), std::back_inserter( distributedLocators ), [offset, hullOffset, partTag]( EveSOFDataMgr::LocatorDirectionData d ) -> EveSOFDataMgr::LocatorDirectionData { Matrix m = TransformationMatrix( Vector3( 1.0, 1.0, 1.0 ), d.rotation, d.position + hullOffset ) * offset; Vector3 tmp; Decompose( tmp, d.rotation, d.position, m ); + d.partTag = partTag; return d; } ); } @@ -3686,8 +3878,8 @@ void EveSOF::CreatePlacement( BeObjectMetadata->Set( weak, "SofLocatorSetName", placement.locatorSetName.c_str() ); } - layoutContainer->AddToEffectChildrenList( child ); - } + layoutContainer->AddToEffectChildrenList( child ); + } SetupAttachments( BlueCastPtr( layoutContainer->GetRawRoot() ), extensionDna, placementOffsets, buildFlags ); } @@ -3730,8 +3922,8 @@ void EveSOF::CreatePlacement( // we don't really know until now if we have an empty placement container if( !placementContainer->Empty() ) { - layoutContainer->AddToEffectChildrenList( placementContainer ); - } + layoutContainer->AddToEffectChildrenList( placementContainer ); + } } } diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.h b/trinity/Eve/SpaceObjectFactory/EveSOF.h index afa18c47b..fb3e97a62 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.h @@ -45,6 +45,7 @@ BLUE_CLASS( EveSOF ) : IRootPtr Build( const char* hullName, const char* factionName, const char* raceName ); // build a spaceship from a dns string and return a EveShip2 object IRootPtr BuildFromDNA( const char* dnaString ); + bool BuildChild( EveSpaceObject2* owner, const char* dnaString, uint32_t partTag, const Matrix& transform ); // validate a dna string (slow!) bool ValidateDNA( const char* dnaString ); @@ -104,7 +105,7 @@ BLUE_CLASS( EveSOF ) : void SetupDecalSets( IEveSpaceObjectDecalOwnerPtr obj, const EveSOFDNAPtr dna ) const; void SetupModelCurves( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const; void SetupLocators( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const; - void SetupLocatorSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets ); + void SetupLocatorSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets, EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG ); void SetupImpactEffects( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const; void SetupLights( ITr2LightOwnerPtr obj, const EveSOFDNAPtr dna, const std::vector& offsets ) const; void SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutContainer, EveChildInstancedMeshesPtr & sharedMeshes, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t seedOverwrite = 0 ); diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h index cadfd89e9..63888cfe3 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h @@ -38,10 +38,11 @@ BLUE_CLASS( EveSOFDataMgr ) : Vector3 scaling; int32_t boneIndex; int32_t uniqueID; + EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG; operator Locator() const { - return Locator{ position, rotation, scaling, boneIndex }; + return Locator{ position, rotation, scaling, boneIndex, partTag }; }; }; From dad3a521db6079561313b62a5efcc0d953f5fc3a Mon Sep 17 00:00:00 2001 From: Filipp Pavlov Date: Fri, 24 Jul 2026 15:21:37 +0000 Subject: [PATCH 13/29] Transform locators --- .../SpaceObject/Children/EveChildPartData.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index fb109827e..32320f4fe 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -6,6 +6,7 @@ #include "../EveStation2.h" #include "EveChildInstancedMeshes.h" #include "EveChildContainer.h" +#include EveChildPartData::EveChildPartData( IRoot* ) @@ -149,6 +150,27 @@ BlueStdResult EveModularObjectModifier::SetTransform( EveSpaceObjectChild::PartT { return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; } + + cmf::Transform oldTransform{ found->position, found->rotation, found->scale }; + cmf::Transform newTransform{ position, rotation, scale }; + auto invOldTransform = cmf::Inverse( oldTransform ); + + for( auto& set : m_object->GetLocatorSets() ) + { + auto& locators = *set->GetLocators(); + for( auto& locator : locators ) + { + if( locator.partTag == partId ) + { + locator.scale.x = scale.x / found->scale.x; + locator.scale.y = scale.y / found->scale.y; + locator.scale.z = scale.z / found->scale.z; + locator.direction = invOldTransform.rotation * rotation; + locator.position = cmf::TransformPoint( cmf::TransformPoint( locator.position, invOldTransform ), newTransform ); + } + } + } + found->position = position; found->rotation = rotation; found->scale = scale; From 7b373924c7fdf921b22c75ca033d21212a9358bc Mon Sep 17 00:00:00 2001 From: breki Date: Thu, 6 Aug 2026 14:42:52 +0000 Subject: [PATCH 14/29] unregister child assert allows get parent nullptr as well --- trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp index 464de622b..3e34c6855 100644 --- a/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp +++ b/trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.cpp @@ -143,7 +143,7 @@ void EveSpaceObjectChild::UnregisterChild( EveSpaceObjectChild* child ) { if( child ) { - CCP_ASSERT( child->GetParent() == this ); + CCP_ASSERT( child->GetParent() == this || child->GetParent() == nullptr ); child->SetParent( nullptr ); child->SetOwner( nullptr ); // No reason to reset the part tag as it is meaningless outside the hierarchy of the parent object From 5c7fd6c24a7fbbdb45cfe5217e78ff013d691b95 Mon Sep 17 00:00:00 2001 From: breki Date: Fri, 7 Aug 2026 09:35:46 +0000 Subject: [PATCH 15/29] add invalid part tag for error messages --- .../SpaceObject/Children/EveChildPartData.cpp | 16 +++++++++------- .../Eve/SpaceObject/Children/EveChildPartData.h | 6 +++++- .../Children/EveChildPartData_Blue.cpp | 4 +++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 32320f4fe..44d44353c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -46,7 +46,7 @@ void EveModularObjectModifier::Create( SpaceObjectType* object, EveSOF* sof ) EveModularObjectModifier::~EveModularObjectModifier() { - if ( m_object ) + if( m_object ) { CcpMath::Sphere bounds; for( auto& part : m_data->m_parts ) @@ -62,10 +62,9 @@ EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hull auto id = m_data->GetUnusedPartID(); auto size = m_object->GetEffectChildren().size(); auto dna = std::string( hullName ) + ":" + ( factionName[0] ? factionName : m_data->m_faction.c_str() ) + ":" + ( raceName[0] ? raceName : m_data->m_race.c_str() ); - if ( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ) ) ) + if( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ) ) ) { - // TODO: return error - return 0; + return INVALID_PART_TAG; } if( !m_instancedMeshes ) @@ -99,8 +98,7 @@ EveSpaceObjectChild::PartTag EveModularObjectModifier::AddChild( const char* res m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, position, rotation, scale } ); return id; } - // TODO: return error - return 0; + return INVALID_PART_TAG; } BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag partId ) @@ -124,7 +122,7 @@ BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag par ++i; } - for ( auto& set : m_object->GetLocatorSets() ) + for( auto& set : m_object->GetLocatorSets() ) { auto& locators = *set->GetLocators(); auto removed = std::remove_if( locators.begin(), locators.end(), [partId]( const auto& locator ) { @@ -250,4 +248,8 @@ EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::Space modifier.CreateInstance(); modifier->Create( object, sof ); return modifier; +} +EveSpaceObjectChild::PartTag GetInvalidPartTag() +{ + return EveModularObjectModifier::INVALID_PART_TAG; } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.h b/trinity/Eve/SpaceObject/Children/EveChildPartData.h index 8dff07dc5..d89dcb60c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.h @@ -44,6 +44,7 @@ class EveModularObjectModifier : public IRoot void Create( SpaceObjectType* object, EveSOF* sof ); ~EveModularObjectModifier(); + static constexpr EveSpaceObjectChild::PartTag INVALID_PART_TAG = 0xFFFFFFFF; EveSpaceObjectChild::PartTag AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); EveSpaceObjectChild::PartTag AddChild( const char* resPath, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); @@ -66,4 +67,7 @@ class EveModularObjectModifier : public IRoot TYPEDEF_BLUECLASS( EveModularObjectModifier ); std::pair CreateModularObject( EveSOF* sof, const char* factionName, const char* raceName ); -EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ); \ No newline at end of file +EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ); + +// Wrapper function because blue doesn't support exporting const variables +EveSpaceObjectChild::PartTag GetInvalidPartTag(); diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp index 77834b81c..906ff198e 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp @@ -32,4 +32,6 @@ const Be::ClassInfo* EveModularObjectModifier::ExposeToBlue() } MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, "" ); -MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "" ); \ No newline at end of file +MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "" ); + +MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the NO_PART_TAG constant" ); \ No newline at end of file From 6137ec72a3504654a737f86ba593d23ed4d0985a Mon Sep 17 00:00:00 2001 From: breki Date: Wed, 12 Aug 2026 09:25:54 +0000 Subject: [PATCH 16/29] keep locator order on remove --- trinity/Eve/SpaceObject/Children/EveChildPartData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 44d44353c..2c2d477be 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -128,7 +128,7 @@ BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag par auto removed = std::remove_if( locators.begin(), locators.end(), [partId]( const auto& locator ) { return locator.partTag == partId; } ); - locators.Resize( std::distance( removed, locators.end() ) ); + locators.Resize( std::distance( locators.begin(), removed ) ); } if( m_instancedMeshes ) From 858859562d2ce0c005770c8372e9d157db4fe93a Mon Sep 17 00:00:00 2001 From: breki Date: Wed, 12 Aug 2026 11:48:47 +0000 Subject: [PATCH 17/29] build shapeEllipsoid on modifier deletion like how boundingSphere was already doing it --- trinity/Eve/SpaceObject/Children/EveChildPartData.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 2c2d477be..60d3e26f3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -49,11 +49,14 @@ EveModularObjectModifier::~EveModularObjectModifier() if( m_object ) { CcpMath::Sphere bounds; + CcpMath::AxisAlignedBox box; for( auto& part : m_data->m_parts ) { bounds.Include( part.boundingSphere ); + box.IncludeSphere( part.boundingSphere ); } m_object->SetBoundingSphereInformation( bounds ); + m_object->SetShapeEllipsoid( m_data->m_parts.empty() ? CcpMath::AxisAlignedEllipsoid{} : CcpMath::AxisAlignedEllipsoid{ box, true } ); } } From 4aa827e3117308ac82e5a2e44d00e8928b370a9a Mon Sep 17 00:00:00 2001 From: breki Date: Wed, 12 Aug 2026 15:41:33 +0000 Subject: [PATCH 18/29] apply boundingsphere transform correctly on SetTransform --- trinity/Eve/SpaceObject/Children/EveChildPartData.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 60d3e26f3..11028b56b 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -172,6 +172,9 @@ BlueStdResult EveModularObjectModifier::SetTransform( EveSpaceObjectChild::PartT } } + found->boundingSphere.center = cmf::TransformPoint( cmf::TransformPoint( found->boundingSphere.center, invOldTransform ), newTransform ); + found->boundingSphere.radius *= std::max( { scale.x, scale.y, scale.z } ) / std::max( { found->scale.x, found->scale.y, found->scale.z } ); + found->position = position; found->rotation = rotation; found->scale = scale; From ed89d23185a7f4976d33a29cb8f525473ca56b3a Mon Sep 17 00:00:00 2001 From: breki Date: Thu, 13 Aug 2026 10:34:42 +0000 Subject: [PATCH 19/29] Set the part tag for the child when adding children --- trinity/Eve/SpaceObject/Children/EveChildPartData.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 11028b56b..07bb734e8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -98,6 +98,7 @@ EveSpaceObjectChild::PartTag EveModularObjectModifier::AddChild( const char* res child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); m_object->AddToEffectChildrenList( child ); auto id = m_data->GetUnusedPartID(); + child->SetPartTag( id ); m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, position, rotation, scale } ); return id; } From 7f52c362177e1d2fe3d6306c18389cfdda166460 Mon Sep 17 00:00:00 2001 From: breki Date: Thu, 13 Aug 2026 10:54:51 +0000 Subject: [PATCH 20/29] Fix issue where boundingsphere that fully encapsulates a smaller boundsphere wasn't being applied --- .../Eve/SpaceObject/Children/EveChildPartData.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 07bb734e8..937e11e02 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -48,12 +48,20 @@ EveModularObjectModifier::~EveModularObjectModifier() { if( m_object ) { + std::vector orderedParts; + orderedParts.reserve( m_data->m_parts.size() ); + for( const auto& part : m_data->m_parts ) + orderedParts.push_back( &part ); + std::sort( orderedParts.begin(), orderedParts.end(), []( const auto* a, const auto* b ) { + return a->boundingSphere.radius > b->boundingSphere.radius; + } ); + CcpMath::Sphere bounds; CcpMath::AxisAlignedBox box; - for( auto& part : m_data->m_parts ) + for( const auto* part : orderedParts ) { - bounds.Include( part.boundingSphere ); - box.IncludeSphere( part.boundingSphere ); + bounds.Include( part->boundingSphere ); + box.IncludeSphere( part->boundingSphere ); } m_object->SetBoundingSphereInformation( bounds ); m_object->SetShapeEllipsoid( m_data->m_parts.empty() ? CcpMath::AxisAlignedEllipsoid{} : CcpMath::AxisAlignedEllipsoid{ box, true } ); From 6f2ab51d3cf0c49ac1f9de789f748264c7b238ea Mon Sep 17 00:00:00 2001 From: breki Date: Tue, 18 Aug 2026 09:27:10 +0000 Subject: [PATCH 21/29] handle layout part tag range support and fix issue with damage locators after merge --- .../Children/EveChildInstancedMeshes.cpp | 12 +++- .../Children/EveChildInstancedMeshes.h | 1 + .../SpaceObject/Children/EveChildPartData.cpp | 59 +++++++++++++++---- .../SpaceObject/Children/EveChildPartData.h | 3 + trinity/Eve/SpaceObject/EveSpaceObject2.cpp | 24 ++++++-- trinity/Eve/SpaceObject/EveSpaceObject2.h | 1 + trinity/Eve/SpaceObjectFactory/EveSOF.cpp | 12 +++- trinity/Eve/SpaceObjectFactory/EveSOF.h | 2 +- 8 files changed, 92 insertions(+), 22 deletions(-) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp index 3cf9f2dfe..1ef3d41a5 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp @@ -528,12 +528,20 @@ void EveChildInstancedMeshes::AddMesh( void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag partTag ) { + RemoveInstancesByPartTag( partTag, partTag + 1 ); +} + +void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag firstPartTag, EveSpaceObjectChild::PartTag endPartTag ) +{ + auto inRange = [firstPartTag, endPartTag]( EveSpaceObjectChild::PartTag tag ) { + return tag >= firstPartTag && tag < endPartTag; + }; for( size_t i = 0; i < m_meshes.size(); ++i ) { auto& mesh = m_meshes[i]; auto newEnd = std::remove_if( begin( mesh.instances ), end( mesh.instances ), [&]( const EveInstancedMeshManager::StaticPerInstanceData& instance ) { - return mesh.partTags[&instance - mesh.instances.data()] == partTag; + return inRange( mesh.partTags[&instance - mesh.instances.data()] ); } ); bool removed = newEnd != end( mesh.instances ); if( !removed ) @@ -565,7 +573,7 @@ void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::Par } mesh.instances.erase( newEnd, end( mesh.instances ) ); auto newTagEnd = std::remove_if( begin( mesh.partTags ), end( mesh.partTags ), [&]( uint32_t tag ) { - return tag == partTag; + return inRange( tag ); } ); mesh.partTags.erase( newTagEnd, end( mesh.partTags ) ); if( removed ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h index cfcff75fa..7dfec1e8c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h @@ -94,6 +94,7 @@ BLUE_CLASS( EveChildInstancedMeshes ) : EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG ); void RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag partTag ); + void RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag firstPartTag, EveSpaceObjectChild::PartTag endPartTag ); BluePy GetSofSourceLocator( uint32_t areaId ) const; uint32_t GetMeshCount() const; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 937e11e02..d73e0af66 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -4,6 +4,7 @@ #include "EveChildPartData.h" #include "IEveEffectChildrenOwner.h" #include "../EveStation2.h" +#include "../Attachments/EveImpactOverlay.h" #include "EveChildInstancedMeshes.h" #include "EveChildContainer.h" #include @@ -16,7 +17,7 @@ EveChildPartData::EveChildPartData( IRoot* ) EveSpaceObjectChild::PartTag EveChildPartData::GetUnusedPartID() const { return std::accumulate( m_parts.begin(), m_parts.end(), 1u, []( EveSpaceObjectChild::PartTag maxId, const PartData& part ) { - return std::max( maxId, part.partId + 1 ); + return std::max( { maxId, part.partId + 1, part.partIdEnd } ); } ); } @@ -68,12 +69,35 @@ EveModularObjectModifier::~EveModularObjectModifier() } } -EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ) +void EveModularObjectModifier::UpdateImpactOverlayLocatorCount() const +{ + if( EveImpactOverlayPtr overlay = m_object->GetImpactOverlay() ) + { + auto locators = m_object->GetLocatorsForSet( DAMAGE_LOCATOR_SET_NAME ); + overlay->SetDamageLocatorCount( locators ? uint32_t( locators->size() ) : 0 ); + } +} + +EveSpaceObjectChild::PartTag EveModularObjectModifier::AllocatePartId() const { auto id = m_data->GetUnusedPartID(); + for( auto& child : m_object->GetEffectChildren() ) + { + if( child->GetPartTag() != EveSpaceObjectChild::NO_PART_TAG ) + { + id = std::max( id, child->GetPartTag() + 1 ); + } + } + return id; +} + +EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ) +{ + auto id = AllocatePartId(); auto size = m_object->GetEffectChildren().size(); auto dna = std::string( hullName ) + ":" + ( factionName[0] ? factionName : m_data->m_faction.c_str() ) + ":" + ( raceName[0] ? raceName : m_data->m_race.c_str() ); - if( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ) ) ) + EveSpaceObjectChild::PartTag idEnd = id + 1; + if( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ), idEnd ) ) { return INVALID_PART_TAG; } @@ -94,8 +118,10 @@ EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hull // Store the part bounding sphere and recalculate the bounding sphere of the modular object after adding all the parts CcpMath::Sphere sphere{ m_object->GetBoundingSphereCenter(), m_object->GetBoundingSphereRadius() }; - auto part = EveChildPartData::PartData{ id, position, rotation, scale, sphere }; + auto part = EveChildPartData::PartData{ id, idEnd, position, rotation, scale, sphere }; m_data->m_parts.emplace_back( part ); + m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); + UpdateImpactOverlayLocatorCount(); return id; } @@ -105,9 +131,10 @@ EveSpaceObjectChild::PartTag EveModularObjectModifier::AddChild( const char* res { child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); m_object->AddToEffectChildrenList( child ); - auto id = m_data->GetUnusedPartID(); + auto id = AllocatePartId(); child->SetPartTag( id ); - m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, position, rotation, scale } ); + m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, id + 1, position, rotation, scale } ); + m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); return id; } return INVALID_PART_TAG; @@ -123,10 +150,15 @@ BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag par return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; } + const auto tagEnd = std::max( found->partIdEnd, partId + 1 ); + auto inPart = [partId, tagEnd]( EveSpaceObjectChild::PartTag tag ) { + return tag >= partId && tag < tagEnd; + }; + for( size_t i = 0; i < m_object->GetEffectChildren().size(); ) { auto child = m_object->GetEffectChildren()[i]; - if( child->GetPartTag() == partId ) + if( inPart( child->GetPartTag() ) ) { m_object->RemoveFromEffectChildrenList( child ); continue; @@ -137,17 +169,20 @@ BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag par for( auto& set : m_object->GetLocatorSets() ) { auto& locators = *set->GetLocators(); - auto removed = std::remove_if( locators.begin(), locators.end(), [partId]( const auto& locator ) { - return locator.partTag == partId; + auto removed = std::remove_if( locators.begin(), locators.end(), [&inPart]( const auto& locator ) { + return inPart( locator.partTag ); } ); locators.Resize( std::distance( locators.begin(), removed ) ); } if( m_instancedMeshes ) { - m_instancedMeshes->RemoveInstancesByPartTag( partId ); + m_instancedMeshes->RemoveInstancesByPartTag( partId, tagEnd ); } m_data->m_parts.erase( found ); + m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); + m_object->ClearImpactDamage(); + UpdateImpactOverlayLocatorCount(); return BlueStdResultType::BLUE_STD_RESULT_OK; } @@ -164,13 +199,14 @@ BlueStdResult EveModularObjectModifier::SetTransform( EveSpaceObjectChild::PartT cmf::Transform oldTransform{ found->position, found->rotation, found->scale }; cmf::Transform newTransform{ position, rotation, scale }; auto invOldTransform = cmf::Inverse( oldTransform ); + const auto tagEnd = std::max( found->partIdEnd, partId + 1 ); for( auto& set : m_object->GetLocatorSets() ) { auto& locators = *set->GetLocators(); for( auto& locator : locators ) { - if( locator.partTag == partId ) + if( locator.partTag >= partId && locator.partTag < tagEnd ) { locator.scale.x = scale.x / found->scale.x; locator.scale.y = scale.y / found->scale.y; @@ -195,6 +231,7 @@ BlueStdResult EveModularObjectModifier::SetTransform( EveSpaceObjectChild::PartT child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); } } + m_object->InvalidateMergedLocators( LocatorInvalidationReason::PartMoved ); return BlueStdResultType::BLUE_STD_RESULT_OK; } diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.h b/trinity/Eve/SpaceObject/Children/EveChildPartData.h index d89dcb60c..0482d025c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.h @@ -22,6 +22,7 @@ class EveChildPartData : public EveSpaceObjectChild struct PartData { PartTag partId; + PartTag partIdEnd; // one past the last tag consumed by this part, including nested layout placements Vector3 position; Quaternion rotation; Vector3 scale; @@ -57,6 +58,8 @@ class EveModularObjectModifier : public IRoot private: EveChildPartData::PartData* FindPartData( EveSpaceObjectChild::PartTag partId ) const; + EveSpaceObjectChild::PartTag AllocatePartId() const; + void UpdateImpactOverlayLocatorCount() const; BluePtr m_object; EveChildPartDataPtr m_data; diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp index 6ba4e3f15..3eeb3592f 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp @@ -1135,6 +1135,11 @@ void EveSpaceObject2::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchT { if( !m_mesh ) { + // meshless objects (modular ships) still render their impact effects + if( m_impactOverlay ) + { + m_impactOverlay->GetBatches( batches, batchType, perObjectData, m_meshScreenSize ); + } return; } @@ -1712,11 +1717,11 @@ void EveSpaceObject2::UpdateVisibility( const EveUpdateContext& updateContext, c } } + m_meshScreenSize = frustum.GetPixelSizeAccrossEst( m_boundingSphereWorldCenter, m_boundingSphereWorldRadius ) * invLodFactor; + m_meshScreenSize = m_allowLodSelection ? m_meshScreenSize : std::numeric_limits::max(); + if( m_mesh ) { - m_meshScreenSize = frustum.GetPixelSizeAccrossEst( m_boundingSphereWorldCenter, m_boundingSphereWorldRadius ) * invLodFactor; - m_meshScreenSize = m_allowLodSelection ? m_meshScreenSize : std::numeric_limits::max(); - m_mesh->UseWithScreenSize( m_meshScreenSize, m_boundingSphereWorldRadius ); if( updateContext.m_raytracingEnabled ) @@ -1930,6 +1935,7 @@ void EveSpaceObject2::EnsureChildLocatorMerged() const Locator transformedLocator; transformedLocator.boneIndex = -1; Decompose( transformedLocator.scale, transformedLocator.direction, transformedLocator.position, transform ); + transformedLocator.partTag = locator->partTag; ( *mergedLocatorSet )->Append( &transformedLocator, 1 ); } @@ -3450,6 +3456,11 @@ void EveSpaceObject2::SetImpactOverlay( EveImpactOverlayPtr overlay ) m_impactOverlay = overlay; } +EveImpactOverlayPtr EveSpaceObject2::GetImpactOverlay() const +{ + return m_impactOverlay; +} + // -------------------------------------------------------------------------------- // Description: // Set the impact damage state: how many percent are gone? @@ -3806,10 +3817,13 @@ void EveSpaceObject2::EstimatePixelDiameter( const TriFrustum& frustum ) // estimate the pixel diameter using the local bounding box, // as the bounding sphere may not pepresent the mesh bounding sphere, // but rather the bounding sphere of the object and it's EveChildMesh attachments - if( m_mesh ) + if( !m_mesh ) { - m_mesh->GetBoundingBox( m_localAabbMin, m_localAabbMax ); + // meshless objects (modular ships) have no local box; size by the bounding sphere + m_estimatedPixelDiameter = frustum.GetPixelSizeAccrossEst( m_boundingSphereWorldCenter, m_boundingSphereWorldRadius ); + return; } + m_mesh->GetBoundingBox( m_localAabbMin, m_localAabbMax ); Vector4 sphere; BoundingSphereFromBox( sphere, m_localAabbMin, m_localAabbMax, &m_worldTransform ); m_estimatedPixelDiameter = frustum.GetPixelSizeAccross( sphere.GetXYZ(), sphere.w ); diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.h b/trinity/Eve/SpaceObject/EveSpaceObject2.h index be4e91796..2d57f2381 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.h +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.h @@ -527,6 +527,7 @@ BLUE_CLASS( EveSpaceObject2 ) : // access to impacts void SetImpactOverlay( EveImpactOverlayPtr overlay ); + EveImpactOverlayPtr GetImpactOverlay() const; void SetImpactDamageState( float shield, float armor, float hull, bool doCreateArmorImpacts ); void SetImpactAnimation( const std::string& name, bool enable, float duration ); void ClearImpactDamage(); diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp index 7c8dd6fba..266ebc641 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp @@ -306,7 +306,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) return newObj->GetRawRoot(); } -bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_t partTag, const Matrix& transform ) +bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_t partTag, const Matrix& transform, uint32_t& nextPartTag ) { std::string s = "BuildChild "; s += std::string( dnaString ); @@ -487,10 +487,15 @@ bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_ } //SetupCustomMask( newObj, dna ); + if( !newObj->GetImpactOverlay() ) + { + SetupImpactEffects( newObj, dna ); + } SetupLocatorSets( newObj, dna, placementOffsets, partTag ); // setup nested layout - int layoutPartTag = static_cast( partTag ); + int layoutPartTag = static_cast( partTag ) + 1; SetupLayout( newObj, placementContainer, sharedMeshes, dna, placementOffsets, layoutPartTag ); + nextPartTag = static_cast( layoutPartTag ); return true; } @@ -3912,7 +3917,8 @@ void EveSOF::CreatePlacement( placementOffsets.data(), placementOffsets.size(), m_editorMode ? BlueSharedString( parentDna->GetHullNames()[0].c_str() ) : BlueSharedString(), - m_editorMode ? placement.locatorSetName : BlueSharedString() ); + m_editorMode ? placement.locatorSetName : BlueSharedString(), + static_cast( partTag++ ) ); } else { diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.h b/trinity/Eve/SpaceObjectFactory/EveSOF.h index 8f4678933..892b33565 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.h @@ -45,7 +45,7 @@ BLUE_CLASS( EveSOF ) : IRootPtr Build( const char* hullName, const char* factionName, const char* raceName ); // build a spaceship from a dns string and return a EveShip2 object IRootPtr BuildFromDNA( const char* dnaString ); - bool BuildChild( EveSpaceObject2* owner, const char* dnaString, uint32_t partTag, const Matrix& transform ); + bool BuildChild( EveSpaceObject2* owner, const char* dnaString, uint32_t partTag, const Matrix& transform, uint32_t& nextPartTag ); // validate a dna string (slow!) bool ValidateDNA( const char* dnaString ); From 42e4e493c55fa23857ab83d0bbaf8f47f086fc2c Mon Sep 17 00:00:00 2001 From: breki Date: Tue, 18 Aug 2026 13:54:02 +0000 Subject: [PATCH 22/29] apply feedback from copilot review --- trinity/Eve/EveInstancedMeshManager.h | 24 ++++++++++++------- .../Children/EveChildInstancedMeshes.cpp | 16 +++++++++---- .../SpaceObject/Children/EveChildPartData.cpp | 5 ++++ .../Children/EveChildPartData_Blue.cpp | 2 +- trinity/Eve/SpaceObjectFactory/EveSOF.cpp | 4 ++-- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/trinity/Eve/EveInstancedMeshManager.h b/trinity/Eve/EveInstancedMeshManager.h index a92ca39a0..e6485245f 100644 --- a/trinity/Eve/EveInstancedMeshManager.h +++ b/trinity/Eve/EveInstancedMeshManager.h @@ -46,21 +46,29 @@ class EveInstancedMeshManager DataHandle& operator=( const DataHandle& ) = delete; DataHandle( DataHandle&& other ) noexcept { + owner = other.owner; + index = other.index; if( owner ) { - owner->ReplaceHandle( this, &other ); + owner->ReplaceHandle( &other, this ); } - owner = other.owner; - index = other.index; other.owner = nullptr; other.index = InvalidIndex; } - DataHandle& operator=( DataHandle&& other ) + DataHandle& operator=( DataHandle&& other ) noexcept { - owner = other.owner; - index = other.index; - other.owner = nullptr; - other.index = InvalidIndex; + if( this != &other ) + { + CCP_ASSERT( !*this ); + owner = other.owner; + index = other.index; + if( owner ) + { + owner->ReplaceHandle( &other, this ); + } + other.owner = nullptr; + other.index = InvalidIndex; + } return *this; } diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp index 1ef3d41a5..a27718c9f 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp @@ -443,7 +443,8 @@ void EveChildInstancedMeshes::AddMesh( { continue; } - mesh.instances.reserve( mesh.instances.size() + count ); + const size_t existingCount = mesh.instances.size(); + mesh.instances.reserve( existingCount + count ); mesh.partTags.reserve( mesh.partTags.size() + count ); for( size_t i = 0; i < count; ++i ) { @@ -452,7 +453,7 @@ void EveChildInstancedMeshes::AddMesh( instanceData.worldTransform[0] = Vector4( mat._11, mat._21, mat._31, mat._41 ); instanceData.worldTransform[1] = Vector4( mat._12, mat._22, mat._32, mat._42 ); instanceData.worldTransform[2] = Vector4( mat._13, mat._23, mat._33, mat._43 ); - instanceData.sphereIndex = static_cast( i ); + instanceData.sphereIndex = static_cast( existingCount + i ); mesh.instances.push_back( instanceData ); mesh.partTags.push_back( partTag ); } @@ -561,11 +562,12 @@ void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::Par area.meshGroupHandle.owner->RemoveMeshGroup( area.meshGroupHandle ); } } + TriGeometryResPtr geometry = mesh.geometry; std::swap( mesh, m_meshes.back() ); - auto seenMesh = find_if( begin( m_meshes ), end( m_meshes ) - 1, [&]( const Mesh& m ) { return m.geometry == mesh.geometry; } ); - if( seenMesh == end( m_meshes ) - 1 ) + auto seenMesh = find_if( begin( m_meshes ), end( m_meshes ) - 1, [&]( const Mesh& m ) { return m.geometry == geometry; } ); + if( geometry && seenMesh == end( m_meshes ) - 1 ) { - mesh.geometry->RemoveNotifyTarget( this ); + geometry->RemoveNotifyTarget( this ); } m_meshes.pop_back(); --i; @@ -576,6 +578,10 @@ void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::Par return inRange( tag ); } ); mesh.partTags.erase( newTagEnd, end( mesh.partTags ) ); + for( auto& instance : mesh.instances ) + { + instance.sphereIndex = static_cast( &instance - mesh.instances.data() ); + } if( removed ) { m_allRegistered = false; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index d73e0af66..383400aab 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -35,6 +35,11 @@ void EveModularObjectModifier::Create( SpaceObjectType* object, EveSOF* sof ) break; } } + if( !m_data ) + { + m_data.CreateInstance(); + object->AddToEffectChildrenList( m_data ); + } for( auto& child : object->GetEffectChildren() ) { if( EveChildInstancedMeshesPtr instancedMeshes = BlueCastPtr( child ) ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp index 906ff198e..b484998ef 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp @@ -34,4 +34,4 @@ const Be::ClassInfo* EveModularObjectModifier::ExposeToBlue() MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, "" ); MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "" ); -MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the NO_PART_TAG constant" ); \ No newline at end of file +MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the INVALID_PART_TAG constant" ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp index 266ebc641..ed645ff99 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp @@ -422,7 +422,7 @@ bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_ for( auto type : types ) { CTr2MeshAreaVector meshAreas; - // We are purpusely ignoring multi-hull logic assuming shared instanced meshes are single hull only + // We are purposely ignoring multi-hull logic assuming shared instanced meshes are single hull only FillMeshAreaVector( &meshAreas, type, dna, 0, 0 ); for( auto area : meshAreas ) { @@ -3898,7 +3898,7 @@ void EveSOF::CreatePlacement( for( auto type : types ) { CTr2MeshAreaVector meshAreas; - // We are purpusely ignoring multi-hull logic assuming shared instanced meshes are single hull only + // We are purposely ignoring multi-hull logic assuming shared instanced meshes are single hull only FillMeshAreaVector( &meshAreas, type, extensionDna, 0, 0 ); for( auto area : meshAreas ) { From 38f59ae64af30eb78b842b86d369c94dec9a989e Mon Sep 17 00:00:00 2001 From: Breki Ingibjargarson Date: Tue, 18 Aug 2026 14:34:59 +0000 Subject: [PATCH 23/29] Update trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp index d3086732e..33be1c04f 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp @@ -5,7 +5,7 @@ static_assert( sizeof( EveSpaceObjectChild::PartTag ) == sizeof( uint32_t ), "Size mismatch for PartTag: need to update LocatorStructureDef" ); - // locator item definition +// locator item definition static BlueStructureDefinition LocatorStructureDef[] = { { "position", Be::FLOAT32_3, 0 }, { "direction", Be::FLOAT32_4, 12 }, From d4aef48f94c3b69980ec8487f40adcf71345b312 Mon Sep 17 00:00:00 2001 From: breki Date: Tue, 18 Aug 2026 14:41:25 +0000 Subject: [PATCH 24/29] expland blue class macro to fix clang formatting --- trinity/Eve/SpaceObjectFactory/EveSOF.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.h b/trinity/Eve/SpaceObjectFactory/EveSOF.h index 892b33565..92fb90cbb 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.h @@ -32,8 +32,8 @@ BLUE_DECLARE( EveChildInstancedMeshes ); // SeeAlso: // EveBoosterSet2 // -------------------------------------------------------------------------------- -BLUE_CLASS( EveSOF ) : - public IRoot +BLUE_CLASS_IMPL( EveSOF ) +class EveSOF : public IRoot { public: EXPOSE_TO_BLUE(); @@ -51,8 +51,8 @@ BLUE_CLASS( EveSOF ) : bool ValidateDNA( const char* dnaString ); // change the material of a turret with SOF data - void SetupTurretMaterialFromDNA( EveTurretSet * turretSet, const char* dnaString ); - void SetupTurretMaterialFromFaction( EveTurretSet * turretSet, const char* factionName ); + void SetupTurretMaterialFromDNA( EveTurretSet* turretSet, const char* dnaString ); + void SetupTurretMaterialFromFaction( EveTurretSet* turretSet, const char* factionName ); bool LoadData( const char* filePath ); @@ -109,7 +109,7 @@ BLUE_CLASS( EveSOF ) : void SetupLocatorSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets, EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG ); void SetupImpactEffects( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const; void SetupLights( ITr2LightOwnerPtr obj, const EveSOFDNAPtr dna, const std::vector& offsets ) const; - void SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutContainer, EveChildInstancedMeshesPtr & sharedMeshes, const EveSOFDNAPtr dna, const std::vector& offsets, int& partTag, uint32_t seedOverwrite = 0 ); + void SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutContainer, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, const std::vector& offsets, int& partTag, uint32_t seedOverwrite = 0 ); Tr2MeshPtr CreateMesh( const EveSOFDNAPtr dna ) const; @@ -118,7 +118,7 @@ BLUE_CLASS( EveSOF ) : void CreatePlacement( EveSpaceObject2Ptr parent, - EveChildInstancedMeshesPtr & sharedMeshes, + EveChildInstancedMeshesPtr& sharedMeshes, EveSOFDNAPtr extensionDna, const EveSOFDNAPtr& parentDna, EveSOFDataMgr::ExtensionPlacementData& placement, @@ -134,14 +134,14 @@ BLUE_CLASS( EveSOF ) : Tr2EffectPtr CreateBoosterEffect( const EveSOFDataMgr::RaceBoosterData* rdata, const BlueSharedString& lodOption ) const; - bool ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacementData & placement, const EveSOFDNAPtr dna ); - void ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacementDistribution & distributionData, const EveSOFDNAPtr dna, std::vector& placementSet, std::vector& managedLocatorSet ); - void ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacementData & distributionData, EveSpaceObject2Ptr obj, EveChildInstancedMeshesPtr & sharedMeshes, const EveSOFDNAPtr dna, std::map>& managedLocatorSet, size_t& layoutIdx, size_t& placementIdx, const std::vector& offsets, EveChildContainerPtr childContainer, int& partTag ); + bool ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacementData& placement, const EveSOFDNAPtr dna ); + void ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacementDistribution& distributionData, const EveSOFDNAPtr dna, std::vector& placementSet, std::vector& managedLocatorSet ); + void ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacementData& distributionData, EveSpaceObject2Ptr obj, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, std::map>& managedLocatorSet, size_t& layoutIdx, size_t& placementIdx, const std::vector& offsets, EveChildContainerPtr childContainer, int& partTag ); // helper functions - size_t FillMeshAreaVector( Tr2MeshAreaVector * meshAreaVector, TriBatchType areaType, const EveSOFDNAPtr dna, size_t hullIdx, size_t meshIndexOffset ) const; - bool GenerateLodResourcePaths( std::string & mediumResPath, std::string & lowResPath, std::string & ultraResPath, const char* resPath, const char* usage ) const; - void GenerateDepthFromAreaVector( Tr2MeshBase * mesh, const Tr2MeshAreaVector* meshAreaVector, const EveSOFDNAPtr dna ) const; + size_t FillMeshAreaVector( Tr2MeshAreaVector* meshAreaVector, TriBatchType areaType, const EveSOFDNAPtr dna, size_t hullIdx, size_t meshIndexOffset ) const; + bool GenerateLodResourcePaths( std::string& mediumResPath, std::string& lowResPath, std::string& ultraResPath, const char* resPath, const char* usage ) const; + void GenerateDepthFromAreaVector( Tr2MeshBase* mesh, const Tr2MeshAreaVector* meshAreaVector, const EveSOFDNAPtr dna ) const; void CreatePointLightData( const Vector3& pos, const float scale, const Color& color, const EveSOFDataMgr::PointLightAttachment* lightData ) const; void CreateTexturedPointLightData( const Vector3& pos, const float scale, const std::string& texturePath, const EveSOFDataMgr::PointLightAttachment* lightData ) const; From 423bc8f4862fb74c825d55cf8c04a34445717336 Mon Sep 17 00:00:00 2001 From: breki Date: Wed, 19 Aug 2026 09:12:09 +0000 Subject: [PATCH 25/29] remove range based part tag for modular --- .../Children/EveChildInstancedMeshes.cpp | 12 ++----- .../Children/EveChildInstancedMeshes.h | 1 - .../SpaceObject/Children/EveChildPartData.cpp | 25 +++++--------- .../SpaceObject/Children/EveChildPartData.h | 1 - trinity/Eve/SpaceObjectFactory/EveSOF.cpp | 33 ++++++++++--------- trinity/Eve/SpaceObjectFactory/EveSOF.h | 9 ++--- 6 files changed, 33 insertions(+), 48 deletions(-) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp index a27718c9f..b29193781 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp @@ -529,20 +529,12 @@ void EveChildInstancedMeshes::AddMesh( void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag partTag ) { - RemoveInstancesByPartTag( partTag, partTag + 1 ); -} - -void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag firstPartTag, EveSpaceObjectChild::PartTag endPartTag ) -{ - auto inRange = [firstPartTag, endPartTag]( EveSpaceObjectChild::PartTag tag ) { - return tag >= firstPartTag && tag < endPartTag; - }; for( size_t i = 0; i < m_meshes.size(); ++i ) { auto& mesh = m_meshes[i]; auto newEnd = std::remove_if( begin( mesh.instances ), end( mesh.instances ), [&]( const EveInstancedMeshManager::StaticPerInstanceData& instance ) { - return inRange( mesh.partTags[&instance - mesh.instances.data()] ); + return mesh.partTags[&instance - mesh.instances.data()] == partTag; } ); bool removed = newEnd != end( mesh.instances ); if( !removed ) @@ -575,7 +567,7 @@ void EveChildInstancedMeshes::RemoveInstancesByPartTag( EveSpaceObjectChild::Par } mesh.instances.erase( newEnd, end( mesh.instances ) ); auto newTagEnd = std::remove_if( begin( mesh.partTags ), end( mesh.partTags ), [&]( uint32_t tag ) { - return inRange( tag ); + return tag == partTag; } ); mesh.partTags.erase( newTagEnd, end( mesh.partTags ) ); for( auto& instance : mesh.instances ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h index 7dfec1e8c..cfcff75fa 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h @@ -94,7 +94,6 @@ BLUE_CLASS( EveChildInstancedMeshes ) : EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG ); void RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag partTag ); - void RemoveInstancesByPartTag( EveSpaceObjectChild::PartTag firstPartTag, EveSpaceObjectChild::PartTag endPartTag ); BluePy GetSofSourceLocator( uint32_t areaId ) const; uint32_t GetMeshCount() const; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 383400aab..64b25d0e7 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -17,7 +17,7 @@ EveChildPartData::EveChildPartData( IRoot* ) EveSpaceObjectChild::PartTag EveChildPartData::GetUnusedPartID() const { return std::accumulate( m_parts.begin(), m_parts.end(), 1u, []( EveSpaceObjectChild::PartTag maxId, const PartData& part ) { - return std::max( { maxId, part.partId + 1, part.partIdEnd } ); + return std::max( maxId, part.partId + 1 ); } ); } @@ -101,8 +101,7 @@ EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hull auto id = AllocatePartId(); auto size = m_object->GetEffectChildren().size(); auto dna = std::string( hullName ) + ":" + ( factionName[0] ? factionName : m_data->m_faction.c_str() ) + ":" + ( raceName[0] ? raceName : m_data->m_race.c_str() ); - EveSpaceObjectChild::PartTag idEnd = id + 1; - if( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ), idEnd ) ) + if( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ) ) ) { return INVALID_PART_TAG; } @@ -123,7 +122,7 @@ EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hull // Store the part bounding sphere and recalculate the bounding sphere of the modular object after adding all the parts CcpMath::Sphere sphere{ m_object->GetBoundingSphereCenter(), m_object->GetBoundingSphereRadius() }; - auto part = EveChildPartData::PartData{ id, idEnd, position, rotation, scale, sphere }; + auto part = EveChildPartData::PartData{ id, position, rotation, scale, sphere }; m_data->m_parts.emplace_back( part ); m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); UpdateImpactOverlayLocatorCount(); @@ -138,7 +137,7 @@ EveSpaceObjectChild::PartTag EveModularObjectModifier::AddChild( const char* res m_object->AddToEffectChildrenList( child ); auto id = AllocatePartId(); child->SetPartTag( id ); - m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, id + 1, position, rotation, scale } ); + m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, position, rotation, scale } ); m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); return id; } @@ -155,15 +154,10 @@ BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag par return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; } - const auto tagEnd = std::max( found->partIdEnd, partId + 1 ); - auto inPart = [partId, tagEnd]( EveSpaceObjectChild::PartTag tag ) { - return tag >= partId && tag < tagEnd; - }; - for( size_t i = 0; i < m_object->GetEffectChildren().size(); ) { auto child = m_object->GetEffectChildren()[i]; - if( inPart( child->GetPartTag() ) ) + if( child->GetPartTag() == partId ) { m_object->RemoveFromEffectChildrenList( child ); continue; @@ -174,15 +168,15 @@ BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag par for( auto& set : m_object->GetLocatorSets() ) { auto& locators = *set->GetLocators(); - auto removed = std::remove_if( locators.begin(), locators.end(), [&inPart]( const auto& locator ) { - return inPart( locator.partTag ); + auto removed = std::remove_if( locators.begin(), locators.end(), [partId]( const auto& locator ) { + return locator.partTag == partId; } ); locators.Resize( std::distance( locators.begin(), removed ) ); } if( m_instancedMeshes ) { - m_instancedMeshes->RemoveInstancesByPartTag( partId, tagEnd ); + m_instancedMeshes->RemoveInstancesByPartTag( partId ); } m_data->m_parts.erase( found ); m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); @@ -204,14 +198,13 @@ BlueStdResult EveModularObjectModifier::SetTransform( EveSpaceObjectChild::PartT cmf::Transform oldTransform{ found->position, found->rotation, found->scale }; cmf::Transform newTransform{ position, rotation, scale }; auto invOldTransform = cmf::Inverse( oldTransform ); - const auto tagEnd = std::max( found->partIdEnd, partId + 1 ); for( auto& set : m_object->GetLocatorSets() ) { auto& locators = *set->GetLocators(); for( auto& locator : locators ) { - if( locator.partTag >= partId && locator.partTag < tagEnd ) + if( locator.partTag == partId ) { locator.scale.x = scale.x / found->scale.x; locator.scale.y = scale.y / found->scale.y; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.h b/trinity/Eve/SpaceObject/Children/EveChildPartData.h index 0482d025c..012874b7f 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.h @@ -22,7 +22,6 @@ class EveChildPartData : public EveSpaceObjectChild struct PartData { PartTag partId; - PartTag partIdEnd; // one past the last tag consumed by this part, including nested layout placements Vector3 position; Quaternion rotation; Vector3 scale; diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp index ed645ff99..6c48c4fc4 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp @@ -224,7 +224,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) extensionContainer->SetIsPlacementRoot( true ); EveChildInstancedMeshesPtr sharedMeshes; - CreatePlacement( newObj, sharedMeshes, dna, dna, fakePlacement, std::vector( 1, center ), centerOffset, extensionContainer, partTag ); + CreatePlacement( newObj, sharedMeshes, dna, dna, fakePlacement, std::vector( 1, center ), centerOffset, extensionContainer, partTag, true ); newObj->AddToEffectChildrenList( extensionContainer ); // create an empty mesh... @@ -278,7 +278,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) layoutContainer->SetOrigin( EveSpaceObjectChild::SOF ); layoutContainer->SetIsPlacementRoot( true ); layoutContainer->SetAlwaysOn( true ); - SetupLayout( newObj, layoutContainer, sharedMeshes, dna, centerOffset, partTag ); + SetupLayout( newObj, layoutContainer, sharedMeshes, dna, centerOffset, partTag, true ); if( layoutContainer->m_objects.size() != 0 ) { @@ -306,7 +306,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) return newObj->GetRawRoot(); } -bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_t partTag, const Matrix& transform, uint32_t& nextPartTag ) +bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_t partTag, const Matrix& transform ) { std::string s = "BuildChild "; s += std::string( dnaString ); @@ -493,9 +493,8 @@ bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_ } SetupLocatorSets( newObj, dna, placementOffsets, partTag ); // setup nested layout - int layoutPartTag = static_cast( partTag ) + 1; - SetupLayout( newObj, placementContainer, sharedMeshes, dna, placementOffsets, layoutPartTag ); - nextPartTag = static_cast( layoutPartTag ); + int layoutPartTag = static_cast( partTag ); + SetupLayout( newObj, placementContainer, sharedMeshes, dna, placementOffsets, layoutPartTag, false ); return true; } @@ -3280,7 +3279,7 @@ std::vector EveSOF::BuildHullLocalLocatorSets( const EveSOFDN return result; } -void EveSOF::SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutContainer, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, const std::vector& offsets, int& partTag, uint32_t seedOverwrite ) +void EveSOF::SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutContainer, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, const std::vector& offsets, int& partTag, bool perPlacementTags, uint32_t seedOverwrite ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -3334,7 +3333,7 @@ void EveSOF::SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutCon // Go over all the placements (each layout can have multiple mesh attachments) for( auto placement : layout->placements ) { - ProcessPlacementDistributionOrGroup( placement, obj, sharedMeshes, dna, locatorSets, layoutIdx, placementIdx, offsets, layoutContainer, partTag ); + ProcessPlacementDistributionOrGroup( placement, obj, sharedMeshes, dna, locatorSets, layoutIdx, placementIdx, offsets, layoutContainer, partTag, perPlacementTags ); } if( layout->scrambleSeed ) @@ -3353,7 +3352,8 @@ void EveSOF::ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacem size_t& placementIdx, const std::vector& offsets, EveChildContainerPtr layoutContainer, - int& partTag ) + int& partTag, + bool perPlacementTags ) { if( placement.isAGroup ) { @@ -3372,7 +3372,7 @@ void EveSOF::ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacem // Go over all the placements (each layout can have multiple mesh attachments) for( auto& placement : placement.placements ) { - ProcessPlacementDistributionOrGroup( placement, obj, sharedMeshes, dna, managedLocatorSets, layoutIdx, placementIdx, offsets, layoutContainer, partTag ); + ProcessPlacementDistributionOrGroup( placement, obj, sharedMeshes, dna, managedLocatorSets, layoutIdx, placementIdx, offsets, layoutContainer, partTag, perPlacementTags ); } return; } @@ -3476,12 +3476,12 @@ void EveSOF::ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacem for( auto& locator : locators ) { singleLocator[0] = locator; - CreatePlacement( obj, sharedMeshes, placementDna, dna, placement, singleLocator, offsets, layoutContainer, partTag ); + CreatePlacement( obj, sharedMeshes, placementDna, dna, placement, singleLocator, offsets, layoutContainer, partTag, perPlacementTags ); } } else { - CreatePlacement( obj, sharedMeshes, placementDna, dna, placement, locators, offsets, layoutContainer, partTag ); + CreatePlacement( obj, sharedMeshes, placementDna, dna, placement, locators, offsets, layoutContainer, partTag, perPlacementTags ); } } @@ -3707,7 +3707,8 @@ void EveSOF::CreatePlacement( const std::vector& locators, const std::vector& nestedOffsets, EveChildContainerPtr layoutContainer, - int& partTag ) + int& partTag, + bool perPlacementTags ) { Matrix placementOffset = TranslationMatrix( placement.offset ); @@ -3808,7 +3809,7 @@ void EveSOF::CreatePlacement( child->SetName( "Hull" ); child->SetupWithStaticTransform( &randomScale, &rotation, &translation, Tr2Lod::TR2_LOD_LOW ); child->SetOwnedLocatorSets( childLocatorSets ); - child->SetPartTag( partTag++ ); + child->SetPartTag( perPlacementTags ? partTag++ : partTag ); if( m_editorMode ) { @@ -3918,7 +3919,7 @@ void EveSOF::CreatePlacement( placementOffsets.size(), m_editorMode ? BlueSharedString( parentDna->GetHullNames()[0].c_str() ) : BlueSharedString(), m_editorMode ? placement.locatorSetName : BlueSharedString(), - static_cast( partTag++ ) ); + static_cast( perPlacementTags ? partTag++ : partTag ) ); } else { @@ -4005,7 +4006,7 @@ void EveSOF::CreatePlacement( SetupLocatorSets( parent, extensionDna, placementOffsets ); } // setup nested layout - SetupLayout( parent, layoutContainer, sharedMeshes, extensionDna, placementOffsets, partTag ); + SetupLayout( parent, layoutContainer, sharedMeshes, extensionDna, placementOffsets, partTag, perPlacementTags ); CCP_LOGNOTICE( "Creating %s extensions on %zu places", placement.isInstanced ? " instanced" : "", locators.size() ); } diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.h b/trinity/Eve/SpaceObjectFactory/EveSOF.h index 92fb90cbb..e169d5d7f 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.h @@ -45,7 +45,7 @@ class EveSOF : public IRoot IRootPtr Build( const char* hullName, const char* factionName, const char* raceName ); // build a spaceship from a dns string and return a EveShip2 object IRootPtr BuildFromDNA( const char* dnaString ); - bool BuildChild( EveSpaceObject2* owner, const char* dnaString, uint32_t partTag, const Matrix& transform, uint32_t& nextPartTag ); + bool BuildChild( EveSpaceObject2* owner, const char* dnaString, uint32_t partTag, const Matrix& transform ); // validate a dna string (slow!) bool ValidateDNA( const char* dnaString ); @@ -109,7 +109,7 @@ class EveSOF : public IRoot void SetupLocatorSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets, EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG ); void SetupImpactEffects( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const; void SetupLights( ITr2LightOwnerPtr obj, const EveSOFDNAPtr dna, const std::vector& offsets ) const; - void SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutContainer, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, const std::vector& offsets, int& partTag, uint32_t seedOverwrite = 0 ); + void SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutContainer, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, const std::vector& offsets, int& partTag, bool perPlacementTags, uint32_t seedOverwrite = 0 ); Tr2MeshPtr CreateMesh( const EveSOFDNAPtr dna ) const; @@ -125,7 +125,8 @@ class EveSOF : public IRoot const std::vector& locators, const std::vector& nestedOffsets, EveChildContainerPtr layoutContainer, - int& partTag ); + int& partTag, + bool perPlacementTags ); void SetupCustomMask( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const; @@ -136,7 +137,7 @@ class EveSOF : public IRoot bool ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacementData& placement, const EveSOFDNAPtr dna ); void ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacementDistribution& distributionData, const EveSOFDNAPtr dna, std::vector& placementSet, std::vector& managedLocatorSet ); - void ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacementData& distributionData, EveSpaceObject2Ptr obj, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, std::map>& managedLocatorSet, size_t& layoutIdx, size_t& placementIdx, const std::vector& offsets, EveChildContainerPtr childContainer, int& partTag ); + void ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacementData& distributionData, EveSpaceObject2Ptr obj, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, std::map>& managedLocatorSet, size_t& layoutIdx, size_t& placementIdx, const std::vector& offsets, EveChildContainerPtr childContainer, int& partTag, bool perPlacementTags ); // helper functions size_t FillMeshAreaVector( Tr2MeshAreaVector* meshAreaVector, TriBatchType areaType, const EveSOFDNAPtr dna, size_t hullIdx, size_t meshIndexOffset ) const; From 7043aa33551a9cfd2f8d9c60305cacc8d0f48f2f Mon Sep 17 00:00:00 2001 From: breki Date: Thu, 20 Aug 2026 14:06:49 +0000 Subject: [PATCH 26/29] Add documentation to modular ship assembly --- doc/source/eve/modular-assembly.rst | 66 +++++++++++++++++++ .../SpaceObject/Children/EveChildPartData.cpp | 5 ++ .../SpaceObject/Children/EveChildPartData.h | 38 ++++++++++- .../Children/EveChildPartData_Blue.cpp | 34 ++++++---- .../Eve/SpaceObject/Utils/EveLocatorSets.h | 2 +- trinity/Eve/SpaceObjectFactory/EveSOF.h | 5 ++ .../Eve/SpaceObjectFactory/EveSOFDataMgr.h | 2 +- 7 files changed, 135 insertions(+), 17 deletions(-) create mode 100644 doc/source/eve/modular-assembly.rst diff --git a/doc/source/eve/modular-assembly.rst b/doc/source/eve/modular-assembly.rst new file mode 100644 index 000000000..10852f7da --- /dev/null +++ b/doc/source/eve/modular-assembly.rst @@ -0,0 +1,66 @@ +:orphan: + +Modular ship assembly +===================== + +A modular space object is a single ``EveSpaceObject2`` assembled at runtime from multiple SOF +hulls ("parts"), created via ``CreateModularObject`` and edited through the transient +``EveModularObjectModifier`` session object. Persistent per-part state lives in +``EveChildPartData``, an effect child on the object itself, so a saved or handed-off object +carries everything needed to reopen an edit session with ``ModifyModularObject``. + +This page only describes the cross-cutting flow that no single file shows. API contracts live +with the API: the headers (``EveChildPartData.h``, ``EveSOF.h``) and the python docstrings on +``trinity.CreateModularObject`` and the modifier methods. Values and signatures are deliberately +not repeated here. + +Part-tag propagation +-------------------- + +A part tag (``EveSpaceObjectChild::PartTag``, sentinels documented in ``EveSpaceObjectChild.h`` +and ``EveChildPartData.h``) identifies everything belonging to one part. It flows: + +1. **Allocation**: ``EveModularObjectModifier::AllocatePartId`` (``EveChildPartData.cpp``) takes + the max over ``EveChildPartData::GetUnusedPartID`` and the tags of existing effect children. +2. **SOF build**: ``EveSOF::BuildChild`` (``EveSOF.cpp``) stamps the tag on every container and + child it creates; nested layout placements flow it through ``EveSOF::SetupLayout`` / + ``EveSOF::CreatePlacement``. +3. **Locators**: ``EveSOF::SetupLocatorSets`` stamps ``partTag`` on each generated locator + (``EveSOFDataMgr::LocatorDirectionData`` converts to ``Locator`` preserving it), then merges + into the object via ``EveSpaceObject2::MergeToLocatorSet``. The merged view built by + ``EveSpaceObject2::EnsureChildLocatorMerged`` preserves per-locator tags. +4. **Mesh instances**: instanced meshes are shared across parts, so the tag is per *instance*, + not per child. Each ``EveChildInstancedMeshes::Mesh`` carries a ``partTags`` vector parallel + to the instance data (written in ``AddMesh``, consumed by ``RemoveInstancesByPartTag``). The + child's own ``m_partTag`` is meaningless for instanced meshes. +5. **Effect children**: ``EveSpaceObjectChild::SetPartTag`` propagates through container + overrides (``EveChildContainer::SetPartTag`` etc.), and ``EveSpaceObjectChild::RegisterChild`` + copies the parent's tag onto newly attached children. + +Locator lifecycle during editing +-------------------------------- + +- **AddHull**: locators from every hull merge into the object's sets *by set name*, with no + renaming or prefixing (``EveSpaceObject2::MergeToLocatorSet`` appends to an existing same-named + set). Parts are distinguishable within a set only by ``partTag``. +- **Remove**: locators are stripped from every set by exact ``partTag`` match, mesh instances via + ``RemoveInstancesByPartTag``, effect children by tag; accumulated impact damage is cleared. +- **SetTransform**: locators of the part are re-derived in place (position through + inverse-old-transform then new-transform, direction and scale by delta), and the part's stored + bounding sphere is re-transformed the same way. See + ``EveModularObjectModifier::SetTransform`` (``EveChildPartData.cpp``). +- **Damage locators / impact overlay**: the impact overlay allocates per-damage-locator slots, so + its count must track the merged ``DAMAGE_LOCATOR_SET_NAME`` locator set. ``UpdateImpactOverlayLocatorCount`` + re-syncs it after AddHull/Remove; a stale count would index locators that no longer exist. +- Any structural edit calls ``EveSpaceObject2::InvalidateMergedLocators`` so the merged view is + rebuilt lazily. + +Gotchas +------- + +- A modular object with zero parts (or before ``ApplyBounds``/modifier destruction ever ran) has + a zero-radius bounding sphere: ``EveSpaceObject2::UpdateVisibility`` skips the mesh-visibility + test and ``EveSpaceObject2::IsVisible`` culls it at any distance, so it never renders. +- Culling volumes are only pushed to the object by ``EveModularObjectModifier::ApplyBounds`` (the + destructor calls it too). Editing without applying leaves the object rendering with stale + bounds. diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index 64b25d0e7..b06386d87 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -51,6 +51,11 @@ void EveModularObjectModifier::Create( SpaceObjectType* object, EveSOF* sof ) } EveModularObjectModifier::~EveModularObjectModifier() +{ + ApplyBounds(); +} + +void EveModularObjectModifier::ApplyBounds() { if( m_object ) { diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.h b/trinity/Eve/SpaceObject/Children/EveChildPartData.h index 012874b7f..3d6158f20 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.h @@ -7,6 +7,10 @@ BLUE_CLASS_IMPL( EveChildPartData ); +/** + * @brief Persistent state of a modular space object: seed faction/race and per-part transforms and bounds. + * Stored as an effect child so the state travels with the object. All editing goes through EveModularObjectModifier. + */ class EveChildPartData : public EveSpaceObjectChild { public: @@ -16,6 +20,7 @@ class EveChildPartData : public EveSpaceObjectChild PartTag GetUnusedPartID() const; + /// @brief Fallbacks for EveModularObjectModifier::AddHull when it is called with an empty faction or race name. std::string m_faction; std::string m_race; @@ -25,7 +30,7 @@ class EveChildPartData : public EveSpaceObjectChild Vector3 position; Quaternion rotation; Vector3 scale; - CcpMath::Sphere boundingSphere; + CcpMath::Sphere boundingSphere; ///< In the modular object's local space. }; std::vector m_parts; }; @@ -34,6 +39,11 @@ TYPEDEF_BLUECLASS( EveChildPartData ); BLUE_CLASS_IMPL( EveModularObjectModifier ); +/** + * @brief Transient edit session for a modular space object. Reads and writes the object's EveChildPartData and + * holds no persistent state itself. Object-level culling volumes only update on ApplyBounds(), which the + * destructor also calls as a fallback. + */ class EveModularObjectModifier : public IRoot { public: @@ -44,12 +54,30 @@ class EveModularObjectModifier : public IRoot void Create( SpaceObjectType* object, EveSOF* sof ); ~EveModularObjectModifier(); + /// @brief Returned by AddHull/AddChild when the part could not be built. Never a valid tag. static constexpr EveSpaceObjectChild::PartTag INVALID_PART_TAG = 0xFFFFFFFF; + /** + * @brief Builds a SOF hull as a new part at the given transform. Empty factionName/raceName fall back to + * the seed faction/race stored in EveChildPartData (set by CreateModularObject). + * @return The new part's tag, or INVALID_PART_TAG if the hull could not be built. + */ EveSpaceObjectChild::PartTag AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); + + /** + * @brief Loads a space object child resource and adds it as a new part at the given transform. + * @return The new part's tag, or INVALID_PART_TAG if the resource could not be loaded. + */ EveSpaceObjectChild::PartTag AddChild( const char* resPath, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); + BlueStdResult Remove( EveSpaceObjectChild::PartTag partId ); + /** + * @brief Recomputes the object's bounding sphere and shape ellipsoid from the current parts. + * Cheap; call after a batch of edits to keep culling volumes in sync. The destructor also calls it. + */ + void ApplyBounds(); + BlueStdResult SetTransform( EveSpaceObjectChild::PartTag partId, const Vector3& position, const Quaternion& rotation, Vector3 scale ); BlueStdResult GetPosition( EveSpaceObjectChild::PartTag partId, Vector3& position ) const; BlueStdResult GetRotation( EveSpaceObjectChild::PartTag partId, Quaternion& rotation ) const; @@ -68,8 +96,14 @@ class EveModularObjectModifier : public IRoot TYPEDEF_BLUECLASS( EveModularObjectModifier ); +/** + * @brief Creates an empty modular space object together with an open edit session for it. + * factionName/raceName seed the AddHull fallbacks. + */ std::pair CreateModularObject( EveSOF* sof, const char* factionName, const char* raceName ); + +/// @brief Opens an edit session on an existing modular space object. EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ); -// Wrapper function because blue doesn't support exporting const variables +/// @brief Wrapper for EveModularObjectModifier::INVALID_PART_TAG because blue doesn't support exporting const variables. EveSpaceObjectChild::PartTag GetInvalidPartTag(); diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp index b484998ef..683650171 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( EveChildPartData ); const Be::ClassInfo* EveChildPartData::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildPartData, "" ) + EXPOSURE_BEGIN( EveChildPartData, "Persistent state of a modular space object (per-part transforms and bounds). Edit through EveModularObjectModifier" ) MAP_INTERFACE( EveSpaceObjectChild ); MAP_INTERFACE( IEveSpaceObjectChild ) EXPOSURE_END() @@ -19,19 +19,27 @@ BLUE_DEFINE_NONEXPOSED( EveModularObjectModifier ); const Be::ClassInfo* EveModularObjectModifier::ExposeToBlue() { - EXPOSURE_BEGIN( EveModularObjectModifier, "" ) - MAP_METHOD_AND_WRAP( "AddHull", AddHull, "" ); - MAP_METHOD_AND_WRAP( "AddChild", AddChild, "" ) - MAP_METHOD_AND_WRAP( "Remove", Remove, "" ) - MAP_METHOD_AND_WRAP( "SetTransform", SetTransform, "" ) - MAP_METHOD_AND_WRAP( "GetPosition", GetPosition, "" ) - MAP_METHOD_AND_WRAP( "GetRotation", GetRotation, "" ) - MAP_METHOD_AND_WRAP( "GetScale", GetScale, "" ) + EXPOSURE_BEGIN( EveModularObjectModifier, "Edit session for a modular space object, from CreateModularObject or ModifyModularObject. Culling bounds update on ApplyBounds; dropping the last reference also applies them" ) + MAP_METHOD_AND_WRAP( "AddHull", AddHull, "Builds a SOF hull as a new part at the given transform. Empty faction/race fall back to the seeds given to CreateModularObject. Returns the new part tag, or GetInvalidPartTag() on failure" ); + MAP_METHOD_AND_WRAP( "AddChild", AddChild, "Loads a space object child resource and adds it as a new part at the given transform. Returns the new part tag, or GetInvalidPartTag() on failure" ) + MAP_METHOD_AND_WRAP( "Remove", Remove, "Removes a part: its effect children, mesh instances and locators. Clears accumulated impact damage. Key error if the part tag is unknown" ) + MAP_METHOD_AND_WRAP( "ApplyBounds", ApplyBounds, "Recomputes the object's bounding sphere and shape ellipsoid from the current parts. Call after a batch of edits to keep culling in sync" ) + MAP_METHOD_AND_WRAP( "SetTransform", SetTransform, "Moves a part: re-derives its effect children, locators and bounding sphere from the new transform. Key error if the part tag is unknown" ) + MAP_METHOD_AND_WRAP( "GetPosition", GetPosition, "Returns the part's position. Key error if the part tag is unknown" ) + MAP_METHOD_AND_WRAP( "GetRotation", GetRotation, "Returns the part's rotation. Key error if the part tag is unknown" ) + MAP_METHOD_AND_WRAP( "GetScale", GetScale, "Returns the part's scale. Key error if the part tag is unknown" ) EXPOSURE_END() } -MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, "" ); -MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "" ); - -MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the INVALID_PART_TAG constant" ); \ No newline at end of file +MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, + "Creates an empty modular space object and an edit session for it. Returns (object, modifier).\n" + "\n" + " obj, mod = trinity.CreateModularObject(sof, 'faction', 'race')\n" + " tag = mod.AddHull('hullname', '', '', pos, rot, scale) # '' -> seed faction/race\n" + " mod.SetTransform(tag, pos2, rot2, scale2)\n" + " mod.ApplyBounds() # apply culling bounds after a batch of edits\n" + " mod = None # end the session (also applies bounds)" ); +MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "Opens an edit session on an existing modular space object" ); + +MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the INVALID_PART_TAG constant" ); diff --git a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h index f8af43494..c53d7b4fa 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h +++ b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h @@ -13,7 +13,7 @@ struct Locator Quaternion direction; Vector3 scale; int boneIndex; - EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG; + EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG; ///< Part of a modular object this locator belongs to; NO_PART_TAG when not part-scoped. }; BLUE_DECLARE_STRUCTURE_LIST( Locator ); diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.h b/trinity/Eve/SpaceObjectFactory/EveSOF.h index e169d5d7f..9941fc708 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.h @@ -45,6 +45,11 @@ class EveSOF : public IRoot IRootPtr Build( const char* hullName, const char* factionName, const char* raceName ); // build a spaceship from a dns string and return a EveShip2 object IRootPtr BuildFromDNA( const char* dnaString ); + /** + * @brief Builds a hull ("hull:faction:race" DNA) directly onto an existing space object as one part of a + * modular object, stamping partTag on every child, locator and mesh instance it creates. + * @return False if the DNA did not resolve to a buildable hull. + */ bool BuildChild( EveSpaceObject2* owner, const char* dnaString, uint32_t partTag, const Matrix& transform ); // validate a dna string (slow!) diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h index 63888cfe3..788ea8591 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h @@ -38,7 +38,7 @@ BLUE_CLASS( EveSOFDataMgr ) : Vector3 scaling; int32_t boneIndex; int32_t uniqueID; - EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG; + EveSpaceObjectChild::PartTag partTag = EveSpaceObjectChild::NO_PART_TAG; ///< Part of a modular object this locator belongs to; NO_PART_TAG when not part-scoped. operator Locator() const { From 9c0e870eb0906c22dc64e1fd0f227c9d9d542de3 Mon Sep 17 00:00:00 2001 From: Breki Ingibjargarson Date: Thu, 20 Aug 2026 14:35:19 +0000 Subject: [PATCH 27/29] Update trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../Children/EveChildPartData_Blue.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp index 683650171..79dfea0b8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp @@ -32,14 +32,13 @@ const Be::ClassInfo* EveModularObjectModifier::ExposeToBlue() EXPOSURE_END() } -MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, - "Creates an empty modular space object and an edit session for it. Returns (object, modifier).\n" - "\n" - " obj, mod = trinity.CreateModularObject(sof, 'faction', 'race')\n" - " tag = mod.AddHull('hullname', '', '', pos, rot, scale) # '' -> seed faction/race\n" - " mod.SetTransform(tag, pos2, rot2, scale2)\n" - " mod.ApplyBounds() # apply culling bounds after a batch of edits\n" - " mod = None # end the session (also applies bounds)" ); +MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, "Creates an empty modular space object and an edit session for it. Returns (object, modifier).\n" + "\n" + " obj, mod = trinity.CreateModularObject(sof, 'faction', 'race')\n" + " tag = mod.AddHull('hullname', '', '', pos, rot, scale) # '' -> seed faction/race\n" + " mod.SetTransform(tag, pos2, rot2, scale2)\n" + " mod.ApplyBounds() # apply culling bounds after a batch of edits\n" + " mod = None # end the session (also applies bounds)" ); MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "Opens an edit session on an existing modular space object" ); MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the INVALID_PART_TAG constant" ); From 4651fb467a0f0be5073abd9a9ce61b1840543568 Mon Sep 17 00:00:00 2001 From: breki Date: Thu, 20 Aug 2026 14:52:28 +0000 Subject: [PATCH 28/29] Add more documentation to modular ship assembly and separate EveModularObjectModifer into its own file --- doc/source/eve/modular-assembly.rst | 54 +++- trinity/CMakeLists.txt | 3 + .../SpaceObject/Children/EveChildPartData.cpp | 295 +---------------- .../SpaceObject/Children/EveChildPartData.h | 74 +---- .../Children/EveChildPartData_Blue.cpp | 29 -- .../Children/EveModularObjectModifier.cpp | 299 ++++++++++++++++++ .../Children/EveModularObjectModifier.h | 77 +++++ .../EveModularObjectModifier_Blue.cpp | 33 ++ trinity/Eve/SpaceObjectFactory/EveSOF.cpp | 4 +- 9 files changed, 463 insertions(+), 405 deletions(-) create mode 100644 trinity/Eve/SpaceObject/Children/EveModularObjectModifier.cpp create mode 100644 trinity/Eve/SpaceObject/Children/EveModularObjectModifier.h create mode 100644 trinity/Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp diff --git a/doc/source/eve/modular-assembly.rst b/doc/source/eve/modular-assembly.rst index 10852f7da..2260d8fc0 100644 --- a/doc/source/eve/modular-assembly.rst +++ b/doc/source/eve/modular-assembly.rst @@ -10,17 +10,59 @@ hulls ("parts"), created via ``CreateModularObject`` and edited through the tran carries everything needed to reopen an edit session with ``ModifyModularObject``. This page only describes the cross-cutting flow that no single file shows. API contracts live -with the API: the headers (``EveChildPartData.h``, ``EveSOF.h``) and the python docstrings on -``trinity.CreateModularObject`` and the modifier methods. Values and signatures are deliberately -not repeated here. +with the API: the headers (``EveModularObjectModifier.h``, ``EveChildPartData.h``, ``EveSOF.h``) and the python docstrings on +``trinity.CreateModularObject`` and the modifier methods. Beyond the usage example below, +values and signatures are deliberately not repeated here. + +Python example +-------------- + +Condensed from ``packages/trinity/tests/test_modular.py``, which exercises the full API and is +the authoritative reference for behavior. The modifier edits the object immediately, but +culling bounds are only committed by ``ApplyBounds``, or by dropping the last reference to the +modifier, which the example relies on. + +.. code-block:: python + + import trinity + + IDENTITY_ROT = (0, 0, 0, 1) + UNIT_SCALE = (1, 1, 1) + + sof = trinity.EveSOF() + sof.dataMgr.LoadData('res:/dx9/model/spaceobjectfactory/data.red') + + # Create an empty modular object. The faction/race arguments seed the + # defaults used when AddHull is passed empty strings. + ship, modifier = trinity.CreateModularObject(sof, 'somefaction', 'somerace') + + core = modifier.AddHull('some_hull', '', '', (0, 0, 0), IDENTITY_ROT, UNIT_SCALE) + wing = modifier.AddHull('other_hull', 'somefaction', 'somerace', + (30, 0, 0), IDENTITY_ROT, UNIT_SCALE) + if wing == trinity.GetInvalidPartTag(): + raise RuntimeError('hull failed to build') + + # Non-SOF parts come from a space object child resource. + beacon = modifier.AddChild('res:/model/somechild.red', (0, 50, 0), IDENTITY_ROT, UNIT_SCALE) + + modifier.SetTransform(wing, (-30, 0, 0), IDENTITY_ROT, UNIT_SCALE) + modifier.Remove(beacon) # KeyError on an unknown or already-removed tag + + del modifier # last reference dropped: bounding sphere and shape ellipsoid commit here + + # Part tags stay valid across sessions: EveChildPartData persists them on the + # object, so a saved/reloaded object reopens the same way. + modifier = trinity.ModifyModularObject(ship, sof) + assert modifier.GetPosition(wing) == (-30, 0, 0) + del modifier Part-tag propagation -------------------- A part tag (``EveSpaceObjectChild::PartTag``, sentinels documented in ``EveSpaceObjectChild.h`` -and ``EveChildPartData.h``) identifies everything belonging to one part. It flows: +and ``EveModularObjectModifier.h``) identifies everything belonging to one part. It flows: -1. **Allocation**: ``EveModularObjectModifier::AllocatePartId`` (``EveChildPartData.cpp``) takes +1. **Allocation**: ``EveModularObjectModifier::AllocatePartId`` (``EveModularObjectModifier.cpp``) takes the max over ``EveChildPartData::GetUnusedPartID`` and the tags of existing effect children. 2. **SOF build**: ``EveSOF::BuildChild`` (``EveSOF.cpp``) stamps the tag on every container and child it creates; nested layout placements flow it through ``EveSOF::SetupLayout`` / @@ -48,7 +90,7 @@ Locator lifecycle during editing - **SetTransform**: locators of the part are re-derived in place (position through inverse-old-transform then new-transform, direction and scale by delta), and the part's stored bounding sphere is re-transformed the same way. See - ``EveModularObjectModifier::SetTransform`` (``EveChildPartData.cpp``). + ``EveModularObjectModifier::SetTransform`` (``EveModularObjectModifier.cpp``). - **Damage locators / impact overlay**: the impact overlay allocates per-damage-locator slots, so its count must track the merged ``DAMAGE_LOCATOR_SET_NAME`` locator set. ``UpdateImpactOverlayLocatorCount`` re-syncs it after AddHull/Remove; a stale count would index locators that no longer exist. diff --git a/trinity/CMakeLists.txt b/trinity/CMakeLists.txt index 41b7b36da..b5e0b65b3 100644 --- a/trinity/CMakeLists.txt +++ b/trinity/CMakeLists.txt @@ -578,6 +578,9 @@ set(_SOURCES Eve/SpaceObject/Children/EveCloudEditableVolume.cpp Eve/SpaceObject/Children/EveCloudEditableVolume.h Eve/SpaceObject/Children/EveCloudEditableVolume_Blue.cpp + Eve/SpaceObject/Children/EveModularObjectModifier.cpp + Eve/SpaceObject/Children/EveModularObjectModifier.h + Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp Eve/SpaceObject/Children/EveSpaceObjectChild.cpp Eve/SpaceObject/Children/EveSpaceObjectChild.h Eve/SpaceObject/Children/EveSpaceObjectChild_Blue.cpp diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp index b06386d87..bf237679c 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.cpp @@ -2,12 +2,7 @@ #include "StdAfx.h" #include "EveChildPartData.h" -#include "IEveEffectChildrenOwner.h" -#include "../EveStation2.h" -#include "../Attachments/EveImpactOverlay.h" -#include "EveChildInstancedMeshes.h" -#include "EveChildContainer.h" -#include +#include EveChildPartData::EveChildPartData( IRoot* ) @@ -19,292 +14,4 @@ EveSpaceObjectChild::PartTag EveChildPartData::GetUnusedPartID() const return std::accumulate( m_parts.begin(), m_parts.end(), 1u, []( EveSpaceObjectChild::PartTag maxId, const PartData& part ) { return std::max( maxId, part.partId + 1 ); } ); -} - - - -void EveModularObjectModifier::Create( SpaceObjectType* object, EveSOF* sof ) -{ - m_object = object; - m_sof = sof; - for( auto& child : object->GetEffectChildren() ) - { - if( EveChildPartDataPtr partData = BlueCastPtr( child ) ) - { - m_data = partData; - break; - } - } - if( !m_data ) - { - m_data.CreateInstance(); - object->AddToEffectChildrenList( m_data ); - } - for( auto& child : object->GetEffectChildren() ) - { - if( EveChildInstancedMeshesPtr instancedMeshes = BlueCastPtr( child ) ) - { - m_instancedMeshes = instancedMeshes; - break; - } - } -} - -EveModularObjectModifier::~EveModularObjectModifier() -{ - ApplyBounds(); -} - -void EveModularObjectModifier::ApplyBounds() -{ - if( m_object ) - { - std::vector orderedParts; - orderedParts.reserve( m_data->m_parts.size() ); - for( const auto& part : m_data->m_parts ) - orderedParts.push_back( &part ); - std::sort( orderedParts.begin(), orderedParts.end(), []( const auto* a, const auto* b ) { - return a->boundingSphere.radius > b->boundingSphere.radius; - } ); - - CcpMath::Sphere bounds; - CcpMath::AxisAlignedBox box; - for( const auto* part : orderedParts ) - { - bounds.Include( part->boundingSphere ); - box.IncludeSphere( part->boundingSphere ); - } - m_object->SetBoundingSphereInformation( bounds ); - m_object->SetShapeEllipsoid( m_data->m_parts.empty() ? CcpMath::AxisAlignedEllipsoid{} : CcpMath::AxisAlignedEllipsoid{ box, true } ); - } -} - -void EveModularObjectModifier::UpdateImpactOverlayLocatorCount() const -{ - if( EveImpactOverlayPtr overlay = m_object->GetImpactOverlay() ) - { - auto locators = m_object->GetLocatorsForSet( DAMAGE_LOCATOR_SET_NAME ); - overlay->SetDamageLocatorCount( locators ? uint32_t( locators->size() ) : 0 ); - } -} - -EveSpaceObjectChild::PartTag EveModularObjectModifier::AllocatePartId() const -{ - auto id = m_data->GetUnusedPartID(); - for( auto& child : m_object->GetEffectChildren() ) - { - if( child->GetPartTag() != EveSpaceObjectChild::NO_PART_TAG ) - { - id = std::max( id, child->GetPartTag() + 1 ); - } - } - return id; -} - -EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ) -{ - auto id = AllocatePartId(); - auto size = m_object->GetEffectChildren().size(); - auto dna = std::string( hullName ) + ":" + ( factionName[0] ? factionName : m_data->m_faction.c_str() ) + ":" + ( raceName[0] ? raceName : m_data->m_race.c_str() ); - if( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ) ) ) - { - return INVALID_PART_TAG; - } - - if( !m_instancedMeshes ) - { - for( size_t i = size; i < m_object->GetEffectChildren().size(); ++i ) - { - if( EveChildInstancedMeshesPtr instancedMesh = BlueCastPtr( m_object->GetEffectChildren()[i] ) ) - { - m_instancedMeshes = instancedMesh; - break; - } - } - } - - // SOF will reset the bounding sphere of the object to the one of the part - // Store the part bounding sphere and recalculate the bounding sphere of the modular object after adding all the parts - CcpMath::Sphere sphere{ m_object->GetBoundingSphereCenter(), m_object->GetBoundingSphereRadius() }; - - auto part = EveChildPartData::PartData{ id, position, rotation, scale, sphere }; - m_data->m_parts.emplace_back( part ); - m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); - UpdateImpactOverlayLocatorCount(); - return id; -} - -EveSpaceObjectChild::PartTag EveModularObjectModifier::AddChild( const char* resPath, const Vector3& position, const Quaternion& rotation, const Vector3& scale ) -{ - if( auto child = BeResMan->LoadObject( resPath ) ) - { - child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); - m_object->AddToEffectChildrenList( child ); - auto id = AllocatePartId(); - child->SetPartTag( id ); - m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, position, rotation, scale } ); - m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); - return id; - } - return INVALID_PART_TAG; -} - -BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag partId ) -{ - auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { - return part.partId == partId; - } ); - if( found == m_data->m_parts.end() ) - { - return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; - } - - for( size_t i = 0; i < m_object->GetEffectChildren().size(); ) - { - auto child = m_object->GetEffectChildren()[i]; - if( child->GetPartTag() == partId ) - { - m_object->RemoveFromEffectChildrenList( child ); - continue; - } - ++i; - } - - for( auto& set : m_object->GetLocatorSets() ) - { - auto& locators = *set->GetLocators(); - auto removed = std::remove_if( locators.begin(), locators.end(), [partId]( const auto& locator ) { - return locator.partTag == partId; - } ); - locators.Resize( std::distance( locators.begin(), removed ) ); - } - - if( m_instancedMeshes ) - { - m_instancedMeshes->RemoveInstancesByPartTag( partId ); - } - m_data->m_parts.erase( found ); - m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); - m_object->ClearImpactDamage(); - UpdateImpactOverlayLocatorCount(); - return BlueStdResultType::BLUE_STD_RESULT_OK; -} - -BlueStdResult EveModularObjectModifier::SetTransform( EveSpaceObjectChild::PartTag partId, const Vector3& position, const Quaternion& rotation, Vector3 scale ) -{ - auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { - return part.partId == partId; - } ); - if( found == m_data->m_parts.end() ) - { - return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; - } - - cmf::Transform oldTransform{ found->position, found->rotation, found->scale }; - cmf::Transform newTransform{ position, rotation, scale }; - auto invOldTransform = cmf::Inverse( oldTransform ); - - for( auto& set : m_object->GetLocatorSets() ) - { - auto& locators = *set->GetLocators(); - for( auto& locator : locators ) - { - if( locator.partTag == partId ) - { - locator.scale.x = scale.x / found->scale.x; - locator.scale.y = scale.y / found->scale.y; - locator.scale.z = scale.z / found->scale.z; - locator.direction = invOldTransform.rotation * rotation; - locator.position = cmf::TransformPoint( cmf::TransformPoint( locator.position, invOldTransform ), newTransform ); - } - } - } - - found->boundingSphere.center = cmf::TransformPoint( cmf::TransformPoint( found->boundingSphere.center, invOldTransform ), newTransform ); - found->boundingSphere.radius *= std::max( { scale.x, scale.y, scale.z } ) / std::max( { found->scale.x, found->scale.y, found->scale.z } ); - - found->position = position; - found->rotation = rotation; - found->scale = scale; - - for( auto& child : m_object->GetEffectChildren() ) - { - if( child->GetPartTag() == partId ) - { - child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); - } - } - m_object->InvalidateMergedLocators( LocatorInvalidationReason::PartMoved ); - return BlueStdResultType::BLUE_STD_RESULT_OK; -} - -BlueStdResult EveModularObjectModifier::GetPosition( EveSpaceObjectChild::PartTag partId, Vector3& position ) const -{ - auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { - return part.partId == partId; - } ); - if( found == m_data->m_parts.end() ) - { - return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; - } - position = found->position; - return BlueStdResultType::BLUE_STD_RESULT_OK; -} - -BlueStdResult EveModularObjectModifier::GetRotation( EveSpaceObjectChild::PartTag partId, Quaternion& rotation ) const -{ - auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { - return part.partId == partId; - } ); - if( found == m_data->m_parts.end() ) - { - return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; - } - rotation = found->rotation; - return BlueStdResultType::BLUE_STD_RESULT_OK; -} - -BlueStdResult EveModularObjectModifier::GetScale( EveSpaceObjectChild::PartTag partId, Vector3& scale ) const -{ - auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { - return part.partId == partId; - } ); - if( found == m_data->m_parts.end() ) - { - return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; - } - scale = found->scale; - return BlueStdResultType::BLUE_STD_RESULT_OK; -} - - -std::pair CreateModularObject( EveSOF* sof, const char* factionName, const char* raceName ) -{ - EveStation2Ptr object; - object.CreateInstance(); - object->Initialize(); - - EveChildPartDataPtr partData; - partData.CreateInstance(); - partData->m_faction = factionName; - partData->m_race = raceName; - - object->AddToEffectChildrenList( partData ); - - EveModularObjectModifierPtr modifier; - modifier.CreateInstance(); - modifier->Create( object, sof ); - return { IEveSpaceObject2Ptr( object ), modifier }; -} - -EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ) -{ - EveModularObjectModifierPtr modifier; - modifier.CreateInstance(); - modifier->Create( object, sof ); - return modifier; -} -EveSpaceObjectChild::PartTag GetInvalidPartTag() -{ - return EveModularObjectModifier::INVALID_PART_TAG; } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData.h b/trinity/Eve/SpaceObject/Children/EveChildPartData.h index 3d6158f20..d55d20284 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData.h @@ -3,7 +3,6 @@ #pragma once #include "EveSpaceObjectChild.h" -#include "../../SpaceObjectFactory/EveSOF.h" BLUE_CLASS_IMPL( EveChildPartData ); @@ -35,75 +34,4 @@ class EveChildPartData : public EveSpaceObjectChild std::vector m_parts; }; -TYPEDEF_BLUECLASS( EveChildPartData ); - - -BLUE_CLASS_IMPL( EveModularObjectModifier ); -/** - * @brief Transient edit session for a modular space object. Reads and writes the object's EveChildPartData and - * holds no persistent state itself. Object-level culling volumes only update on ApplyBounds(), which the - * destructor also calls as a fallback. - */ -class EveModularObjectModifier : public IRoot -{ -public: - using SpaceObjectType = EveSpaceObject2; - - EXPOSE_TO_BLUE(); - - void Create( SpaceObjectType* object, EveSOF* sof ); - ~EveModularObjectModifier(); - - /// @brief Returned by AddHull/AddChild when the part could not be built. Never a valid tag. - static constexpr EveSpaceObjectChild::PartTag INVALID_PART_TAG = 0xFFFFFFFF; - - /** - * @brief Builds a SOF hull as a new part at the given transform. Empty factionName/raceName fall back to - * the seed faction/race stored in EveChildPartData (set by CreateModularObject). - * @return The new part's tag, or INVALID_PART_TAG if the hull could not be built. - */ - EveSpaceObjectChild::PartTag AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); - - /** - * @brief Loads a space object child resource and adds it as a new part at the given transform. - * @return The new part's tag, or INVALID_PART_TAG if the resource could not be loaded. - */ - EveSpaceObjectChild::PartTag AddChild( const char* resPath, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); - - BlueStdResult Remove( EveSpaceObjectChild::PartTag partId ); - - /** - * @brief Recomputes the object's bounding sphere and shape ellipsoid from the current parts. - * Cheap; call after a batch of edits to keep culling volumes in sync. The destructor also calls it. - */ - void ApplyBounds(); - - BlueStdResult SetTransform( EveSpaceObjectChild::PartTag partId, const Vector3& position, const Quaternion& rotation, Vector3 scale ); - BlueStdResult GetPosition( EveSpaceObjectChild::PartTag partId, Vector3& position ) const; - BlueStdResult GetRotation( EveSpaceObjectChild::PartTag partId, Quaternion& rotation ) const; - BlueStdResult GetScale( EveSpaceObjectChild::PartTag partId, Vector3& scale ) const; - -private: - EveChildPartData::PartData* FindPartData( EveSpaceObjectChild::PartTag partId ) const; - EveSpaceObjectChild::PartTag AllocatePartId() const; - void UpdateImpactOverlayLocatorCount() const; - - BluePtr m_object; - EveChildPartDataPtr m_data; - EveChildInstancedMeshesPtr m_instancedMeshes; - EveSOFPtr m_sof; -}; - -TYPEDEF_BLUECLASS( EveModularObjectModifier ); - -/** - * @brief Creates an empty modular space object together with an open edit session for it. - * factionName/raceName seed the AddHull fallbacks. - */ -std::pair CreateModularObject( EveSOF* sof, const char* factionName, const char* raceName ); - -/// @brief Opens an edit session on an existing modular space object. -EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ); - -/// @brief Wrapper for EveModularObjectModifier::INVALID_PART_TAG because blue doesn't support exporting const variables. -EveSpaceObjectChild::PartTag GetInvalidPartTag(); +TYPEDEF_BLUECLASS( EveChildPartData ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp index 79dfea0b8..7fbf367f8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPartData_Blue.cpp @@ -13,32 +13,3 @@ const Be::ClassInfo* EveChildPartData::ExposeToBlue() MAP_INTERFACE( IEveSpaceObjectChild ) EXPOSURE_END() } - - -BLUE_DEFINE_NONEXPOSED( EveModularObjectModifier ); - -const Be::ClassInfo* EveModularObjectModifier::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveModularObjectModifier, "Edit session for a modular space object, from CreateModularObject or ModifyModularObject. Culling bounds update on ApplyBounds; dropping the last reference also applies them" ) - MAP_METHOD_AND_WRAP( "AddHull", AddHull, "Builds a SOF hull as a new part at the given transform. Empty faction/race fall back to the seeds given to CreateModularObject. Returns the new part tag, or GetInvalidPartTag() on failure" ); - MAP_METHOD_AND_WRAP( "AddChild", AddChild, "Loads a space object child resource and adds it as a new part at the given transform. Returns the new part tag, or GetInvalidPartTag() on failure" ) - MAP_METHOD_AND_WRAP( "Remove", Remove, "Removes a part: its effect children, mesh instances and locators. Clears accumulated impact damage. Key error if the part tag is unknown" ) - MAP_METHOD_AND_WRAP( "ApplyBounds", ApplyBounds, "Recomputes the object's bounding sphere and shape ellipsoid from the current parts. Call after a batch of edits to keep culling in sync" ) - MAP_METHOD_AND_WRAP( "SetTransform", SetTransform, "Moves a part: re-derives its effect children, locators and bounding sphere from the new transform. Key error if the part tag is unknown" ) - MAP_METHOD_AND_WRAP( "GetPosition", GetPosition, "Returns the part's position. Key error if the part tag is unknown" ) - MAP_METHOD_AND_WRAP( "GetRotation", GetRotation, "Returns the part's rotation. Key error if the part tag is unknown" ) - MAP_METHOD_AND_WRAP( "GetScale", GetScale, "Returns the part's scale. Key error if the part tag is unknown" ) - - EXPOSURE_END() -} - -MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, "Creates an empty modular space object and an edit session for it. Returns (object, modifier).\n" - "\n" - " obj, mod = trinity.CreateModularObject(sof, 'faction', 'race')\n" - " tag = mod.AddHull('hullname', '', '', pos, rot, scale) # '' -> seed faction/race\n" - " mod.SetTransform(tag, pos2, rot2, scale2)\n" - " mod.ApplyBounds() # apply culling bounds after a batch of edits\n" - " mod = None # end the session (also applies bounds)" ); -MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "Opens an edit session on an existing modular space object" ); - -MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the INVALID_PART_TAG constant" ); diff --git a/trinity/Eve/SpaceObject/Children/EveModularObjectModifier.cpp b/trinity/Eve/SpaceObject/Children/EveModularObjectModifier.cpp new file mode 100644 index 000000000..3a86747f2 --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveModularObjectModifier.cpp @@ -0,0 +1,299 @@ +// Copyright © 2026 CCP ehf. + +#include "StdAfx.h" +#include "EveModularObjectModifier.h" +#include "IEveEffectChildrenOwner.h" +#include "../EveStation2.h" +#include "../Attachments/EveImpactOverlay.h" +#include "EveChildInstancedMeshes.h" +#include "EveChildContainer.h" +#include + + +void EveModularObjectModifier::Create( SpaceObjectType* object, EveSOF* sof ) +{ + m_object = object; + m_sof = sof; + for( auto& child : object->GetEffectChildren() ) + { + if( EveChildPartDataPtr partData = BlueCastPtr( child ) ) + { + m_data = partData; + break; + } + } + if( !m_data ) + { + m_data.CreateInstance(); + object->AddToEffectChildrenList( m_data ); + } + for( auto& child : object->GetEffectChildren() ) + { + if( EveChildInstancedMeshesPtr instancedMeshes = BlueCastPtr( child ) ) + { + m_instancedMeshes = instancedMeshes; + break; + } + } +} + +EveModularObjectModifier::~EveModularObjectModifier() +{ + ApplyBounds(); +} + +void EveModularObjectModifier::ApplyBounds() +{ + if( m_object ) + { + std::vector orderedParts; + orderedParts.reserve( m_data->m_parts.size() ); + for( const auto& part : m_data->m_parts ) + { + orderedParts.push_back( &part ); + } + std::sort( orderedParts.begin(), orderedParts.end(), []( const auto* a, const auto* b ) { + return a->boundingSphere.radius > b->boundingSphere.radius; + } ); + + CcpMath::Sphere bounds; + CcpMath::AxisAlignedBox box; + for( const auto* part : orderedParts ) + { + bounds.Include( part->boundingSphere ); + box.IncludeSphere( part->boundingSphere ); + } + m_object->SetBoundingSphereInformation( bounds ); + m_object->SetShapeEllipsoid( m_data->m_parts.empty() ? CcpMath::AxisAlignedEllipsoid{} : CcpMath::AxisAlignedEllipsoid{ box, true } ); + } +} + +void EveModularObjectModifier::UpdateImpactOverlayLocatorCount() const +{ + if( EveImpactOverlayPtr overlay = m_object->GetImpactOverlay() ) + { + auto locators = m_object->GetLocatorsForSet( DAMAGE_LOCATOR_SET_NAME ); + overlay->SetDamageLocatorCount( locators ? uint32_t( locators->size() ) : 0 ); + } +} + +EveSpaceObjectChild::PartTag EveModularObjectModifier::AllocatePartId() const +{ + auto id = m_data->GetUnusedPartID(); + for( auto& child : m_object->GetEffectChildren() ) + { + if( child->GetPartTag() != EveSpaceObjectChild::NO_PART_TAG ) + { + id = std::max( id, child->GetPartTag() + 1 ); + } + } + return id; +} + +EveSpaceObjectChild::PartTag EveModularObjectModifier::AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ) +{ + auto id = AllocatePartId(); + auto size = m_object->GetEffectChildren().size(); + auto dna = std::string( hullName ) + ":" + ( factionName[0] ? factionName : m_data->m_faction.c_str() ) + ":" + ( raceName[0] ? raceName : m_data->m_race.c_str() ); + if( !m_sof->BuildChild( m_object, dna.c_str(), id, TransformationMatrix( scale, rotation, position ) ) ) + { + return INVALID_PART_TAG; + } + + if( !m_instancedMeshes ) + { + for( size_t i = size; i < m_object->GetEffectChildren().size(); ++i ) + { + if( EveChildInstancedMeshesPtr instancedMesh = BlueCastPtr( m_object->GetEffectChildren()[i] ) ) + { + m_instancedMeshes = instancedMesh; + break; + } + } + } + + // SOF will reset the bounding sphere of the object to the one of the part + // Store the part bounding sphere and recalculate the bounding sphere of the modular object after adding all the parts + CcpMath::Sphere sphere{ m_object->GetBoundingSphereCenter(), m_object->GetBoundingSphereRadius() }; + + auto part = EveChildPartData::PartData{ id, position, rotation, scale, sphere }; + m_data->m_parts.emplace_back( part ); + m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); + UpdateImpactOverlayLocatorCount(); + return id; +} + +EveSpaceObjectChild::PartTag EveModularObjectModifier::AddChild( const char* resPath, const Vector3& position, const Quaternion& rotation, const Vector3& scale ) +{ + if( auto child = BeResMan->LoadObject( resPath ) ) + { + child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); + m_object->AddToEffectChildrenList( child ); + auto id = AllocatePartId(); + child->SetPartTag( id ); + m_data->m_parts.emplace_back( EveChildPartData::PartData{ id, position, rotation, scale } ); + m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); + return id; + } + return INVALID_PART_TAG; +} + +BlueStdResult EveModularObjectModifier::Remove( EveSpaceObjectChild::PartTag partId ) +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + + for( size_t i = 0; i < m_object->GetEffectChildren().size(); ) + { + auto child = m_object->GetEffectChildren()[i]; + if( child->GetPartTag() == partId ) + { + m_object->RemoveFromEffectChildrenList( child ); + continue; + } + ++i; + } + + for( auto& set : m_object->GetLocatorSets() ) + { + auto& locators = *set->GetLocators(); + auto removed = std::remove_if( locators.begin(), locators.end(), [partId]( const auto& locator ) { + return locator.partTag == partId; + } ); + locators.Resize( std::distance( locators.begin(), removed ) ); + } + + if( m_instancedMeshes ) + { + m_instancedMeshes->RemoveInstancesByPartTag( partId ); + } + m_data->m_parts.erase( found ); + m_object->InvalidateMergedLocators( LocatorInvalidationReason::StructureChanged ); + m_object->ClearImpactDamage(); + UpdateImpactOverlayLocatorCount(); + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + +BlueStdResult EveModularObjectModifier::SetTransform( EveSpaceObjectChild::PartTag partId, const Vector3& position, const Quaternion& rotation, Vector3 scale ) +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + + cmf::Transform oldTransform{ found->position, found->rotation, found->scale }; + cmf::Transform newTransform{ position, rotation, scale }; + auto invOldTransform = cmf::Inverse( oldTransform ); + + for( auto& set : m_object->GetLocatorSets() ) + { + auto& locators = *set->GetLocators(); + for( auto& locator : locators ) + { + if( locator.partTag == partId ) + { + locator.scale.x = scale.x / found->scale.x; + locator.scale.y = scale.y / found->scale.y; + locator.scale.z = scale.z / found->scale.z; + locator.direction = invOldTransform.rotation * rotation; + locator.position = cmf::TransformPoint( cmf::TransformPoint( locator.position, invOldTransform ), newTransform ); + } + } + } + + found->boundingSphere.center = cmf::TransformPoint( cmf::TransformPoint( found->boundingSphere.center, invOldTransform ), newTransform ); + found->boundingSphere.radius *= std::max( { scale.x, scale.y, scale.z } ) / std::max( { found->scale.x, found->scale.y, found->scale.z } ); + + found->position = position; + found->rotation = rotation; + found->scale = scale; + + for( auto& child : m_object->GetEffectChildren() ) + { + if( child->GetPartTag() == partId ) + { + child->Setup( &scale, &rotation, &position, Tr2Lod::TR2_LOD_LOW ); + } + } + m_object->InvalidateMergedLocators( LocatorInvalidationReason::PartMoved ); + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + +BlueStdResult EveModularObjectModifier::GetPosition( EveSpaceObjectChild::PartTag partId, Vector3& position ) const +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + position = found->position; + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + +BlueStdResult EveModularObjectModifier::GetRotation( EveSpaceObjectChild::PartTag partId, Quaternion& rotation ) const +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + rotation = found->rotation; + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + +BlueStdResult EveModularObjectModifier::GetScale( EveSpaceObjectChild::PartTag partId, Vector3& scale ) const +{ + auto found = std::find_if( m_data->m_parts.begin(), m_data->m_parts.end(), [partId]( const EveChildPartData::PartData& part ) { + return part.partId == partId; + } ); + if( found == m_data->m_parts.end() ) + { + return BlueStdResultType::BLUE_STD_RESULT_KEY_ERROR; + } + scale = found->scale; + return BlueStdResultType::BLUE_STD_RESULT_OK; +} + + +std::pair CreateModularObject( EveSOF* sof, const char* factionName, const char* raceName ) +{ + EveStation2Ptr object; + object.CreateInstance(); + object->Initialize(); + + EveChildPartDataPtr partData; + partData.CreateInstance(); + partData->m_faction = factionName; + partData->m_race = raceName; + + object->AddToEffectChildrenList( partData ); + + EveModularObjectModifierPtr modifier; + modifier.CreateInstance(); + modifier->Create( object, sof ); + return { IEveSpaceObject2Ptr( object ), modifier }; +} + +EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ) +{ + EveModularObjectModifierPtr modifier; + modifier.CreateInstance(); + modifier->Create( object, sof ); + return modifier; +} +EveSpaceObjectChild::PartTag GetInvalidPartTag() +{ + return EveModularObjectModifier::INVALID_PART_TAG; +} \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveModularObjectModifier.h b/trinity/Eve/SpaceObject/Children/EveModularObjectModifier.h new file mode 100644 index 000000000..53bdc6fc7 --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveModularObjectModifier.h @@ -0,0 +1,77 @@ +// Copyright © 2026 CCP ehf. + +#pragma once + +#include "EveChildPartData.h" +#include "../../SpaceObjectFactory/EveSOF.h" + + +BLUE_CLASS_IMPL( EveModularObjectModifier ); +/** + * @brief Transient edit session for a modular space object. Reads and writes the object's EveChildPartData and + * holds no persistent state itself. Object-level culling volumes only update on ApplyBounds(), which the + * destructor also calls as a fallback. + */ +class EveModularObjectModifier : public IRoot +{ +public: + using SpaceObjectType = EveSpaceObject2; + + EXPOSE_TO_BLUE(); + + void Create( SpaceObjectType* object, EveSOF* sof ); + ~EveModularObjectModifier(); + + /// @brief Returned by AddHull/AddChild when the part could not be built. Never a valid tag. + static constexpr EveSpaceObjectChild::PartTag INVALID_PART_TAG = 0xFFFFFFFF; + + /** + * @brief Builds a SOF hull as a new part at the given transform. Empty factionName/raceName fall back to + * the seed faction/race stored in EveChildPartData (set by CreateModularObject). + * @return The new part's tag, or INVALID_PART_TAG if the hull could not be built. + */ + EveSpaceObjectChild::PartTag AddHull( const char* hullName, const char* factionName, const char* raceName, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); + + /** + * @brief Loads a space object child resource and adds it as a new part at the given transform. + * @return The new part's tag, or INVALID_PART_TAG if the resource could not be loaded. + */ + EveSpaceObjectChild::PartTag AddChild( const char* resPath, const Vector3& position, const Quaternion& rotation, const Vector3& scale ); + + BlueStdResult Remove( EveSpaceObjectChild::PartTag partId ); + + /** + * @brief Recomputes the object's bounding sphere and shape ellipsoid from the current parts. + * Cheap; call after a batch of edits to keep culling volumes in sync. The destructor also calls it. + */ + void ApplyBounds(); + + BlueStdResult SetTransform( EveSpaceObjectChild::PartTag partId, const Vector3& position, const Quaternion& rotation, Vector3 scale ); + BlueStdResult GetPosition( EveSpaceObjectChild::PartTag partId, Vector3& position ) const; + BlueStdResult GetRotation( EveSpaceObjectChild::PartTag partId, Quaternion& rotation ) const; + BlueStdResult GetScale( EveSpaceObjectChild::PartTag partId, Vector3& scale ) const; + +private: + EveChildPartData::PartData* FindPartData( EveSpaceObjectChild::PartTag partId ) const; + EveSpaceObjectChild::PartTag AllocatePartId() const; + void UpdateImpactOverlayLocatorCount() const; + + BluePtr m_object; + EveChildPartDataPtr m_data; + EveChildInstancedMeshesPtr m_instancedMeshes; + EveSOFPtr m_sof; +}; + +TYPEDEF_BLUECLASS( EveModularObjectModifier ); + +/** + * @brief Creates an empty modular space object together with an open edit session for it. + * factionName/raceName seed the AddHull fallbacks. + */ +std::pair CreateModularObject( EveSOF* sof, const char* factionName, const char* raceName ); + +/// @brief Opens an edit session on an existing modular space object. +EveModularObjectModifierPtr ModifyModularObject( EveModularObjectModifier::SpaceObjectType* object, EveSOF* sof ); + +/// @brief Wrapper for EveModularObjectModifier::INVALID_PART_TAG because blue doesn't support exporting const variables. +EveSpaceObjectChild::PartTag GetInvalidPartTag(); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp new file mode 100644 index 000000000..f167aac57 --- /dev/null +++ b/trinity/Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp @@ -0,0 +1,33 @@ +// Copyright © 2026 CCP ehf. + +#include "StdAfx.h" +#include "EveModularObjectModifier.h" + + +BLUE_DEFINE_NONEXPOSED( EveModularObjectModifier ); + +const Be::ClassInfo* EveModularObjectModifier::ExposeToBlue() +{ + EXPOSURE_BEGIN( EveModularObjectModifier, "Edit session for a modular space object, from CreateModularObject or ModifyModularObject. Culling bounds update on ApplyBounds; dropping the last reference also applies them" ) + MAP_METHOD_AND_WRAP( "AddHull", AddHull, "Builds a SOF hull as a new part at the given transform. Empty faction/race fall back to the seeds given to CreateModularObject. Returns the new part tag, or GetInvalidPartTag() on failure" ); + MAP_METHOD_AND_WRAP( "AddChild", AddChild, "Loads a space object child resource and adds it as a new part at the given transform. Returns the new part tag, or GetInvalidPartTag() on failure" ) + MAP_METHOD_AND_WRAP( "Remove", Remove, "Removes a part: its effect children, mesh instances and locators. Clears accumulated impact damage. Key error if the part tag is unknown" ) + MAP_METHOD_AND_WRAP( "ApplyBounds", ApplyBounds, "Recomputes the object's bounding sphere and shape ellipsoid from the current parts. Call after a batch of edits to keep culling in sync" ) + MAP_METHOD_AND_WRAP( "SetTransform", SetTransform, "Moves a part: re-derives its effect children, locators and bounding sphere from the new transform. Key error if the part tag is unknown" ) + MAP_METHOD_AND_WRAP( "GetPosition", GetPosition, "Returns the part's position. Key error if the part tag is unknown" ) + MAP_METHOD_AND_WRAP( "GetRotation", GetRotation, "Returns the part's rotation. Key error if the part tag is unknown" ) + MAP_METHOD_AND_WRAP( "GetScale", GetScale, "Returns the part's scale. Key error if the part tag is unknown" ) + + EXPOSURE_END() +} + +MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, "Creates an empty modular space object and an edit session for it. Returns (object, modifier).\n" + "\n" + " obj, mod = trinity.CreateModularObject(sof, 'faction', 'race')\n" + " tag = mod.AddHull('hullname', '', '', pos, rot, scale) # '' -> seed faction/race\n" + " mod.SetTransform(tag, pos2, rot2, scale2)\n" + " mod.ApplyBounds() # apply culling bounds after a batch of edits\n" + " mod = None # end the session (also applies bounds)" ); +MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "Opens an edit session on an existing modular space object" ); + +MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the INVALID_PART_TAG constant" ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp index 6c48c4fc4..6fec973fa 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp @@ -479,14 +479,12 @@ bool EveSOF::BuildChild( EveSpaceObject2* newObj, const char* dnaString, uint32_ SetupAudio( BlueCastPtr( placementContainer ), dna, transform ); - //SetupInstancedMeshes( newObj, dna, placementOffsets ); - + // Old style instanced meshes are not supported here if( hasChildEffects ) { SetupEffects( newObj, (IEveEffectChildrenOwnerPtr)placementContainer, dna, placementOffsets, buildFlags ); } - //SetupCustomMask( newObj, dna ); if( !newObj->GetImpactOverlay() ) { SetupImpactEffects( newObj, dna ); From 50e8f0b8bfc6da29b35ba4b4991d1df46e0de2cb Mon Sep 17 00:00:00 2001 From: breki Date: Thu, 20 Aug 2026 15:00:21 +0000 Subject: [PATCH 29/29] fixup comment --- .../Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trinity/Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp index f167aac57..bdf5c2535 100644 --- a/trinity/Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveModularObjectModifier_Blue.cpp @@ -27,7 +27,7 @@ MAP_FUNCTION_AND_WRAP( "CreateModularObject", CreateModularObject, "Creates an e " tag = mod.AddHull('hullname', '', '', pos, rot, scale) # '' -> seed faction/race\n" " mod.SetTransform(tag, pos2, rot2, scale2)\n" " mod.ApplyBounds() # apply culling bounds after a batch of edits\n" - " mod = None # end the session (also applies bounds)" ); + " del mod # end the session (also applies bounds)" ); MAP_FUNCTION_AND_WRAP( "ModifyModularObject", ModifyModularObject, "Opens an edit session on an existing modular space object" ); MAP_FUNCTION_AND_WRAP( "GetInvalidPartTag", GetInvalidPartTag, "Gets the INVALID_PART_TAG constant" ); \ No newline at end of file