mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge of PR #855
This commit is contained in:
commit
98b3d3294d
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@
|
|||
#include "ts/tsShape.h"
|
||||
#endif
|
||||
|
||||
#ifndef _REFLECTOR_H_
|
||||
#include "scene/reflector.h"
|
||||
#endif
|
||||
|
||||
class TSShapeInstance;
|
||||
class TSThread;
|
||||
class TSStatic;
|
||||
|
|
@ -147,6 +151,11 @@ protected:
|
|||
/// Start or stop processing ticks depending on our state.
|
||||
void _updateShouldTick();
|
||||
|
||||
String cubeDescName;
|
||||
U32 cubeDescId;
|
||||
ReflectorDesc *reflectorDesc;
|
||||
CubeReflector mCubeReflector;
|
||||
|
||||
protected:
|
||||
|
||||
Convex *mConvexList;
|
||||
|
|
|
|||
|
|
@ -84,3 +84,15 @@ datablock LightningData(DefaultStorm)
|
|||
thunderSounds[2] = ThunderCrash3Sound;
|
||||
thunderSounds[3] = ThunderCrash4Sound;
|
||||
};
|
||||
|
||||
datablock ReflectorDesc( DefaultCubeDesc )
|
||||
{
|
||||
texSize = 256;
|
||||
nearDist = 0.1;
|
||||
farDist = 1000.0;
|
||||
objectTypeMask = 0xFFFFFFFF;
|
||||
detailAdjust = 1.0;
|
||||
priority = 1.0;
|
||||
maxRateMs = 15;
|
||||
useOcclusionQuery = true;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue