| 1078 | } |
| 1079 | |
| 1080 | bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload ) |
| 1081 | { |
| 1082 | ShapeBaseData *prevDB = dynamic_cast<ShapeBaseData*>( mDataBlock ); |
| 1083 | |
| 1084 | bool isInitialDataBlock = ( mDataBlock == 0 ); |
| 1085 | |
| 1086 | if ( Parent::onNewDataBlock( dptr, reload ) == false ) |
| 1087 | return false; |
| 1088 | |
| 1089 | mDataBlock = dynamic_cast<ShapeBaseData*>(dptr); |
| 1090 | if (!mDataBlock) |
| 1091 | return false; |
| 1092 | |
| 1093 | setMaskBits(DamageMask); |
| 1094 | mDamageThread = 0; |
| 1095 | mHulkThread = 0; |
| 1096 | |
| 1097 | // Even if loadShape succeeds, there may not actually be |
| 1098 | // a shape assigned to this object. |
| 1099 | if (bool(mDataBlock->mShape)) { |
| 1100 | delete mShapeInstance; |
| 1101 | mShapeInstance = new TSShapeInstance(mDataBlock->mShape, isClientObject()); |
| 1102 | if (isClientObject()) |
| 1103 | mShapeInstance->cloneMaterialList(); |
| 1104 | |
| 1105 | mObjBox = mDataBlock->mShape->bounds; |
| 1106 | resetWorldBox(); |
| 1107 | |
| 1108 | // Set the initial mesh hidden state. |
| 1109 | mMeshHidden.setSize( mDataBlock->mShape->objects.size() ); |
| 1110 | mMeshHidden.clear(); |
| 1111 | |
| 1112 | // Initialize the threads |
| 1113 | for (U32 i = 0; i < MaxScriptThreads; i++) { |
| 1114 | Thread& st = mScriptThread[i]; |
| 1115 | if (st.sequence != -1) { |
| 1116 | // TG: Need to see about suppressing non-cyclic sounds |
| 1117 | // if the sequences were activated before the object was |
| 1118 | // ghosted. |
| 1119 | // TG: Cyclic animations need to have a random pos if |
| 1120 | // they were started before the object was ghosted. |
| 1121 | |
| 1122 | // If there was something running on the old shape, the thread |
| 1123 | // needs to be reset. Otherwise we assume that it's been |
| 1124 | // initialized either by the constructor or from the server. |
| 1125 | bool reset = st.thread != 0; |
| 1126 | st.thread = 0; |
| 1127 | |
| 1128 | // New datablock/shape may not actually HAVE this sequence. |
| 1129 | // In that case stop playing it. |
| 1130 | |
| 1131 | AssertFatal( prevDB != NULL, "ShapeBase::onNewDataBlock - how did you have a sequence playing without a prior datablock?" ); |
| 1132 | |
| 1133 | const TSShape *prevShape = prevDB->mShape; |
| 1134 | const TSShape::Sequence &prevSeq = prevShape->sequences[st.sequence]; |
| 1135 | const String &prevSeqName = prevShape->names[prevSeq.nameIndex]; |
| 1136 | |
| 1137 | st.sequence = mDataBlock->mShape->findSequence( prevSeqName ); |
no test coverage detected