Minor optimisations. Added several comments to unveil certain parts of the code.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9918 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
83caa059fb
commit
49f227b7cc
@ -215,9 +215,13 @@ public abstract class ConstraintDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(JmeExporter ex) throws IOException { }
|
public void write(JmeExporter ex) throws IOException {
|
||||||
|
//no need to implement this one (the TrackWrapper is used internally and never serialized)
|
||||||
|
}
|
||||||
|
|
||||||
public void read(JmeImporter im) throws IOException { }
|
public void read(JmeImporter im) throws IOException {
|
||||||
|
//no need to implement this one (the TrackWrapper is used internally and never serialized)
|
||||||
|
}
|
||||||
|
|
||||||
public void setTime(float time, float weight, AnimControl control,
|
public void setTime(float time, float weight, AnimControl control,
|
||||||
AnimChannel channel, TempVars vars) {
|
AnimChannel channel, TempVars vars) {
|
||||||
|
|||||||
@ -53,35 +53,23 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
public void bake(Transform ownerTransform, Transform targetTransform, float influence) {
|
public void bake(Transform ownerTransform, Transform targetTransform, float influence) {
|
||||||
Vector3f translation = ownerTransform.getTranslation();
|
Vector3f translation = ownerTransform.getTranslation();
|
||||||
|
|
||||||
if ((flag & LIMIT_XMIN) != 0) {
|
if ((flag & LIMIT_XMIN) != 0 && translation.x < limits[0][0]) {
|
||||||
if (translation.x < limits[0][0]) {
|
translation.x -= (translation.x - limits[0][0]) * influence;
|
||||||
translation.x -= (translation.x - limits[0][0]) * influence;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ((flag & LIMIT_XMAX) != 0) {
|
if ((flag & LIMIT_XMAX) != 0 && translation.x > limits[0][1]) {
|
||||||
if (translation.x > limits[0][1]) {
|
translation.x -= (translation.x - limits[0][1]) * influence;
|
||||||
translation.x -= (translation.x - limits[0][1]) * influence;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ((flag & LIMIT_YMIN) != 0) {
|
if ((flag & LIMIT_YMIN) != 0 && translation.y < limits[1][0]) {
|
||||||
if (translation.y < limits[1][0]) {
|
translation.y -= (translation.y - limits[1][0]) * influence;
|
||||||
translation.y -= (translation.y - limits[1][0]) * influence;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ((flag & LIMIT_YMAX) != 0) {
|
if ((flag & LIMIT_YMAX) != 0 && translation.y > limits[1][1]) {
|
||||||
if (translation.y > limits[1][1]) {
|
translation.y -= (translation.y - limits[1][1]) * influence;
|
||||||
translation.y -= (translation.y - limits[1][1]) * influence;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ((flag & LIMIT_ZMIN) != 0) {
|
if ((flag & LIMIT_ZMIN) != 0 && translation.z < limits[2][0]) {
|
||||||
if (translation.z < limits[2][0]) {
|
translation.z -= (translation.z - limits[2][0]) * influence;
|
||||||
translation.z -= (translation.z - limits[2][0]) * influence;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ((flag & LIMIT_ZMAX) != 0) {
|
if ((flag & LIMIT_ZMAX) != 0 && translation.z > limits[2][1]) {
|
||||||
if (translation.z > limits[2][1]) {
|
translation.z -= (translation.z - limits[2][1]) * influence;
|
||||||
translation.z -= (translation.z - limits[2][1]) * influence;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,5 +15,7 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bake(Transform ownerTransform, Transform targetTransform, float influence) { }
|
public void bake(Transform ownerTransform, Transform targetTransform, float influence) {
|
||||||
|
//null constraint does nothing so no need to implement this one
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
private static final int LIMIT_YROT = 0x02;
|
private static final int LIMIT_YROT = 0x02;
|
||||||
private static final int LIMIT_ZROT = 0x04;
|
private static final int LIMIT_ZROT = 0x04;
|
||||||
|
|
||||||
private float[][] limits = new float[3][2];
|
private transient float[][] limits = new float[3][2];
|
||||||
private transient float[] angles = new float[3];
|
private transient float[] angles = new float[3];
|
||||||
|
|
||||||
public ConstraintDefinitionRotLimit(Structure constraintData, BlenderContext blenderContext) {
|
public ConstraintDefinitionRotLimit(Structure constraintData, BlenderContext blenderContext) {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
private static final int LIMIT_ZMIN = 0x10;
|
private static final int LIMIT_ZMIN = 0x10;
|
||||||
private static final int LIMIT_ZMAX = 0x20;
|
private static final int LIMIT_ZMAX = 0x20;
|
||||||
|
|
||||||
protected float[][] limits = new float[3][2];
|
protected transient float[][] limits = new float[3][2];
|
||||||
|
|
||||||
public ConstraintDefinitionSizeLimit(Structure constraintData, BlenderContext blenderContext) {
|
public ConstraintDefinitionSizeLimit(Structure constraintData, BlenderContext blenderContext) {
|
||||||
super(constraintData, blenderContext);
|
super(constraintData, blenderContext);
|
||||||
|
|||||||
@ -461,6 +461,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
protected List<Geometry> applyBevelAndTaper(Curve curve, List<Geometry> bevelObject, Spline taperObject,
|
protected List<Geometry> applyBevelAndTaper(Curve curve, List<Geometry> bevelObject, Spline taperObject,
|
||||||
boolean smooth, BlenderContext blenderContext) {
|
boolean smooth, BlenderContext blenderContext) {
|
||||||
Vector3f[] curvePoints = BufferUtils.getVector3Array(curve.getFloatBuffer(Type.Position));
|
Vector3f[] curvePoints = BufferUtils.getVector3Array(curve.getFloatBuffer(Type.Position));
|
||||||
|
Vector3f subtractResult = new Vector3f();
|
||||||
float curveLength = curve.getLength();
|
float curveLength = curve.getLength();
|
||||||
|
|
||||||
FloatBuffer[] vertexBuffers = new FloatBuffer[bevelObject.size()];
|
FloatBuffer[] vertexBuffers = new FloatBuffer[bevelObject.size()];
|
||||||
@ -488,7 +489,6 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
//equal to the distance between the points on curve that define the bevel position
|
//equal to the distance between the points on curve that define the bevel position
|
||||||
//so instead doing complicated rotations on each point we will simply properly translate each of them
|
//so instead doing complicated rotations on each point we will simply properly translate each of them
|
||||||
|
|
||||||
Vector3f subtractResult = new Vector3f();
|
|
||||||
int[][] pointIndexes = new int[][] { { 0, 1 }, { curvePoints.length - 1, curvePoints.length - 2 } };
|
int[][] pointIndexes = new int[][] { { 0, 1 }, { curvePoints.length - 1, curvePoints.length - 2 } };
|
||||||
for(int[] indexes : pointIndexes) {
|
for(int[] indexes : pointIndexes) {
|
||||||
float distance = curvePoints[indexes[1]].subtract(curvePoints[indexes[0]], subtractResult).length();
|
float distance = curvePoints[indexes[1]].subtract(curvePoints[indexes[0]], subtractResult).length();
|
||||||
@ -506,7 +506,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
|
|||||||
float lengthAlongCurve = 0;
|
float lengthAlongCurve = 0;
|
||||||
for(int i=0;i<curvePoints.length; ++i) {
|
for(int i=0;i<curvePoints.length; ++i) {
|
||||||
if(i > 0) {
|
if(i > 0) {
|
||||||
lengthAlongCurve += curvePoints[i].subtract(curvePoints[i - 1]).length();
|
lengthAlongCurve += curvePoints[i].subtract(curvePoints[i - 1], subtractResult).length();
|
||||||
}
|
}
|
||||||
float taperScale = this.getTaperScale(taperObject, i == 0 ? 0 : lengthAlongCurve / curveLength);
|
float taperScale = this.getTaperScale(taperObject, i == 0 ? 0 : lengthAlongCurve / curveLength);
|
||||||
this.applyScale(bevels.get(i), curvePoints[i], taperScale);
|
this.applyScale(bevels.get(i), curvePoints[i], taperScale);
|
||||||
|
|||||||
@ -43,6 +43,7 @@ public class BlenderFileException extends Exception {
|
|||||||
* Constructor. Creates an exception with no description.
|
* Constructor. Creates an exception with no description.
|
||||||
*/
|
*/
|
||||||
public BlenderFileException() {
|
public BlenderFileException() {
|
||||||
|
//this constructor has no message
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -379,7 +379,12 @@ public class BlenderInputStream extends InputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException { }
|
public void close() throws IOException {
|
||||||
|
//this method is unimplemented because some loaders (ie. TGALoader) have flaws that close the stream given from the outside
|
||||||
|
//because the images can be stored directly in the blender file then this stream is properly positioned and given to the loader
|
||||||
|
//to read the image file, that is why we do not want it to be closed before the reading is done
|
||||||
|
//to properly close the stream use forceClose() method
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be used to close the stream because some loaders may close the stream while reading resources from it.
|
* This method should be used to close the stream because some loaders may close the stream while reading resources from it.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user