コード例 #1
0
void RenderPassData::reset()
{
    for( U32 i = 0; i < Material::MAX_TEX_PER_PASS; ++ i )
        destructInPlace( &mTexSlot[ i ] );

    dMemset( &mTexSlot, 0, sizeof(mTexSlot) );
    dMemset( &mTexType, 0, sizeof(mTexType) );

    mCubeMap = NULL;
    mNumTex = mNumTexReg = mStageNum = 0;
    mGlow = false;
    mBlendOp = Material::None;

    mFeatureData.clear();

    for (U32 i = 0; i < STATE_MAX; i++)
        mRenderStates[i] = NULL;
}
コード例 #2
0
void SFX3DWorld::setListener( SceneObject* object )
{
   SFX3DObject* oldListener = mSFXWorld.getReferenceObject();

   // If it's the same object as our current listener,
   // return.

   if( oldListener && oldListener->getObject() == object )
      return;

   // Create a SFX3DObject for the given SceneObject.

   SFX3DObject* sfxObject = NULL;
   if( object )
   {
      AssertFatal( !dynamic_cast< SFX3DObject* >( SFX3DObject::getLinkForTracker( this, object ) ),
         "SFX3DWorld::setListener - listener objects must not be registered for tracking" );

      sfxObject = mChunker.alloc();
      constructInPlace( sfxObject, this, object );
      sfxObject->setFlags( SFXObjectListener );
   }

#ifdef DEBUG_SPEW
   if( object )
      Platform::outputDebugString( "[SFX3DWorld] Listener is now %i:%s (%s)",
      object->getId(), object->getClassName(), object->getName() );
   else
      Platform::outputDebugString( "[SFX3DWorld] Unsetting listener" );
#endif

   // Make this object the center of our SFX world.

   mSFXWorld.setReferenceObject( sfxObject );

   // Remove the tracking links from the old listener so we
   // don't see further updates on it.

   if( oldListener )
   {
      destructInPlace( oldListener );
      mChunker.free( oldListener );
   }
}
コード例 #3
0
void SFX3DWorld::unregisterObject( SceneObject* object )
{
   SFX3DObject* sfxObject = dynamic_cast< SFX3DObject* >( SFX3DObject::getLinkForTracker( this, object ) );
   if( !sfxObject )
      return;
      
   #ifdef DEBUG_SPEW
   Platform::outputDebugString( "[SFX3DWorld] Unregistering %i:%s (was 0x%x)",
      object->getId(), object->getClassName(), sfxObject );
   #endif

   // Remove the object from the SFX world.
      
   if( sfxObject->isListener() )
      mSFXWorld.setReferenceObject( NULL );
   else
      mSFXWorld.unregisterObject( sfxObject );
   
   // Destroy the scene object link.
   
   destructInPlace( sfxObject );
   mChunker.free( sfxObject );
}
コード例 #4
0
// Install into the TSShape, the shape is expected to be empty.
// Data is not copied, the TSShape is modified to point to memory
// managed by this object.  This object is also bound to the TSShape
// object and will be deleted when it's deleted.
void TSShapeLoader::install()
{
   // Arrays that are filled in by ts shape init, but need
   // to be allocated beforehand.
   shape->subShapeFirstTranslucentObject.setSize(shape->subShapeFirstObject.size());

   // Construct TS sub-meshes
   shape->meshes.setSize(appMeshes.size());
   for (U32 m = 0; m < appMeshes.size(); m++)
      shape->meshes[m] = appMeshes[m] ? appMeshes[m]->constructTSMesh() : NULL;

   // Remove empty meshes and objects
   for (S32 iObj = shape->objects.size()-1; iObj >= 0; iObj--)
   {
      TSShape::Object& obj = shape->objects[iObj];
      for (S32 iMesh = obj.numMeshes-1; iMesh >= 0; iMesh--)
      {
         TSMesh *mesh = shape->meshes[obj.startMeshIndex + iMesh];

         if (mesh && !mesh->primitives.size())
         {
            S32 oldMeshCount = obj.numMeshes;
            destructInPlace(mesh);
            shape->removeMeshFromObject(iObj, iMesh);
            iMesh -= (oldMeshCount - obj.numMeshes - 1);      // handle when more than one mesh is removed
         }
      }

      if (!obj.numMeshes)
         shape->removeObject(shape->getName(obj.nameIndex));
   }

   // Add a dummy object if needed so the shape loads and renders ok
   if (!shape->details.size())
   {
      shape->addDetail("detail", 2, 0);
      shape->subShapeNumObjects.last() = 1;

      shape->meshes.push_back(NULL);

      shape->objects.increment();
      shape->objects.last().nameIndex = shape->addName("dummy");
      shape->objects.last().nodeIndex = 0;
      shape->objects.last().startMeshIndex = 0;
      shape->objects.last().numMeshes = 1;

      shape->objectStates.increment();
      shape->objectStates.last().frameIndex = 0;
      shape->objectStates.last().matFrameIndex = 0;
      shape->objectStates.last().vis = 1.0f;
   }

   // Update smallest visible detail
   shape->mSmallestVisibleDL = -1;
   shape->mSmallestVisibleSize = 999999;
   for (S32 i = 0; i < shape->details.size(); i++)
   {
      if ((shape->details[i].size >= 0) &&
         (shape->details[i].size < shape->mSmallestVisibleSize))
      {
         shape->mSmallestVisibleDL = i;
         shape->mSmallestVisibleSize = shape->details[i].size;
      }
   }

   computeBounds(shape->bounds);
   if (!shape->bounds.isValidBox())
      shape->bounds = Box3F(1.0f);

   shape->bounds.getCenter(&shape->center);
   shape->radius = (shape->bounds.maxExtents - shape->center).len();
   shape->tubeRadius = shape->radius;

   shape->init();
}
コード例 #5
0
ThreadStorage::~ThreadStorage()
{
   TlsFree(mThreadStorage->mTlsIndex);
   destructInPlace(mThreadStorage);
}