'isNotNull' method added to pointer (so that the code reading is more clear).

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7676 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 14 years ago
parent fd2184784c
commit 16c60c7cde
  1. 2
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ArmatureHelper.java
  2. 6
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ConstraintHelper.java
  3. 10
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/CurvesHelper.java
  4. 4
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MaterialHelper.java
  5. 10
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MeshHelper.java
  6. 12
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ModifierHelper.java
  7. 10
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ObjectHelper.java
  8. 2
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ParticlesHelper.java
  9. 2
      engine/src/blender/com/jme3/scene/plugins/blender/structures/Constraint.java
  10. 2
      engine/src/blender/com/jme3/scene/plugins/blender/utils/AbstractBlenderHelper.java
  11. 8
      engine/src/blender/com/jme3/scene/plugins/blender/utils/Pointer.java

@ -174,7 +174,7 @@ public class ArmatureHelper extends AbstractBlenderHelper {
Integer boneIndex = bonesMap.get(name);
if (boneIndex != null) {
Pointer p = (Pointer) bActionChannel.getFieldValue("ipo");
if (!p.isNull()) {
if (p.isNotNull()) {
Structure ipoStructure = p.fetchData(dataRepository.getInputStream()).get(0);
Ipo ipo = ipoHelper.createIpo(ipoStructure, dataRepository);
tracks.add(ipo.calculateTrack(boneIndex.intValue(), animationFrames[0], animationFrames[1], fps));

@ -568,7 +568,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
IpoHelper ipoHelper = dataRepository.getHelper(IpoHelper.class);
Map<String, Map<String, Ipo>> constraintsIpos = new HashMap<String, Map<String, Ipo>>();
Pointer pActions = (Pointer) objectStructure.getFieldValue("action");
if (!pActions.isNull()) {
if (pActions.isNotNull()) {
List<Structure> actions = pActions.fetchData(dataRepository.getInputStream());
for (Structure action : actions) {
Structure chanbase = (Structure) action.getFieldValue("chanbase");
@ -579,7 +579,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
List<Structure> constraintChannels = constChannels.evaluateListBase(dataRepository);
for (Structure constraintChannel : constraintChannels) {
Pointer pIpo = (Pointer) constraintChannel.getFieldValue("ipo");
if (!pIpo.isNull()) {
if (pIpo.isNotNull()) {
String constraintName = constraintChannel.getFieldValue("name").toString();
Ipo ipo = ipoHelper.createIpo(pIpo.fetchData(dataRepository.getInputStream()).get(0), dataRepository);
ipos.put(constraintName, ipo);
@ -594,7 +594,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
//loading constraints connected with the object's bones
List<Constraint> constraintsList = new ArrayList<Constraint>();
Pointer pPose = (Pointer) objectStructure.getFieldValue("pose");//TODO: what if the object has two armatures ????
if (!pPose.isNull()) {
if (pPose.isNotNull()) {
//getting pose channels
List<Structure> poseChannels = ((Structure) pPose.fetchData(dataRepository.getInputStream()).get(0).getFieldValue("chanbase")).evaluateListBase(dataRepository);
for (Structure poseChannel : poseChannels) {

@ -117,7 +117,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
//getting or creating bevel object
List<Geometry> bevelObject = null;
Pointer pBevelObject = (Pointer) curveStructure.getFieldValue("bevobj");
if (!pBevelObject.isNull()) {
if (pBevelObject.isNotNull()) {
Pointer pBevelStructure = (Pointer) pBevelObject.fetchData(dataRepository.getInputStream()).get(0).getFieldValue("data");
Structure bevelStructure = pBevelStructure.fetchData(dataRepository.getInputStream()).get(0);
bevelObject = this.toCurve(bevelStructure, dataRepository);
@ -177,7 +177,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
//getting taper object
Curve taperObject = null;
Pointer pTaperObject = (Pointer) curveStructure.getFieldValue("taperobj");
if (bevelObject != null && !pTaperObject.isNull()) {
if (bevelObject != null && pTaperObject.isNotNull()) {
Pointer pTaperStructure = (Pointer) pTaperObject.fetchData(dataRepository.getInputStream()).get(0).getFieldValue("data");
Structure taperStructure = pTaperStructure.fetchData(dataRepository.getInputStream()).get(0);
taperObject = this.loadTaperObject(taperStructure, dataRepository);
@ -236,7 +236,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
DataRepository dataRepository) throws BlenderFileException {
Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt");
List<Geometry> result = new ArrayList<Geometry>();
if (!pBezierTriple.isNull()) {
if (pBezierTriple.isNotNull()) {
boolean smooth = (((Number) nurb.getFlatFieldValue("flag")).intValue() & 0x01) != 0;
int resolution = ((Number) nurb.getFieldValue("resolu")).intValue();
boolean cyclic = (((Number) nurb.getFieldValue("flagu")).intValue() & 0x01) != 0;
@ -291,7 +291,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
List<Float>[] knots = new List[2];
Pointer[] pKnots = new Pointer[]{(Pointer) nurb.getFieldValue("knotsu"), (Pointer) nurb.getFieldValue("knotsv")};
for (int i = 0; i < knots.length; ++i) {
if (!pKnots[i].isNull()) {
if (pKnots[i].isNotNull()) {
FileBlockHeader fileBlockHeader = dataRepository.getFileBlock(pKnots[i].getOldMemoryAddress());
BlenderInputStream blenderInputStream = dataRepository.getInputStream();
blenderInputStream.setPosition(fileBlockHeader.getBlockPosition());
@ -563,7 +563,7 @@ public class CurvesHelper extends AbstractBlenderHelper {
List<Structure> nurbStructures = ((Structure) taperStructure.getFieldValue("nurb")).evaluateListBase(dataRepository);
for (Structure nurb : nurbStructures) {
Pointer pBezierTriple = (Pointer) nurb.getFieldValue("bezt");
if (!pBezierTriple.isNull()) {
if (pBezierTriple.isNotNull()) {
//creating the curve object
BezierCurve bezierCurve = new BezierCurve(0, pBezierTriple.fetchData(dataRepository.getInputStream()), 3);
List<Vector3f> controlPoints = bezierCurve.getControlPoints();

@ -235,7 +235,7 @@ public class MaterialHelper extends AbstractBlenderHelper {
DynamicArray<Pointer> mtexs = (DynamicArray<Pointer>) structure.getFieldValue("mtex");
for (int i = 0; i < mtexs.getTotalSize(); ++i) {
Pointer p = mtexs.get(i);
if (!p.isNull()) {
if (p.isNotNull()) {
List<Structure> mtex = p.fetchData(dataRepository.getInputStream());
if (mtex.size() == 1) {
Structure textureLink = mtex.get(0);
@ -544,7 +544,7 @@ public class MaterialHelper extends AbstractBlenderHelper {
public Material[] getMaterials(Structure structureWithMaterials, DataRepository dataRepository) throws BlenderFileException {
Pointer ppMaterials = (Pointer) structureWithMaterials.getFieldValue("mat");
Material[] materials = null;
if (!ppMaterials.isNull()) {
if (ppMaterials.isNotNull()) {
List<Structure> materialStructures = ppMaterials.fetchData(dataRepository.getInputStream());
if (materialStructures != null && materialStructures.size() > 0) {
MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class);

@ -124,7 +124,7 @@ public class MeshHelper extends AbstractBlenderHelper {
List<Vector2f> uvCoordinates = null;
List<Structure> mtFaces = null;
if (!pMTFace.isNull()) {
if (pMTFace.isNotNull()) {
mtFaces = pMTFace.fetchData(dataRepository.getInputStream());
int facesAmount = ((Number) structure.getFieldValue("totface")).intValue();
if (mtFaces.size() != facesAmount) {
@ -169,7 +169,7 @@ public class MeshHelper extends AbstractBlenderHelper {
}
// attaching image to texture (face can have UV's and image whlie its material may have no texture attached)
if (pImage != null && !pImage.isNull() && !materialNumberToTexture.containsKey(materialNumber)) {
if (pImage != null && pImage.isNotNull() && !materialNumberToTexture.containsKey(materialNumber)) {
Texture texture = textureHelper.getTextureFromImage(pImage.fetchData(dataRepository.getInputStream()).get(0),
dataRepository);
if (texture != null) {
@ -436,7 +436,7 @@ public class MeshHelper extends AbstractBlenderHelper {
Pointer pMCol = (Pointer) meshStructure.getFieldValue("mcol");
List<float[]> verticesColors = null;
List<Structure> mCol = null;
if (!pMCol.isNull()) {
if (pMCol.isNotNull()) {
verticesColors = new LinkedList<float[]>();
mCol = pMCol.fetchData(dataRepository.getInputStream());
for (Structure color : mCol) {
@ -502,7 +502,7 @@ public class MeshHelper extends AbstractBlenderHelper {
Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert = DeformVERTices
FloatBuffer weightsFloatData = BufferUtils.createFloatBuffer(vertexListSize * MAXIMUM_WEIGHTS_PER_VERTEX);
ByteBuffer indicesData = BufferUtils.createByteBuffer(vertexListSize * MAXIMUM_WEIGHTS_PER_VERTEX);
if (!pDvert.isNull()) {// assigning weights and bone indices
if (pDvert.isNotNull()) {// assigning weights and bone indices
List<Structure> dverts = pDvert.fetchData(dataRepository.getInputStream());// dverts.size() == verticesAmount (one dvert per
// vertex in blender)
int vertexIndex = 0;
@ -511,7 +511,7 @@ public class MeshHelper extends AbstractBlenderHelper {
// (max. 4 in JME)
Pointer pDW = (Pointer) dvert.getFieldValue("dw");
List<Integer> vertexIndices = vertexReferenceMap.get(Integer.valueOf(vertexIndex));// we fetch the referenced vertices here
if (totweight > 0 && !pDW.isNull()) {// pDW should never be null here, but I check it just in case :)
if (totweight > 0 && pDW.isNotNull()) {// pDW should never be null here, but I check it just in case :)
int weightIndex = 0;
List<Structure> dw = pDW.fetchData(dataRepository.getInputStream());
for (Structure deformWeight : dw) {

@ -168,18 +168,18 @@ public class ModifierHelper extends AbstractBlenderHelper {
}
if ((offsettype & 0x04) != 0) {// Object offset
Pointer pOffsetObject = (Pointer) modifier.getFieldValue("offset_ob");
if (!pOffsetObject.isNull()) {
if (pOffsetObject.isNotNull()) {
params.put("offsetob", pOffsetObject);
}
}
// start cap and end cap
Pointer pStartCap = (Pointer) modifier.getFieldValue("start_cap");
if (!pStartCap.isNull()) {
if (pStartCap.isNotNull()) {
params.put("startcap", pStartCap);
}
Pointer pEndCap = (Pointer) modifier.getFieldValue("end_cap");
if (!pEndCap.isNull()) {
if (pEndCap.isNotNull()) {
params.put("endcap", pEndCap);
}
loadedModifier = params;
@ -190,13 +190,13 @@ public class ModifierHelper extends AbstractBlenderHelper {
params.put("flag", modifier.getFieldValue("flag"));
params.put("tolerance", modifier.getFieldValue("tolerance"));
Pointer pMirrorOb = (Pointer) modifier.getFieldValue("mirror_ob");
if (!pMirrorOb.isNull()) {
if (pMirrorOb.isNotNull()) {
params.put("mirrorob", pMirrorOb);
}
loadedModifier = params;
} else if (Modifier.ARMATURE_MODIFIER_DATA.equals(modifier.getType())) {// ****************ARMATURE MODIFIER
Pointer pArmatureObject = (Pointer) modifier.getFieldValue("object");
if (!pArmatureObject.isNull()) {
if (pArmatureObject.isNotNull()) {
ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class);
Structure armatureObject = (Structure) dataRepository.getLoadedFeature(pArmatureObject.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_STRUCTURE);
if (armatureObject == null) {// we check this first not to fetch the structure unnecessary
@ -237,7 +237,7 @@ public class ModifierHelper extends AbstractBlenderHelper {
}
} else if (Modifier.PARTICLE_MODIFIER_DATA.equals(modifier.getType())) {// ****************PARTICLES MODIFIER
Pointer pParticleSystem = (Pointer) modifier.getFieldValue("psys");
if (!pParticleSystem.isNull()) {
if (pParticleSystem.isNotNull()) {
ParticlesHelper particlesHelper = dataRepository.getHelper(ParticlesHelper.class);
Structure particleSystem = pParticleSystem.fetchData(dataRepository.getInputStream()).get(0);
loadedModifier = particlesHelper.toParticleEmitter(particleSystem, dataRepository);

@ -152,7 +152,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
Pointer pParent = (Pointer)objectStructure.getFieldValue("parent");
Object parent = dataRepository.getLoadedFeature(pParent.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE);
if(parent == null && !pParent.isNull()) {
if(parent == null && pParent.isNotNull()) {
Structure parentStructure = pParent.fetchData(dataRepository.getInputStream()).get(0);//TODO: moze byc wiecej rodzicow
parent = this.toObject(parentStructure, dataRepository);
}
@ -203,7 +203,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
case OBJECT_TYPE_CURVE:
LOGGER.log(Level.INFO, "Importing curve/nurb.");
Pointer pCurve = (Pointer)objectStructure.getFieldValue("data");
if(!pCurve.isNull()) {
if(pCurve.isNotNull()) {
CurvesHelper curvesHelper = dataRepository.getHelper(CurvesHelper.class);
Structure curveData = pCurve.fetchData(dataRepository.getInputStream()).get(0);
List<Geometry> curves = curvesHelper.toCurve(curveData, dataRepository);
@ -217,7 +217,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
case OBJECT_TYPE_LAMP:
LOGGER.log(Level.INFO, "Importing lamp.");
Pointer pLamp = (Pointer)objectStructure.getFieldValue("data");
if(!pLamp.isNull()) {
if(pLamp.isNotNull()) {
LightHelper lightHelper = dataRepository.getHelper(LightHelper.class);
List<Structure> lampsArray = pLamp.fetchData(dataRepository.getInputStream());
Light light = lightHelper.toLight(lampsArray.get(0), dataRepository);
@ -239,7 +239,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
break;
case OBJECT_TYPE_CAMERA:
Pointer pCamera = (Pointer)objectStructure.getFieldValue("data");
if(!pCamera.isNull()) {
if(pCamera.isNotNull()) {
CameraHelper cameraHelper = dataRepository.getHelper(CameraHelper.class);
List<Structure> camerasArray = pCamera.fetchData(dataRepository.getInputStream());
Camera camera = cameraHelper.toCamera(camerasArray.get(0));
@ -357,7 +357,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
*/
public Modifier readObjectAnimation(Structure objectStructure, DataRepository dataRepository) throws BlenderFileException {
Pointer pIpo = (Pointer)objectStructure.getFieldValue("ipo");
if(!pIpo.isNull()) {
if(pIpo.isNotNull()) {
//check if there is an action name connected with this ipo
String objectAnimationName = null;
List<FileBlockHeader> actionBlocks = dataRepository.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00));

@ -96,7 +96,7 @@ public class ParticlesHelper extends AbstractBlenderHelper {
public ParticleEmitter toParticleEmitter(Structure particleSystem, DataRepository dataRepository) throws BlenderFileException {
ParticleEmitter result = null;
Pointer pParticleSettings = (Pointer) particleSystem.getFieldValue("part");
if(!pParticleSettings.isNull()) {
if(pParticleSettings.isNotNull()) {
Structure particleSettings = pParticleSettings.fetchData(dataRepository.getInputStream()).get(0);
int totPart = ((Number) particleSettings.getFieldValue("totpart")).intValue();

@ -47,7 +47,7 @@ public class Constraint {
throw new IllegalArgumentException("Influence function is not defined!");
}
Pointer pData = (Pointer) constraintStructure.getFieldValue("data");
if (!pData.isNull()) {
if (pData.isNotNull()) {
data = pData.fetchData(dataRepository.getInputStream()).get(0);
} else {
throw new BlenderFileException("The constraint has no data specified!");

@ -118,7 +118,7 @@ public abstract class AbstractBlenderHelper {
Structure id = (Structure) structure.getFieldValue("ID");
if (id != null) {
Pointer pProperties = (Pointer) id.getFieldValue("properties");
if (!pProperties.isNull()) {
if (pProperties.isNotNull()) {
Structure propertiesStructure = pProperties.fetchData(dataRepository.getInputStream()).get(0);
properties = new Properties();
properties.load(propertiesStructure, dataRepository);

@ -138,6 +138,14 @@ public class Pointer {
return oldMemoryAddress == 0;
}
/**
* This method indicates if this is a null-pointer or not.
* @return <b>true</b> if the pointer is not null and <b>false</b> otherwise
*/
public boolean isNotNull() {
return oldMemoryAddress != 0;
}
/**
* This method returns the old memory address of the structure pointed by the pointer.
* @return the old memory address of the structure pointed by the pointer

Loading…
Cancel
Save