Don't merge meshes where, in any animation, one is visible and the other

isn't.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@221 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Andrzej Kapolka
2007-05-02 18:19:09 +00:00
parent a855fa8340
commit 277b62bd52
2 changed files with 23 additions and 0 deletions
@@ -24,6 +24,7 @@ package com.threerings.jme.tools;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Properties; import java.util.Properties;
import com.jme.math.Matrix4f; import com.jme.math.Matrix4f;
@@ -33,6 +34,8 @@ import com.jme.scene.Controller;
import com.jme.scene.Node; import com.jme.scene.Node;
import com.jme.scene.Spatial; import com.jme.scene.Spatial;
import com.samskivert.util.Tuple;
import com.threerings.jme.Log; import com.threerings.jme.Log;
import com.threerings.jme.model.Model; import com.threerings.jme.model.Model;
import com.threerings.jme.util.JmeUtil; import com.threerings.jme.util.JmeUtil;
@@ -140,12 +143,19 @@ public class AnimationDef
*/ */
public void filterTransforms (Node root, HashMap<String, TransformNode> nodes) public void filterTransforms (Node root, HashMap<String, TransformNode> nodes)
{ {
// clear the nodes' transformed flags
for (TransformNode node : nodes.values()) {
node.transformed = false;
}
// run through all animation frames
for (FrameDef frame : frames) { for (FrameDef frame : frames) {
for (TransformDef transform : frame.transforms) { for (TransformDef transform : frame.transforms) {
TransformNode node = nodes.get(transform.name); TransformNode node = nodes.get(transform.name);
if (node != null) { if (node != null) {
node.setLocalTransform( node.setLocalTransform(
transform.translation, transform.rotation, transform.scale); transform.translation, transform.rotation, transform.scale);
node.transformed = true;
} }
} }
root.updateGeometricState(0f, true); root.updateGeometricState(0f, true);
@@ -153,6 +163,16 @@ public class AnimationDef
node.cullDivergentTransforms(); node.cullDivergentTransforms();
} }
} }
// remove from merge candidates any pairs where one is visible and the other isn't
for (TransformNode node : nodes.values()) {
for (Iterator<Tuple<TransformNode, Matrix4f>> it = node.relativeTransforms.iterator();
it.hasNext(); ) {
if (it.next().left.transformed != node.transformed) {
it.remove();
}
}
}
} }
/** /**
@@ -560,6 +560,9 @@ public class ModelDef
* an animation, the node/transform pair is removed from the list. */ * an animation, the node/transform pair is removed from the list. */
public ArrayList<Tuple<TransformNode, Matrix4f>> relativeTransforms; public ArrayList<Tuple<TransformNode, Matrix4f>> relativeTransforms;
/** Marks this node as having been transformed in the course of an animation. */
public boolean transformed;
public TransformNode (SpatialDef spatial) public TransformNode (SpatialDef spatial)
{ {
super(spatial.name); super(spatial.name);