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:
@@ -24,6 +24,7 @@ package com.threerings.jme.tools;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.jme.math.Matrix4f;
|
||||
@@ -33,6 +34,8 @@ import com.jme.scene.Controller;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.Spatial;
|
||||
|
||||
import com.samskivert.util.Tuple;
|
||||
|
||||
import com.threerings.jme.Log;
|
||||
import com.threerings.jme.model.Model;
|
||||
import com.threerings.jme.util.JmeUtil;
|
||||
@@ -140,12 +143,19 @@ public class AnimationDef
|
||||
*/
|
||||
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 (TransformDef transform : frame.transforms) {
|
||||
TransformNode node = nodes.get(transform.name);
|
||||
if (node != null) {
|
||||
node.setLocalTransform(
|
||||
transform.translation, transform.rotation, transform.scale);
|
||||
node.transformed = true;
|
||||
}
|
||||
}
|
||||
root.updateGeometricState(0f, true);
|
||||
@@ -153,6 +163,16 @@ public class AnimationDef
|
||||
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. */
|
||||
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)
|
||||
{
|
||||
super(spatial.name);
|
||||
|
||||
Reference in New Issue
Block a user