Преглед изворни кода

simplify Action propertyBinding caches.

Ben Houston пре 10 година
родитељ
комит
94478be299
2 измењених фајлова са 5 додато и 36 уклоњено
  1. 1 1
      src/animation/AnimationAction.js
  2. 4 35
      src/animation/AnimationMixer.js

+ 1 - 1
src/animation/AnimationAction.js

@@ -21,7 +21,7 @@ THREE.AnimationAction = function ( clip, startTime, timeScale, weight, loop ) {
 	this.actionTime = - this.startTime;
 	this.clipTime = 0;
 
-	this.propertyBindingIndices = [];
+	this.propertyBindings = [];
 };
 
 /*

+ 4 - 35
src/animation/AnimationMixer.js

@@ -52,14 +52,15 @@ THREE.AnimationMixer.prototype = {
 			else {
 				propertyBinding = this.propertyBindings[ j ];
 			}
+
+			// push in the same order as the tracks.
+			action.propertyBindings.push( propertyBinding );
 			
 			// track usages of shared property bindings, because if we leave too many around, the mixer can get slow
 			propertyBinding.referenceCount += 1;
 
 		}
 
-		this.propertyBindingIndicesDirty = true;
-
 	},
 
 	getPropertyBindingIndex: function( rootNode, trackName ) {
@@ -69,33 +70,6 @@ THREE.AnimationMixer.prototype = {
 
 	},
 
-	updatePropertyBindingIndices: function() {
-
-		if( this.propertyBindingIndicesDirty ) {
-
-			for( var i = 0; i < this.actions.length; i++ ) {
-
-				var action = this.actions[i];
-
-				var root = action.localRoot || this.root;
-
-				var propertyBindingIndices = [];
-
-				for( var j = 0; j < action.clip.tracks.length; j ++ ) {
-
-					var trackName = action.clip.tracks[j].name;
-					propertyBindingIndices.push( this.getPropertyBindingIndex( root, trackName ) );
-				
-				}
-
-				action.propertyBindingIndices = propertyBindingIndices;
-			}
-
-			this.propertyBindingIndicesDirty = false;
-
-		}
-	},
-
 	removeAllActions: function() {
 
 		for( var i = 0; i < this.actions.length; i ++ ) {
@@ -152,9 +126,6 @@ THREE.AnimationMixer.prototype = {
 			}
 		}
 
-		
-		this.propertyBindingIndicesDirty = true;
-
 		return this;
 
 	},
@@ -241,8 +212,6 @@ THREE.AnimationMixer.prototype = {
 
 	update: function( deltaTime ) {
 
-		this.updatePropertyBindingIndices();
-
 		var mixerDeltaTime = deltaTime * this.timeScale;
 		this.time += mixerDeltaTime;
 
@@ -263,7 +232,7 @@ THREE.AnimationMixer.prototype = {
 
 				var name = action.clip.tracks[j].name;
 
-				this.propertyBindings[ action.propertyBindingIndices[ j ] ].accumulate( actionResults[j], weight );
+				action.propertyBindings[ j ].accumulate( actionResults[j], weight );
 
 			}