Преглед изворни кода

Another way of doing shapeBase, this requires fewer changes but will have an empty asset in each stateData until it is filled with an asset.

Both these will need to be tested to see which one is better.
marauder2k7 пре 3 година
родитељ
комит
656096e016
2 измењених фајлова са 8 додато и 11 уклоњено
  1. 1 3
      Engine/source/T3D/shapeBase.h
  2. 7 8
      Engine/source/T3D/shapeImage.cpp

+ 1 - 3
Engine/source/T3D/shapeBase.h

@@ -264,7 +264,7 @@ struct ShapeBaseImageData: public GameBaseData {
       //SFXTrack* sound;
       F32 emitterTime;              ///<
       S32 emitterNode[MaxShapes];   ///< Node ID on the shape to emit from
-      //DECLARE_SOUNDASSET(StateData, Sound);
+      SoundAsset* sound;
    };
    /// @name State Data
    /// Individual state data used to initialize struct array
@@ -1075,8 +1075,6 @@ protected:
    /// @param   imageSlot   Image slot id
    /// @param   state       State id
    /// @param   force       Force image to state or let it finish then change
-
-   U32 prevState = 0;
    void setImageState(U32 imageSlot, U32 state, bool force = false);
 
    void updateAnimThread(U32 imageSlot, S32 imageShapeIndex, ShapeBaseImageData::StateData* lastState=NULL);

+ 7 - 8
Engine/source/T3D/shapeImage.cpp

@@ -132,7 +132,7 @@ ShapeBaseImageData::StateData::StateData()
    loaded = IgnoreLoaded;
    spin = IgnoreSpin;
    recoil = NoRecoil;
-   //sound = 0;
+   sound = NULL;
    emitter = NULL;
    shapeSequence = NULL;
    shapeSequenceScale = true;
@@ -156,6 +156,7 @@ ShapeBaseImageData::StateData::StateData()
       flashSequence[i] = false;
       emitterNode[i] = -1;
    }
+
 }
 
 static ShapeBaseImageData::StateData gDefaultStateData;
@@ -369,7 +370,8 @@ bool ShapeBaseImageData::onAdd()
          s.shapeSequence = stateShapeSequence[i];
          s.shapeSequenceScale = stateScaleShapeSequence[i];
 
-         _setstateSound(getstateSound(i),i);
+         //_setstateSound(getstateSound(i),i);
+         s.sound = getstateSoundAsset(i);
          s.script = stateScript[i];
          s.emitter = stateEmitter[i];
          s.emitterTime = stateEmitterTime[i];
@@ -2761,7 +2763,7 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState,bool force)
    // Delete any loooping sounds that were in the previous state.
    // this is the crazy bit =/ needs to know prev state in order to stop sounds.
    // lastState does not return an id for the prev state so we keep track of it.
-   if (image.dataBlock->getstateSound(prevState) && image.dataBlock->getstateSoundProfile(prevState)->getDescription()->mIsLooping)
+   if (lastState->sound && lastState->sound->getSfxProfile()->getDescription()->mIsLooping)
    {  
       for(Vector<SFXSource*>::iterator i = image.mSoundSources.begin(); i != image.mSoundSources.end(); i++)      
          SFX_DELETE((*i));    
@@ -2770,15 +2772,12 @@ void ShapeBase::setImageState(U32 imageSlot, U32 newState,bool force)
    }  
 
    // Play sound
-   if( image.dataBlock->getstateSound(newState) && isGhost() )
+   if( stateData.sound && isGhost() )
    {
       const Point3F& velocity         = getVelocity();
-      image.addSoundSource(SFX->createSource(image.dataBlock->getstateSoundProfile(newState), &getRenderTransform(), &velocity ));
+      image.addSoundSource(SFX->createSource(stateData.sound->getSfxProfile(), &getRenderTransform(), &velocity ));
    }
 
-   /// update our prevState.
-   prevState = newState;
-
    // Play animation
    updateAnimThread(imageSlot, imageShapeIndex, lastState);
    for (U32 i=0; i<ShapeBaseImageData::MaxShapes; ++i)