Pārlūkot izejas kodu

Better active bones counting

David Catuhe 10 gadi atpakaļ
vecāks
revīzija
72f3e73493

+ 1 - 0
Babylon/Bones/babylon.skeleton.js

@@ -39,6 +39,7 @@ var BABYLON;
             }
             this._identity.copyToArray(this._transformMatrices, this.bones.length * 16);
             this._isDirty = false;
+            this._scene._activeBones += this.bones.length;
         };
         Skeleton.prototype.getAnimatables = function () {
             if (!this._animatables || this._animatables.length !== this.bones.length) {

+ 2 - 2
Babylon/Bones/babylon.skeleton.ts

@@ -48,11 +48,11 @@
                 bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), this._transformMatrices, index * 16);
             }
 
-
             this._identity.copyToArray(this._transformMatrices, this.bones.length * 16);
 
-
             this._isDirty = false;
+
+            this._scene._activeBones += this.bones.length;
         }
 
         public getAnimatables(): IAnimatable[] {

+ 4 - 5
Babylon/babylon.scene.js

@@ -905,6 +905,10 @@ var BABYLON;
             this._evaluateActiveMeshes();
             this._evaluateActiveMeshesDuration += BABYLON.Tools.Now - beforeEvaluateActiveMeshesDate;
             BABYLON.Tools.EndPerformanceCounter("Active meshes evaluation");
+            for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
+                var skeleton = this._activeSkeletons.data[skeletonIndex];
+                skeleton.prepare();
+            }
             // Render targets
             var beforeRenderTargetDate = BABYLON.Tools.Now;
             if (this.renderTargetsEnabled) {
@@ -1055,11 +1059,6 @@ var BABYLON;
                 this._physicsEngine._runOneStep(deltaTime / 1000.0);
                 BABYLON.Tools.EndPerformanceCounter("Physics");
             }
-            for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
-                var skeleton = this._activeSkeletons.data[skeletonIndex];
-                skeleton.prepare();
-                this._activeBones += skeleton.bones.length;
-            }
             // Customs render targets
             var beforeRenderTargetDate = BABYLON.Tools.Now;
             var engine = this.getEngine();

+ 8 - 10
Babylon/babylon.scene.ts

@@ -221,7 +221,7 @@
         private _renderTargets = new SmartArray<RenderTargetTexture>(256);
         public _activeParticleSystems = new SmartArray<ParticleSystem>(256);
         private _activeSkeletons = new SmartArray<Skeleton>(32);
-        private _activeBones = 0;
+        public _activeBones = 0;
 
         private _renderingManager: RenderingManager;
         private _physicsEngine: PhysicsEngine;
@@ -1171,6 +1171,13 @@
             this._evaluateActiveMeshesDuration += Tools.Now - beforeEvaluateActiveMeshesDate;
             Tools.EndPerformanceCounter("Active meshes evaluation");
 
+            // Skeletons
+            for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
+                var skeleton = this._activeSkeletons.data[skeletonIndex];
+
+                skeleton.prepare();
+            }
+
             // Render targets
             var beforeRenderTargetDate = Tools.Now;
             if (this.renderTargetsEnabled) {
@@ -1352,15 +1359,6 @@
                 Tools.EndPerformanceCounter("Physics");
             }
 
-            // Skeletons
-            for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
-                var skeleton = this._activeSkeletons.data[skeletonIndex];
-
-                skeleton.prepare();
-
-                this._activeBones += skeleton.bones.length;
-            }
-
             // Customs render targets
             var beforeRenderTargetDate = Tools.Now;
             var engine = this.getEngine();

+ 5 - 5
babylon.2.1-alpha.debug.js

@@ -8431,6 +8431,10 @@ var BABYLON;
             this._evaluateActiveMeshes();
             this._evaluateActiveMeshesDuration += BABYLON.Tools.Now - beforeEvaluateActiveMeshesDate;
             BABYLON.Tools.EndPerformanceCounter("Active meshes evaluation");
+            for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
+                var skeleton = this._activeSkeletons.data[skeletonIndex];
+                skeleton.prepare();
+            }
             // Render targets
             var beforeRenderTargetDate = BABYLON.Tools.Now;
             if (this.renderTargetsEnabled) {
@@ -8581,11 +8585,6 @@ var BABYLON;
                 this._physicsEngine._runOneStep(deltaTime / 1000.0);
                 BABYLON.Tools.EndPerformanceCounter("Physics");
             }
-            for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
-                var skeleton = this._activeSkeletons.data[skeletonIndex];
-                skeleton.prepare();
-                this._activeBones += skeleton.bones.length;
-            }
             // Customs render targets
             var beforeRenderTargetDate = BABYLON.Tools.Now;
             var engine = this.getEngine();
@@ -16322,6 +16321,7 @@ var BABYLON;
             }
             this._identity.copyToArray(this._transformMatrices, this.bones.length * 16);
             this._isDirty = false;
+            this._scene._activeBones += this.bones.length;
         };
         Skeleton.prototype.getAnimatables = function () {
             if (!this._animatables || this._animatables.length !== this.bones.length) {

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 2 - 2
babylon.2.1-alpha.js