From 64c732451a6943581038519c6df3f2c240d91d8e Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Tue, 18 Mar 2014 16:47:36 +0000 Subject: [PATCH] Bugfix: fixed a bug that caused the 'maintain volume' constraint to be badlu applied on objects. git-svn-id: https://jmonkeyengine.googlecode.com/svn/branches/gradle-restructure@11104 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../ConstraintDefinitionMaintainVolume.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionMaintainVolume.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionMaintainVolume.java index 75ee9fcbc..fce99d40f 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionMaintainVolume.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/definitions/ConstraintDefinitionMaintainVolume.java @@ -1,5 +1,6 @@ package com.jme3.scene.plugins.blender.constraints.definitions; +import com.jme3.animation.Bone; import com.jme3.math.Transform; import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space; @@ -20,21 +21,25 @@ public class ConstraintDefinitionMaintainVolume extends ConstraintDefinition { @Override public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) { if (volume != 1 && influence > 0) { - Transform ownerTransform = this.getOwnerTransform(ownerSpace); - switch (flag) { - case FLAG_MASK_X: - ownerTransform.getScale().multLocal(1, volume, volume); - break; - case FLAG_MASK_Y: - ownerTransform.getScale().multLocal(volume, 1, volume); - break; - case FLAG_MASK_Z: - ownerTransform.getScale().multLocal(volume, volume, 1); - break; - default: - throw new IllegalStateException("Unknown flag value: " + flag); + // the maintain volume constraint is applied directly to object's scale, so no need to do it again + // but in case of bones we need to make computations + if (this.getOwner() instanceof Bone) { + Transform ownerTransform = this.getOwnerTransform(ownerSpace); + switch (flag) { + case FLAG_MASK_X: + ownerTransform.getScale().multLocal(1, volume, volume); + break; + case FLAG_MASK_Y: + ownerTransform.getScale().multLocal(volume, 1, volume); + break; + case FLAG_MASK_Z: + ownerTransform.getScale().multLocal(volume, volume, 1); + break; + default: + throw new IllegalStateException("Unknown flag value: " + flag); + } + this.applyOwnerTransform(ownerTransform, ownerSpace); } - this.applyOwnerTransform(ownerTransform, ownerSpace); } }