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

Method addNode

Engine/modules/Verve/VPath/VPathEditor.cpp:1005–1079  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1003}
1004
1005void VPathEditor::addNode( const Gui3DMouseEvent &pEvent )
1006{
1007 VPath *path = mSelection.Path;
1008 if ( !path )
1009 {
1010 // Woops!
1011 return;
1012 }
1013
1014 // Min Index.
1015 S32 nodeIndex = -1;
1016 MatrixF nodeTransform( true );
1017 if ( !getPointOnPath( path, pEvent, nodeIndex, nodeTransform ) )
1018 {
1019 // Can't Add.
1020 return;
1021 }
1022
1023 // Invert Transform.
1024 MatrixF pathTransform = mSelection.Path->getTransform();
1025 pathTransform.setPosition( Point3F::Zero );
1026 pathTransform.inverse();
1027
1028 Point3F nodePosition = ( nodeTransform.getPosition() - mSelection.Path->getPosition() );
1029 pathTransform.mulP( nodePosition );
1030
1031 // Node Rotation.
1032 nodeTransform.mul( pathTransform );
1033 QuatF nodeRotation( nodeTransform );
1034
1035 // Node Weights.
1036 F32 nodeWeight = 10.f;
1037
1038 // Add New Node.
1039 VPathNode *node = path->addNode( nodePosition, nodeRotation, nodeWeight, ++nodeIndex );
1040
1041 // Valid Node?
1042 if ( !node )
1043 {
1044 return;
1045 }
1046
1047 // Update Size.
1048 path->updateContainer();
1049
1050 // Calculate Path.
1051 path->calculatePath();
1052
1053 UndoManager *historyManager = NULL;
1054 if ( !Sim::findObject( "EUndoManager", historyManager ) )
1055 {
1056 Con::errorf( "VPathEditor::addNode() - EUndoManager not found!" );
1057 return;
1058 }
1059
1060 // Create Undo Action.
1061 VPathEditorAddNodeAction *editAction = new VPathEditorAddNodeAction();
1062

Callers 2

redoMethod · 0.45
undoMethod · 0.45

Calls 11

mulPMethod · 0.80
findObjectFunction · 0.50
errorfFunction · 0.50
getTransformMethod · 0.45
setPositionMethod · 0.45
inverseMethod · 0.45
getPositionMethod · 0.45
mulMethod · 0.45
updateContainerMethod · 0.45
calculatePathMethod · 0.45
addActionMethod · 0.45

Tested by

no test coverage detected