diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ArmatureHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ArmatureHelper.java index bec0324d8..fab1b6069 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ArmatureHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ArmatureHelper.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)); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ConstraintHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ConstraintHelper.java index 6e4a54757..23edc5d76 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ConstraintHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ConstraintHelper.java @@ -568,7 +568,7 @@ public class ConstraintHelper extends AbstractBlenderHelper { IpoHelper ipoHelper = dataRepository.getHelper(IpoHelper.class); Map> constraintsIpos = new HashMap>(); Pointer pActions = (Pointer) objectStructure.getFieldValue("action"); - if (!pActions.isNull()) { + if (pActions.isNotNull()) { List 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 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 constraintsList = new ArrayList(); Pointer pPose = (Pointer) objectStructure.getFieldValue("pose");//TODO: what if the object has two armatures ???? - if (!pPose.isNull()) { + if (pPose.isNotNull()) { //getting pose channels List poseChannels = ((Structure) pPose.fetchData(dataRepository.getInputStream()).get(0).getFieldValue("chanbase")).evaluateListBase(dataRepository); for (Structure poseChannel : poseChannels) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/CurvesHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/CurvesHelper.java index 5eb429e36..8e3662ef6 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/CurvesHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/CurvesHelper.java @@ -117,7 +117,7 @@ public class CurvesHelper extends AbstractBlenderHelper { //getting or creating bevel object List 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 result = new ArrayList(); - 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[] 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 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 controlPoints = bezierCurve.getControlPoints(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MaterialHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MaterialHelper.java index 8841744ba..ea0d29179 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MaterialHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MaterialHelper.java @@ -235,7 +235,7 @@ public class MaterialHelper extends AbstractBlenderHelper { DynamicArray mtexs = (DynamicArray) structure.getFieldValue("mtex"); for (int i = 0; i < mtexs.getTotalSize(); ++i) { Pointer p = mtexs.get(i); - if (!p.isNull()) { + if (p.isNotNull()) { List 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 materialStructures = ppMaterials.fetchData(dataRepository.getInputStream()); if (materialStructures != null && materialStructures.size() > 0) { MaterialHelper materialHelper = dataRepository.getHelper(MaterialHelper.class); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MeshHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MeshHelper.java index 59e2461d0..91b781ad4 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MeshHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MeshHelper.java @@ -124,7 +124,7 @@ public class MeshHelper extends AbstractBlenderHelper { List uvCoordinates = null; List 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 verticesColors = null; List mCol = null; - if (!pMCol.isNull()) { + if (pMCol.isNotNull()) { verticesColors = new LinkedList(); 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 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 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 dw = pDW.fetchData(dataRepository.getInputStream()); for (Structure deformWeight : dw) { diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ModifierHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ModifierHelper.java index 0bf2ffb55..6fc6994c8 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ModifierHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ModifierHelper.java @@ -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); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ObjectHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ObjectHelper.java index 134a48bfd..033686f3f 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ObjectHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ObjectHelper.java @@ -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 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 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 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 actionBlocks = dataRepository.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00)); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ParticlesHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ParticlesHelper.java index 13d04139e..3fbdc79e2 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ParticlesHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ParticlesHelper.java @@ -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(); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/structures/Constraint.java b/engine/src/blender/com/jme3/scene/plugins/blender/structures/Constraint.java index 6f2c645c3..7467c0aca 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/structures/Constraint.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/structures/Constraint.java @@ -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!"); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/utils/AbstractBlenderHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/utils/AbstractBlenderHelper.java index 26df4d388..de4e84155 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/utils/AbstractBlenderHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/utils/AbstractBlenderHelper.java @@ -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); diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/utils/Pointer.java b/engine/src/blender/com/jme3/scene/plugins/blender/utils/Pointer.java index fd0484348..92d359555 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/utils/Pointer.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/utils/Pointer.java @@ -137,6 +137,14 @@ public class Pointer { public boolean isNull() { return oldMemoryAddress == 0; } + + /** + * This method indicates if this is a null-pointer or not. + * @return true if the pointer is not null and false otherwise + */ + public boolean isNotNull() { + return oldMemoryAddress != 0; + } /** * This method returns the old memory address of the structure pointed by the pointer.