@@ -3251,9 +3251,9 @@ Duik.Pin.getByName = function (comp,name,selectedOnly)
3251
3251
/**
3252
3252
* Links the path to pins<br />
3253
3253
* Works with After Effects CC2018 (15.0) and newer only
3254
- * @param {Property|DuAEProperty} prop - The path property
3255
- * @param {bool } [tangents=true] - True to create bones for the tangents
3256
- * @param {bool } [createPinLayers=true] - True to create layers, false to only create a controller effect
3254
+ * @param {Property|DuAEProperty} pathProp - The path property
3255
+ * @param {Boolean } [tangents=true] - True to create bones for the tangents
3256
+ * @param {Boolean } [createPinLayers=true] - True to create layers, false to only create a controller effect
3257
3257
* @return {DuAEProperty[]} The pin effects created.
3258
3258
*/
3259
3259
Duik.Pin.rigPath = function( pathProp, tangents, createPinLayers )
@@ -3790,7 +3790,7 @@ Duik.CmdLib['Bone']["Arm"] = "Duik.Bone.arm()";
3790
3790
* @param {Boolean} [forearm=true] Whether to create a forearm
3791
3791
* @param {Boolean} [hand=true] Whether to create a hand
3792
3792
* @param {Boolean} [claws=false] Whether to add claws
3793
- * @param {Boolean } [location=OCO.Location.FRONT] The location of the arm
3793
+ * @param {OCO.Location } [location=OCO.Location.FRONT] The location of the arm
3794
3794
* @param {boolean} [forceLink=false] - whether link the selected layers/properties to the new armature
3795
3795
*/
3796
3796
Duik.Bone.arm = function ( characterName, type, side, shoulder, arm, forearm, hand, claws, location, forceLink )
@@ -3831,7 +3831,7 @@ Duik.Bone.arm = function ( characterName, type, side, shoulder, arm, forearm, ha
3831
3831
// Creates a limb on the selection, optionally linking the items
3832
3832
Duik.Bone.createLimb = function ( comp, limbCreator, characterName, forceLink )
3833
3833
{
3834
- var comp = DuAEProject.getActiveComp();
3834
+ comp = def(comp, DuAEProject.getActiveComp() );
3835
3835
if (!comp) return [];
3836
3836
3837
3837
// Links
@@ -3867,10 +3867,8 @@ Duik.Bone.createLimb = function ( comp, limbCreator, characterName, forceLink )
3867
3867
var ok = false;
3868
3868
it.do( function( layer )
3869
3869
{
3870
- var side = Duik.Layer.side(layer);
3871
- var location = Duik.Layer.location(layer);
3872
- if (characterName == "") characterName = Duik.Layer.groupName(layer);
3873
- var limbName = Duik.Layer.name(layer);
3870
+ if (characterName == "")
3871
+ characterName = Duik.Layer.groupName(layer);
3874
3872
3875
3873
//get paths
3876
3874
var props = DuAELayer.getSelectedProps( layer, DuAEProperty.isPathProperty );
@@ -3881,6 +3879,17 @@ Duik.Bone.createLimb = function ( comp, limbCreator, characterName, forceLink )
3881
3879
for (var i = 0, n = props.length; i < n; i++)
3882
3880
{
3883
3881
var path = props[i];
3882
+
3883
+ var pathProp = new DuAEProperty( path ).pathProperty();
3884
+ pathProp = pathProp.getProperty();
3885
+ // don't rig twice the same (we may get either the prop or the group)
3886
+ if (DuString.startsWith(
3887
+ pathProp.expression,
3888
+ '// Duik auto-rig')) {
3889
+ pathProp.expression = pathProp.expression.replace('// Duik auto-rig\n', '');
3890
+ continue;
3891
+ }
3892
+
3884
3893
// create the OCODoc
3885
3894
var doc = OCODoc.fromComp( characterName, comp, [] );
3886
3895
var limb = limbCreator( doc );
@@ -3889,7 +3898,12 @@ Duik.Bone.createLimb = function ( comp, limbCreator, characterName, forceLink )
3889
3898
var boneLayers = doc.toComp( comp );
3890
3899
DuAELayer.moveInsideComp( boneLayers[0] );
3891
3900
// link
3892
- if (linkPath) Duik.Pin.linkPathToLayers( path, boneLayers );
3901
+ if (linkPath)
3902
+ Duik.Pin.linkPathToLayers( path, boneLayers );
3903
+
3904
+ // don't rig twice the same (we may get either the prop or the group)
3905
+ pathProp.expression = '// Duik auto-rig\n' + pathProp.expression;
3906
+
3893
3907
ok = true;
3894
3908
}
3895
3909
if (layerToRemove) layerToRemove.remove();
@@ -7088,6 +7102,12 @@ Duik.Controller.create = function ( comp, type, layer, parent ) {
7088
7102
DuAELayer.applyPreset( ctrl, preset );
7089
7103
Duik.Controller.setColor( DuColor.Color.APP_HIGHLIGHT_COLOR, ctrl );
7090
7104
7105
+ // Reset the side (to flip the controller if needed)
7106
+ if ( layer != null) {
7107
+ var side = Duik.Layer.side(layer);
7108
+ Duik.Controller.setSide( side , ctrl);
7109
+ }
7110
+
7091
7111
return ctrl;
7092
7112
}
7093
7113
@@ -7836,11 +7856,25 @@ Duik.Controller.setLimbName = function ( limbName, layers ) {
7836
7856
/**
7837
7857
* Sets the side of the layer
7838
7858
* @param {OCO.Side} side The side
7839
- * @param {Layer[]} [layers=DuAEComp.getSelectedLayers ()] The layer . If omitted, will use all selected layers in the comp
7859
+ * @param {Layer[]|Layer|DuList.<Layer>|LayerCollection } [layers=Duik.Controller.get ()] The controller . If omitted, will use all selected controllers in the comp
7840
7860
*/
7841
7861
Duik.Controller.setSide = function ( side, layers ) {
7842
7862
layers = def( layers, Duik.Controller.get() );
7863
+ layers = new DuList(layers);
7864
+
7843
7865
Duik.Layer.setSide( side, layers );
7866
+ // Flip the Left controllers
7867
+ for (var i = 0, n = layers.length(); i < n; i++) {
7868
+ var layer = layers.at(i);
7869
+ if (layer instanceof ShapeLayer) {
7870
+ var effect = layer.effect('Pseudo/DUIK Ctrl v03');
7871
+ if (effect) {
7872
+ effect.property('Flip').setValue(
7873
+ side == OCO.Side.LEFT ? 1 : 0
7874
+ );
7875
+ }
7876
+ }
7877
+ }
7844
7878
}
7845
7879
7846
7880
/**
@@ -10640,10 +10674,12 @@ Duik.Constraint.twoOneLayerIK = function(layer1, layer2, layer3, goal, controlle
10640
10674
Duik.Constraint.bezierIK = function(layers, goal, controller, showGuides) {
10641
10675
goal = def(goal, null);
10642
10676
controller = def(controller, null);
10643
- if (controller == null && goal == null) throw "You must provide either a goal layer or a controller";
10677
+ if (controller == null && goal == null)
10678
+ throw "You must provide either a goal layer or a controller";
10644
10679
10645
10680
showGuides = def(showGuides, true);
10646
- if (!showGuides) showGuides = false;
10681
+ if (!showGuides)
10682
+ showGuides = false;
10647
10683
10648
10684
DuAE.beginUndoGroup( i18n._("B\u00e9zier IK"), false);
10649
10685
@@ -12827,8 +12863,6 @@ Duik.Rig.auto = function ( bakeBones, bakeEnvelops, bakeNoodles, longChainMode,
12827
12863
}
12828
12864
}
12829
12865
12830
- // TODO Get/Create a master, parent orphan controllers to it
12831
- // Collect controllers
12832
12866
var ctrls = [];
12833
12867
var limbs = ocoDoc.getLimbs();
12834
12868
for (var i = 0, ni = limbs.length; i < ni; i++ )
@@ -12865,12 +12899,12 @@ Duik.Rig.auto = function ( bakeBones, bakeEnvelops, bakeNoodles, longChainMode,
12865
12899
}
12866
12900
12867
12901
// If controllers are nulls, move them to the top of the comp
12868
- if ( OCO.config.get('after effects/controller layer type', Duik.Controller.LayerMode.SHAPE) == Duik.Controller.LayerMode.NULL) {
12902
+ var ctrlType = OCO.config.get('after effects/controller layer type', Duik.Controller.LayerMode.SHAPE);
12903
+ if ( ctrlType == Duik.Controller.LayerMode.NULL ) {
12869
12904
for (var i = 0; i < ctrls.length; i++) {
12870
12905
ctrls[i].moveBefore( comp.layer(1)
12871
12906
); };
12872
12907
};
12873
-
12874
12908
12875
12909
DuAEProject.setProgressMode( false );
12876
12910
DuAE.endUndoGroup( i18n._("Auto-rig") );
@@ -19236,6 +19270,8 @@ Duik.Animation.cut = function ( comp )
19236
19270
comp = def(comp, DuAEProject.getActiveComp() );
19237
19271
if(!comp) return;
19238
19272
19273
+ DuAE.beginUndoGroup( i18n._("Cut animation"), false);
19274
+
19239
19275
var props = new DuList( DuAEComp.getSelectedProps() );
19240
19276
// When modifying properties, keys are deselected. Let's keep the list.
19241
19277
var selectedKeys = [];
@@ -19252,6 +19288,8 @@ Duik.Animation.cut = function ( comp )
19252
19288
prop.removeKey(keys[i]);
19253
19289
}
19254
19290
});
19291
+
19292
+ DuAE.endUndoGroup( i18n._("Cut animation"));
19255
19293
return animations;
19256
19294
}
19257
19295
0 commit comments