| 559 | // MOUNTING |
| 560 | |
| 561 | bool 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 | |
| 613 | void GuiShapeEdPreview::setMountNode(S32 mountSlot, const char* nodeName) |
| 614 | { |
no test coverage detected