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

Method mountShape

Engine/source/gui/editor/guiShapeEdPreview.cpp:561–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559// MOUNTING
560
561bool GuiShapeEdPreview::mountShape(const char* shapeAssetId, const char* nodeName, const char* mountType, S32 slot)
562{
563 if ( !shapeAssetId || !shapeAssetId[0] )
564 return false;
565
566 if (!AssetDatabase.isDeclaredAsset(shapeAssetId))
567 return false;
568
569 ShapeAsset* model = AssetDatabase.acquireAsset<ShapeAsset>(shapeAssetId);
570
571 if (model == nullptr || !model->getShapeResource())
572 return false;
573
574 TSShapeInstance* tsi = new TSShapeInstance(model->getShapeResource(), true );
575
576 if ( slot == -1 )
577 {
578 slot = mMounts.size();
579 mMounts.push_back( new MountedShape );
580 }
581 else
582 {
583 // Check if we are switching shapes
584 if ( mMounts[slot]->mShape->getShape() != tsi->getShape() )
585 {
586 delete mMounts[slot]->mShape;
587 mMounts[slot]->mShape = NULL;
588 mMounts[slot]->mThread.init();
589 }
590 else
591 {
592 // Keep using the existing shape
593 delete tsi;
594 tsi = mMounts[slot]->mShape;
595 }
596 }
597
598 MountedShape* mount = mMounts[slot];
599 mount->mShape = tsi;
600
601 if ( dStrEqual( mountType, "Wheel" ) )
602 mount->mType = MountedShape::Wheel;
603 else if ( dStrEqual( mountType, "Image" ) )
604 mount->mType = MountedShape::Image;
605 else
606 mount->mType = MountedShape::Object;
607
608 setMountNode( slot, nodeName);
609
610 return true;
611}
612
613void GuiShapeEdPreview::setMountNode(S32 mountSlot, const char* nodeName)
614{

Callers 1

Calls 7

dStrEqualFunction · 0.85
isDeclaredAssetMethod · 0.80
getShapeResourceMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
getShapeMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected