MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / onNewDataBlock

Method onNewDataBlock

Engine/source/T3D/shapeBase.cpp:1156–1329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1154}
1155
1156bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
1157{
1158 // need to destroy blend-clips or we crash
1159 if (isGhost())
1160 {
1161 for (S32 i = 0; i < blend_clips.size(); i++)
1162 {
1163 if (blend_clips[i].thread)
1164 mShapeInstance->destroyThread(blend_clips[i].thread);
1165 blend_clips.erase_fast(i);
1166 }
1167 }
1168 ShapeBaseData *prevDB = dynamic_cast<ShapeBaseData*>( mDataBlock );
1169
1170 bool isInitialDataBlock = (prevDB == 0);
1171
1172 if ( Parent::onNewDataBlock( dptr, reload ) == false )
1173 return false;
1174
1175 mDataBlock = dynamic_cast<ShapeBaseData*>(dptr);
1176 if (!mDataBlock)
1177 return false;
1178
1179 setMaskBits(DamageMask);
1180 mDamageThread = 0;
1181 mHulkThread = 0;
1182
1183 // Even if loadShape succeeds, there may not actually be
1184 // a shape assigned to this object.
1185 if (bool(mDataBlock->mShape)) {
1186 delete mShapeInstance;
1187 if (isClientObject() && mDataBlock->txr_tag_remappings.size() > 0)
1188 {
1189 // temporarily substitute material tags with alternates
1190 TSMaterialList* mat_list = mDataBlock->mShape->materialList;
1191 if (mat_list)
1192 {
1193 for (S32 i = 0; i < mDataBlock->txr_tag_remappings.size(); i++)
1194 {
1195 ShapeBaseData::TextureTagRemapping* remap = &mDataBlock->txr_tag_remappings[i];
1196 Vector<String>& mat_names = (Vector<String>&) mat_list->getMaterialNameList();
1197 S32 old_tagLen = dStrlen(remap->old_tag);
1198 for (S32 j = 0; j < mat_names.size(); j++)
1199 {
1200 if (mat_names[j].compare(remap->old_tag, old_tagLen, String::NoCase) == 0)
1201 {
1202 mat_names[j] = String(remap->new_tag);
1203 mat_names[j].insert(0, '#');
1204 break;
1205 }
1206 }
1207 }
1208 }
1209 }
1210 mShapeInstance = new TSShapeInstance(mDataBlock->mShape, isClientObject());
1211 if (isClientObject())
1212 {
1213 mShapeInstance->cloneMaterialList();

Callers 1

blowUpMethod · 0.45

Calls 15

erase_fastMethod · 0.80
cloneMaterialListMethod · 0.80
substrMethod · 0.80
dStrlenFunction · 0.50
StringClass · 0.50
sizeMethod · 0.45
destroyThreadMethod · 0.45
compareMethod · 0.45
insertMethod · 0.45
lengthMethod · 0.45
setSizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected