Skip to content

Commit

Permalink
AnimationGraph: renaming variable should consider PVNodeGetVariable (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
shrinktofit authored Jun 16, 2023
1 parent 6f41270 commit c37e088
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions editor/src/marionette/variable-binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import {
MotionState,
SubStateMachine,
VariableType,
ProceduralPoseState,
} from '../../../cocos/animation/marionette/asset-creation';
import { PoseNodeStateMachine } from '../../../cocos/animation/marionette/pose-graph/pose-nodes/state-machine';
import { TCBindingValueType } from '../../../cocos/animation/marionette/state-machine/condition/binding/binding';
import { TCVariableBinding } from '../../../cocos/animation/marionette/state-machine/condition/binding/variable-binding';
import { PVNodeGetVariableBase } from '../../../cocos/animation/marionette/pose-graph/pure-value-nodes/get-variable';
import { PoseGraphType } from '../../../cocos/animation/marionette/pose-graph/foundation/type-system';
import { assertIsTrue } from '../../../exports/base';

export interface VariableBindingView {
/**
Expand Down Expand Up @@ -111,7 +116,32 @@ export function* viewVariableBindings(animationGraph: AnimationGraph): Generator
}
} else if (state instanceof SubStateMachine) {
yield* visitStateMachine(state.stateMachine);
} else if (state instanceof ProceduralPoseState) {
for (const node of state.graph.nodes()) {
if (node instanceof PoseNodeStateMachine) {
yield* visitStateMachine(node.stateMachine);
} else if (node instanceof PVNodeGetVariableBase) {
const outputType = node.getOutputType(0);
assertIsTrue(outputType !== PoseGraphType.POSE);
yield createVariableBindingView(
node,
'variableName',
poseGraphTypeToAcceptableVariableType(outputType),
);
}
}
}
}
}
}

function poseGraphTypeToAcceptableVariableType(poseGraphType: Exclude<PoseGraphType, PoseGraphType.POSE>) {
switch (poseGraphType) {
default: throw new Error(`Unhandled pose graph type ${PoseGraphType[poseGraphType]}`);
case PoseGraphType.FLOAT: return VariableType.FLOAT;
case PoseGraphType.INTEGER: return VariableType.INTEGER;
case PoseGraphType.BOOLEAN: return VariableType.BOOLEAN;
case PoseGraphType.VEC3: return VariableType.VEC3_experimental;
case PoseGraphType.QUAT: return VariableType.QUAT_experimental;
}
}

0 comments on commit c37e088

Please sign in to comment.