Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions trinity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,9 @@ set(_SOURCES
Resources/Tr2EffectRes.cpp
Resources/Tr2EffectRes.h
Resources/Tr2EffectRes_Blue.cpp
Resources/Tr2GeometryProvider.cpp
Resources/Tr2GeometryProvider.h
Resources/Tr2GeometryProvider_Blue.cpp
Resources/Tr2GrannyStateRes.cpp
Resources/Tr2GrannyStateRes.h
Resources/Tr2GrannyStateRes_Blue.cpp
Expand All @@ -1262,6 +1265,15 @@ set(_SOURCES
Resources/Tr2MaterialRes.cpp
Resources/Tr2MaterialRes.h
Resources/Tr2MaterialRes_Blue.cpp
Resources/Tr2ProceduralCube.cpp
Resources/Tr2ProceduralCube.h
Resources/Tr2ProceduralCube_Blue.cpp
Resources/Tr2ProceduralGeometryProvider.cpp
Resources/Tr2ProceduralGeometryProvider.h
Resources/Tr2ProceduralGeometryProvider_Blue.cpp
Resources/Tr2ProceduralSierpinski.cpp
Resources/Tr2ProceduralSierpinski.h
Resources/Tr2ProceduralSierpinski_Blue.cpp
Resources/Tr2TextureLodManager.cpp
Resources/Tr2TextureLodManager.h
Resources/Tr2TextureLodManager_Blue.cpp
Expand Down Expand Up @@ -1484,6 +1496,8 @@ set(_SOURCES
Tr2AtlasTexture.cpp
Tr2AtlasTexture.h
Tr2AtlasTexture_Blue.cpp
Tr2BackgroundWorker.cpp
Tr2BackgroundWorker.h
Tr2BindingVector3.h
Tr2BindingVector3_Blue.cpp
Tr2Blitter.cpp
Expand Down Expand Up @@ -1594,6 +1608,9 @@ set(_SOURCES
Tr2MeshBase.cpp
Tr2MeshBase.h
Tr2MeshBase_Blue.cpp
Tr2MeshProcedural.cpp
Tr2MeshProcedural.h
Tr2MeshProcedural_Blue.cpp
Tr2Model.cpp
Tr2Model.h
Tr2Model_Blue.cpp
Expand Down Expand Up @@ -1743,6 +1760,12 @@ set(_SOURCES
Tr2VolumetricsRenderer.cpp
Tr2VolumetricsRenderer.h
Tr2VolumetricsRenderer_Blue.cpp
Tr2VoxelData.cpp
Tr2VoxelData.h
Tr2VoxelData_Blue.cpp
Tr2VoxelTexture.cpp
Tr2VoxelTexture.h
Tr2VoxelTexture_Blue.cpp
TriColor.cpp
TriColor_Blue.cpp
TriConstants.cpp
Expand Down
6 changes: 3 additions & 3 deletions trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void EveSpaceObjectDecal::UpdateVisibility( const EveUpdateContext& updateContex
}

// ------------------------------------------------------------------------------------------------------
void EveSpaceObjectDecal::GetRenderables( std::vector<ITr2Renderable*>& renderables, DecalMeshCache& meshCache, TriGeometryRes* geomRes, float screensize )
void EveSpaceObjectDecal::GetRenderables( std::vector<ITr2Renderable*>& renderables, DecalMeshCache& meshCache, Tr2GeometryProvider* geomRes, float screensize )
{
if( m_isVisible <= 0 || !geomRes )
{
Expand Down Expand Up @@ -589,7 +589,7 @@ void EveSpaceObjectDecal::SetBoneIndex( int idx )
}

// ------------------------------------------------------------------------------------------------------
void EveSpaceObjectDecal::CreateDecalIndexBuffers( TriGeometryResPtr geomRes, DecalMeshCache& meshCache )
void EveSpaceObjectDecal::CreateDecalIndexBuffers( Tr2GeometryProviderPtr geomRes, DecalMeshCache& meshCache )
{
TRINITY_STATS_ZONE( __FUNCTION__ );

Expand Down Expand Up @@ -824,7 +824,7 @@ void EveSpaceObjectDecal::SetMinScreenSize( float minScreenSize )
m_minScreenSize = minScreenSize;
}

void EveSpaceObjectDecal::CreateStaticIndexBuffers( TriGeometryResPtr geomRes )
void EveSpaceObjectDecal::CreateStaticIndexBuffers( Tr2GeometryProviderPtr geomRes )
{
TRINITY_STATS_ZONE( __FUNCTION__ );

Expand Down
8 changes: 4 additions & 4 deletions trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ BLUE_CLASS( EveSpaceObjectDecal ) :

// access
void UpdateVisibility( const EveUpdateContext& updateContext, const IEveSpaceObject2::ParentData* parentData );
void GetRenderables( std::vector<ITr2Renderable*> & renderables, DecalMeshCache & meshCache, TriGeometryRes * geomRes, float screensize );
void GetRenderables( std::vector<ITr2Renderable*> & renderables, DecalMeshCache & meshCache, Tr2GeometryProvider * geomRes, float screensize );
void GetInstancedRenderables( std::vector<ITr2Renderable*> & renderables, DecalMeshCache & meshCache, const Tr2InstancedMesh* instancedMesh, float instanceScreenSize = std::numeric_limits<float>::max() );

// access position etc.
Expand Down Expand Up @@ -160,10 +160,10 @@ BLUE_CLASS( EveSpaceObjectDecal ) :

private:
// create
void CreateDecalIndexBuffers( TriGeometryResPtr geomRes, DecalMeshCache & meshCache );
void CreateDecalIndexBuffers( Tr2GeometryProviderPtr geomRes, DecalMeshCache & meshCache );
// update
void UpdateDecalMatrix();
void CreateStaticIndexBuffers( TriGeometryResPtr geomRes );
void CreateStaticIndexBuffers( Tr2GeometryProviderPtr geomRes );

bool HasStaticIndexBuffers() const;
std::vector<std::vector<uint32_t>> GetStaticIndexBuffers() const;
Expand Down Expand Up @@ -195,7 +195,7 @@ BLUE_CLASS( EveSpaceObjectDecal ) :
Matrix m_inverseDecalMatrix;

// base mesh geometry
TriGeometryResPtr m_baseGeometryResource;
Tr2GeometryProviderPtr m_baseGeometryResource;
int m_geometryLodIndex;

std::shared_ptr<MeshDecalData> m_decalGeometry;
Expand Down
38 changes: 23 additions & 15 deletions trinity/Eve/SpaceObject/Children/EveChildMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void EveChildMesh::InitializeAnimation()
if( auto geometry = m_mesh->GetGeometryResource() )
{
m_animationUpdater->SetUseMeshBinding( true );
m_animationUpdater->SetSharedGeometryRes( geometry );
m_animationUpdater->SetSharedGeometryRes( BlueCastPtr( geometry ) );
return;
}
}
Expand Down Expand Up @@ -711,7 +711,7 @@ void EveChildMesh::GetBatchesFromOverlayVector( ITriRenderBatchAccumulator* batc
return;
}

TriGeometryRes* geomRes = m_mesh->GetGeometryResource();
Tr2GeometryProvider* geomRes = m_mesh->GetGeometryResource();
if( !geomRes || !geomRes->IsGood() )
{
return;
Expand Down Expand Up @@ -1167,6 +1167,7 @@ void EveChildMesh::UpdateSyncronous( const EveUpdateContext& updateContext, cons
UnregisterAudioGeometry();
}
m_allowAudioGeometry = allowAudioGeometry;

if( m_animationUpdater )
{
if( m_mesh && m_animationUpdater->GetResPath().empty() )
Expand All @@ -1185,9 +1186,16 @@ void EveChildMesh::UpdateSyncronous( const EveUpdateContext& updateContext, cons

if( m_mesh && !m_animationUpdater->HasMeshBinding() )
{
if( !m_meshBinding || m_meshBinding->GetAnimation() != m_animationUpdater || m_meshBinding->GetGeometryRes() != m_mesh->GetGeometryResource() || m_meshBinding->GetMeshIndex() != m_mesh->GetMeshIndex() )
auto geometryRes = dynamic_cast<TriGeometryRes*>( m_mesh->GetGeometryResource() );

if( m_meshBinding && ( m_meshBinding->GetAnimation() != m_animationUpdater || m_meshBinding->GetGeometryRes() != geometryRes || m_meshBinding->GetMeshIndex() != m_mesh->GetMeshIndex() ) )
{
m_meshBinding = {};
}

if( !m_meshBinding && geometryRes )
{
m_meshBinding = std::make_unique<Tr2AnimationMeshBinding>( m_animationUpdater, m_mesh->GetGeometryResource(), m_mesh->GetMeshIndex() );
m_meshBinding = std::make_unique<Tr2AnimationMeshBinding>( m_animationUpdater, geometryRes, m_mesh->GetMeshIndex() );
}
}
else
Expand Down Expand Up @@ -1428,10 +1436,14 @@ void EveChildMesh::RenderDebugInfo( ITr2DebugRenderer2& renderer )
m_mesh->RenderDebugInfo( m_worldTransform, renderer, nullptr );
}

if( bvhOptionEnabled && !m_bvhVisualizationGeometry && m_mesh->GetGeometryResource() && m_mesh->GetGeometryResource()->IsGood() )
if( bvhOptionEnabled && !m_bvhVisualizationGeometry )
{
m_bvhVisualizationGeometry = m_mesh->GetGeometryResource();
m_bvhVisualizationGeometry->PrepareRayCaster();
TriGeometryResPtr geometryRes = BlueCastPtr( m_mesh->GetGeometryResource() );
if( geometryRes && geometryRes->IsGood() )
{
m_bvhVisualizationGeometry = geometryRes;
m_bvhVisualizationGeometry->PrepareRayCaster();
}
}
if( m_bvhVisualizationGeometry && m_bvhVisualizationGeometry->IsRayCasterReady() )
{
Expand Down Expand Up @@ -1543,16 +1555,12 @@ std::pair<const Float4x3*, size_t> EveChildMesh::GetRestPoseBoneTransforms() con
return std::make_pair( nullptr, 0 );
}

// Skinned shaders without an animation get rest-pose (identity) skin matrices, sized to the
// geometry's bone bindings. Unskinned geometry drawn with a skinned shader (e.g. a SOF hull
// flagged isSkinned) has no bindings and no blend indices in the vertex stream, so every
// vertex reads bone 0 - a single identity matrix covers it.
// Fixes skinned shader used with uninitialized animationUpdater (no skeleton), or used with no boneBindings. Otherwise shader would read garbage.
size_t boneCount = 1;
auto cmfData = m_mesh->GetGeometryResource()->GetCMFData();
auto meshIndex = m_mesh->GetMeshIndex();
if( cmfData && meshIndex < cmfData->meshes.size() )
auto meshData = m_mesh->GetGeometryResource()->GetMeshData( m_mesh->GetMeshIndex() );
if( meshData )
{
boneCount = std::max<size_t>( cmfData->meshes[meshIndex].boneBindings.size(), 1 );
boneCount = std::max<size_t>( meshData->m_jointBindings.size(), 1 );
}
if( m_restPoseBoneTransforms.size() != boneCount )
{
Expand Down
4 changes: 2 additions & 2 deletions trinity/Eve/SpaceObject/Children/EveChildTurret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void EveChildTurret::UpdateCachedGeometryData()
m_cachedGeometryRes = geometryRes;
}
}
void EveChildTurret::BuildCachedGeometryData( TriGeometryRes& geometryRes )
void EveChildTurret::BuildCachedGeometryData( Tr2GeometryProvider& geometryRes )
{
if( geometryRes.GetSkeletonCount() )
{
Expand Down Expand Up @@ -771,7 +771,7 @@ Matrix EveChildTurret::GetTurretBoneTransform( uint32_t boneID ) const
return matrix;
}

TriGeometryRes* EveChildTurret::GetGeometryRes() const
Tr2GeometryProvider* EveChildTurret::GetGeometryRes() const
{
return m_mesh ? m_mesh->GetGeometryResource() : nullptr;
}
Expand Down
6 changes: 3 additions & 3 deletions trinity/Eve/SpaceObject/Children/EveChildTurret.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ BLUE_CLASS( EveChildTurret ) :
void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override;

void UpdateCachedGeometryData();
void BuildCachedGeometryData( TriGeometryRes & geometryRes );
void BuildCachedGeometryData( Tr2GeometryProvider & geometryRes );
void ReleaseCachedGeometryData();

// action
Expand Down Expand Up @@ -81,7 +81,7 @@ BLUE_CLASS( EveChildTurret ) :

Matrix GetTurretBoneTransform( uint32_t boneID ) const;

TriGeometryRes* GetGeometryRes() const;
Tr2GeometryProvider* GetGeometryRes() const;

// animation
float PlayAnimation( const std::string& animName, const std::string& animNameIdle, float delay = 0.f );
Expand Down Expand Up @@ -141,7 +141,7 @@ BLUE_CLASS( EveChildTurret ) :
std::wstring m_idleToTargetingMovementAudioEvent;
std::wstring m_targetingToIdleMovementAudioEvent;

TriGeometryResPtr m_cachedGeometryRes;
Tr2GeometryProviderPtr m_cachedGeometryRes;
};

TYPEDEF_BLUECLASS( EveChildTurret );
Expand Down
2 changes: 1 addition & 1 deletion trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct EveChildGeometryArea
*/
struct EveChildGeometry
{
class TriGeometryRes* geometry = nullptr;
class Tr2GeometryProvider* geometry = nullptr;
Matrix childToObject = IdentityMatrix();
uint32_t areaStart = 0;
uint32_t areaCount = 0;
Expand Down
20 changes: 11 additions & 9 deletions trinity/Eve/SpaceObject/EveSpaceObject2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void GetSortedBatchesFromMeshAreaVector( const Tr2MeshAreaVector* areas,
float screenSize,
const Matrix* worldTransform )
{
TriGeometryRes* geomRes = mesh->GetGeometryResource();
Tr2GeometryProvider* geomRes = mesh->GetGeometryResource();

if( !geomRes || !geomRes->IsGood() )
{
Expand Down Expand Up @@ -1181,7 +1181,7 @@ void EveSpaceObject2::GetShadowBatches( ITriRenderBatchAccumulator* batches, con
return;
}

TriGeometryRes* geomRes = m_mesh->GetGeometryResource();
Tr2GeometryProvider* geomRes = m_mesh->GetGeometryResource();
if( !geomRes || !geomRes->IsGood() )
{
return;
Expand Down Expand Up @@ -1251,7 +1251,7 @@ void EveSpaceObject2::GetBatchesFromOverlayVector( ITriRenderBatchAccumulator* b
{
return;
}
TriGeometryRes* geomRes = mesh->GetGeometryResource();
Tr2GeometryProvider* geomRes = mesh->GetGeometryResource();
if( !geomRes || !geomRes->IsGood() )
{
return;
Expand Down Expand Up @@ -1489,7 +1489,8 @@ Vector4 EveSpaceObject2::CalculateSkinnedBoundingSphere()
#if WITH_GRANNY
else
{
return m_animationUpdater->CalculateSkinnedBoundingSphere( m_mesh->GetGeometryResource()->GetGrannyInfo() );
auto geometry = dynamic_cast<TriGeometryRes*>( m_mesh->GetGeometryResource() );
return m_animationUpdater->CalculateSkinnedBoundingSphere( geometry ? geometry->GetGrannyInfo() : nullptr );
}
#endif
}
Expand Down Expand Up @@ -1524,7 +1525,8 @@ std::pair<Vector3, Vector3> EveSpaceObject2::CalculateSkinnedBoundingBoxFromTran
#if WITH_GRANNY
else
{
m_animationUpdater->CalculateSkinnedBoundingBoxFromTransform( transform, bbMin, bbMax, m_geometryResFromMesh->GetGrannyInfo() );
TriGeometryResPtr geometry = BlueCastPtr( m_geometryResFromMesh );
m_animationUpdater->CalculateSkinnedBoundingBoxFromTransform( transform, bbMin, bbMax, geometry ? geometry->GetGrannyInfo() : nullptr );
}
#endif
}
Expand Down Expand Up @@ -1577,7 +1579,7 @@ void EveSpaceObject2::PushChildrenAndDecalRenderables( std::vector<ITr2Renderabl
// are decals visible?
if( m_mesh && m_isMeshVisible )
{
TriGeometryResPtr geometryRes = m_mesh->GetGeometryResource();
Tr2GeometryProviderPtr geometryRes = m_mesh->GetGeometryResource();
if( geometryRes )
{
DecalMeshCache meshCache;
Expand Down Expand Up @@ -2381,7 +2383,7 @@ bool EveSpaceObject2::RebuildBoundingSphereInformation()
return false;
}

TriGeometryRes* geomRes = mesh->GetGeometryResource();
Tr2GeometryProvider* geomRes = mesh->GetGeometryResource();
if( !geomRes || !geomRes->IsGood() )
{
return false;
Expand Down Expand Up @@ -3199,7 +3201,7 @@ void EveSpaceObject2::PrepareForAnimation()
m_geometryResFromMesh = geometryRes;

m_animationUpdater->SetUseMeshBinding( true );
m_animationUpdater->SetSharedGeometryRes( m_geometryResFromMesh );
m_animationUpdater->SetSharedGeometryRes( BlueCastPtr( m_geometryResFromMesh ) );

m_geometryResFromMesh->AddNotifyTarget( this );
}
Expand Down Expand Up @@ -4220,7 +4222,7 @@ bool EveSpaceObject2::IsBoundingBoxReady() const
return false;
}

TriGeometryRes* geomRes = mesh->GetGeometryResource();
Tr2GeometryProvider* geomRes = mesh->GetGeometryResource();
if( !geomRes || !geomRes->IsGood() )
{
return false;
Expand Down
5 changes: 3 additions & 2 deletions trinity/Eve/SpaceObject/EveSpaceObject2.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ BLUE_DECLARE_INTERFACE( IEveSpaceObject2 );
BLUE_DECLARE( EveSpaceObject2 );
BLUE_DECLARE_VECTOR( EveSpaceObject2 );
BLUE_DECLARE( TriGeometryRes );
BLUE_DECLARE( Tr2GeometryProvider );
BLUE_DECLARE( Tr2MeshBase );
BLUE_DECLARE( Tr2MeshArea );
BLUE_DECLARE_VECTOR( Tr2MeshArea );
Expand Down Expand Up @@ -182,7 +183,7 @@ struct LocatorSourceRange

struct DamageFilterOccluder
{
TriGeometryResPtr geometry;
Tr2GeometryProviderPtr geometry;
Matrix fromObject;
uint32_t areaStart = 0;
uint32_t areaCount = 0;
Expand Down Expand Up @@ -635,7 +636,7 @@ BLUE_CLASS( EveSpaceObject2 ) :
Tr2Lod m_lodLevel;
Tr2Lod m_lodLevelWithChildren;

TriGeometryResPtr m_geometryResFromMesh;
Tr2GeometryProviderPtr m_geometryResFromMesh;

/////////////////////////////////////////////////////////////////////////////////////
// dissolve
Expand Down
6 changes: 3 additions & 3 deletions trinity/Eve/SpaceObject/EveSwarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void EveSwarmRenderable::InitDecals( const PEveSpaceObjectDecalVector& decals )

void EveSwarmRenderable::PushDecals( std::vector<ITr2Renderable*>& renderables, float screensize )
{
TriGeometryResPtr geometryRes = m_mesh->GetGeometryResource();
Tr2GeometryProviderPtr geometryRes = m_mesh->GetGeometryResource();

if( geometryRes )
{
Expand All @@ -181,7 +181,7 @@ void EveSwarmRenderable::PushDecals( std::vector<ITr2Renderable*>& renderables,

void EveSwarmRenderable::UpdateDecalVisibility( const EveUpdateContext& updateContext, IEveSpaceObject2::ParentData& pd, Tr2GrannyAnimation* animationUpdater )
{
TriGeometryResPtr geometryRes = m_mesh->GetGeometryResource();
Tr2GeometryProviderPtr geometryRes = m_mesh->GetGeometryResource();

if( geometryRes )
{
Expand Down Expand Up @@ -273,7 +273,7 @@ void EveSwarmRenderable::GetShadowBatches( ITriRenderBatchAccumulator* batches,
return;
}

TriGeometryRes* geomRes = m_mesh->GetGeometryResource();
Tr2GeometryProvider* geomRes = m_mesh->GetGeometryResource();
if( !geomRes || !geomRes->IsGood() )
{
return;
Expand Down
2 changes: 1 addition & 1 deletion trinity/Interior/Tr2IntSkinnedObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void Tr2IntSkinnedObject::GetBatches( ITriRenderBatchAccumulator* batches,
continue;
}

TriGeometryRes* geomRes = mesh->GetGeometryResource();
Tr2GeometryProvider* geomRes = mesh->GetGeometryResource();
if( !geomRes || !geomRes->IsGood() )
{
continue;
Expand Down
Loading
Loading