mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Merge of PR #855
This commit is contained in:
commit
98b3d3294d
3 changed files with 81 additions and 0 deletions
|
|
@ -91,6 +91,9 @@ ConsoleDocClass( TSStatic,
|
|||
);
|
||||
|
||||
TSStatic::TSStatic()
|
||||
:
|
||||
cubeDescId( 0 ),
|
||||
reflectorDesc( NULL )
|
||||
{
|
||||
mNetFlags.set(Ghostable | ScopeAlways);
|
||||
|
||||
|
|
@ -186,6 +189,11 @@ void TSStatic::initPersistFields()
|
|||
|
||||
endGroup("Rendering");
|
||||
|
||||
addGroup( "Reflection" );
|
||||
addField( "cubeReflectorDesc", TypeRealString, Offset( cubeDescName, TSStatic ),
|
||||
"References a ReflectorDesc datablock that defines performance and quality properties for dynamic reflections.\n");
|
||||
endGroup( "Reflection" );
|
||||
|
||||
addGroup("Collision");
|
||||
|
||||
addField( "collisionType", TypeTSMeshType, Offset( mCollisionType, TSStatic ),
|
||||
|
|
@ -292,6 +300,14 @@ bool TSStatic::onAdd()
|
|||
|
||||
addToScene();
|
||||
|
||||
if ( isClientObject() )
|
||||
{
|
||||
mCubeReflector.unregisterReflector();
|
||||
|
||||
if ( reflectorDesc )
|
||||
mCubeReflector.registerReflector( this, reflectorDesc );
|
||||
}
|
||||
|
||||
_updateShouldTick();
|
||||
|
||||
// Accumulation
|
||||
|
|
@ -357,6 +373,16 @@ bool TSStatic::_createShape()
|
|||
if ( mAmbientThread )
|
||||
mShapeInstance->setSequence( mAmbientThread, ambientSeq, 0);
|
||||
|
||||
// Resolve CubeReflectorDesc.
|
||||
if ( cubeDescName.isNotEmpty() )
|
||||
{
|
||||
Sim::findObject( cubeDescName, reflectorDesc );
|
||||
}
|
||||
else if( cubeDescId > 0 )
|
||||
{
|
||||
Sim::findObject( cubeDescId, reflectorDesc );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -429,6 +455,8 @@ void TSStatic::onRemove()
|
|||
mShapeInstance = NULL;
|
||||
|
||||
mAmbientThread = NULL;
|
||||
if ( isClientObject() )
|
||||
mCubeReflector.unregisterReflector();
|
||||
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
|
@ -561,6 +589,12 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
|||
|
||||
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
|
||||
|
||||
// If we're currently rendering our own reflection we
|
||||
// don't want to render ourselves into it.
|
||||
if ( mCubeReflector.isRendering() )
|
||||
return;
|
||||
|
||||
|
||||
if ( mForceDetail == -1 )
|
||||
mShapeInstance->setDetailFromDistance( state, dist * invScale );
|
||||
else
|
||||
|
|
@ -577,6 +611,9 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
|||
rdata.setFadeOverride( 1.0f );
|
||||
rdata.setOriginSort( mUseOriginSort );
|
||||
|
||||
if ( mCubeReflector.isEnabled() )
|
||||
rdata.setCubemap( mCubeReflector.getCubemap() );
|
||||
|
||||
// Acculumation
|
||||
rdata.setAccuTex(mAccuTex);
|
||||
|
||||
|
|
@ -604,6 +641,20 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
|||
mat.scale( mObjScale );
|
||||
GFX->setWorldMatrix( mat );
|
||||
|
||||
if ( state->isDiffusePass() && mCubeReflector.isEnabled() && mCubeReflector.getOcclusionQuery() )
|
||||
{
|
||||
RenderPassManager *pass = state->getRenderPass();
|
||||
OccluderRenderInst *ri = pass->allocInst<OccluderRenderInst>();
|
||||
|
||||
ri->type = RenderPassManager::RIT_Occluder;
|
||||
ri->query = mCubeReflector.getOcclusionQuery();
|
||||
mObjToWorld.mulP( mObjBox.getCenter(), &ri->position );
|
||||
ri->scale.set( mObjBox.getExtents() );
|
||||
ri->orientation = pass->allocUniqueXform( mObjToWorld );
|
||||
ri->isSphere = false;
|
||||
state->getRenderPass()->addInst( ri );
|
||||
}
|
||||
|
||||
mShapeInstance->animate();
|
||||
if(mShapeInstance)
|
||||
{
|
||||
|
|
@ -715,6 +766,10 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
|||
if ( mLightPlugin )
|
||||
retMask |= mLightPlugin->packUpdate(this, AdvancedStaticOptionsMask, con, mask, stream);
|
||||
|
||||
if( stream->writeFlag( reflectorDesc != NULL ) )
|
||||
{
|
||||
stream->writeRangedU32( reflectorDesc->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast );
|
||||
}
|
||||
return retMask;
|
||||
}
|
||||
|
||||
|
|
@ -782,6 +837,11 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
mLightPlugin->unpackUpdate(this, con, stream);
|
||||
}
|
||||
|
||||
if( stream->readFlag() )
|
||||
{
|
||||
cubeDescId = stream->readRangedU32( DataBlockObjectIdFirst, DataBlockObjectIdLast );
|
||||
}
|
||||
|
||||
if ( isProperlyAdded() )
|
||||
_updateShouldTick();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue