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

Method removeNode

Engine/source/ts/tsShapeEdit.cpp:531–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531bool TSShape::removeNode(const String& name)
532{
533 // Find the node to be removed
534 S32 nodeIndex = findNode(name);
535 if (nodeIndex < 0)
536 {
537 Con::errorf("TSShape::removeNode: Could not find node '%s'", name.c_str());
538 return false;
539 }
540
541 S32 nodeParentIndex = nodes[nodeIndex].parentIndex;
542
543 // Warn if there are objects attached to this node
544 Vector<S32> nodeObjects;
545 getNodeObjects(nodeIndex, nodeObjects);
546 if (nodeObjects.size())
547 {
548 Con::warnf("TSShape::removeNode: Node '%s' has %d objects attached, these "
549 "will be reassigned to the node's parent ('%s')", name.c_str(), nodeObjects.size(),
550 ((nodeParentIndex >= 0) ? getName(nodes[nodeParentIndex].nameIndex).c_str() : "null"));
551 }
552
553 // Need to make everything editable since node indexes etc will change
554 makeEditable();
555
556 // Update animation sequences
557 for (S32 iSeq = 0; iSeq < sequences.size(); iSeq++)
558 {
559 TSShape::Sequence& seq = sequences[iSeq];
560
561 // Remove animated node transforms
562 if (seq.translationMatters.test(nodeIndex))
563 eraseStates(nodeTranslations, seq.translationMatters, seq.baseTranslation, seq.numKeyframes, nodeIndex);
564 if (seq.rotationMatters.test(nodeIndex))
565 eraseStates(nodeRotations, seq.rotationMatters, seq.baseRotation, seq.numKeyframes, nodeIndex);
566 if (seq.scaleMatters.test(nodeIndex))
567 {
568 if (seq.flags & TSShape::ArbitraryScale)
569 {
570 eraseStates(nodeArbitraryScaleRots, seq.scaleMatters, seq.baseScale, seq.numKeyframes, nodeIndex);
571 eraseStates(nodeArbitraryScaleFactors, seq.scaleMatters, seq.baseScale, seq.numKeyframes, nodeIndex);
572 }
573 else if (seq.flags & TSShape::AlignedScale)
574 eraseStates(nodeAlignedScales, seq.scaleMatters, seq.baseScale, seq.numKeyframes, nodeIndex);
575 else
576 eraseStates(nodeUniformScales, seq.scaleMatters, seq.baseScale, seq.numKeyframes, nodeIndex);
577 }
578
579 seq.translationMatters.erase(nodeIndex);
580 seq.rotationMatters.erase(nodeIndex);
581 seq.scaleMatters.erase(nodeIndex);
582 }
583
584 // Remove the node
585 nodes.erase(nodeIndex);
586 defaultTranslations.erase(nodeIndex);
587 defaultRotations.erase(nodeIndex);
588

Callers 1

Calls 9

eraseStatesFunction · 0.85
getMeshTypeMethod · 0.80
errorfFunction · 0.50
warnfFunction · 0.50
getNameFunction · 0.50
c_strMethod · 0.45
sizeMethod · 0.45
testMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected