Java Code Examples for com.jme3.math.Ray#getLimit()
The following examples show how to use
com.jme3.math.Ray#getLimit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TerrainQuad.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private int collideWithRay(Ray ray, CollisionResults results) { if (picker == null) picker = new BresenhamTerrainPicker(this); Vector3f intersection = picker.getTerrainIntersection(ray, results); if (intersection != null) { if (ray.getLimit() < Float.POSITIVE_INFINITY) { if (results.getClosestCollision().getDistance() <= ray.getLimit()) return 1; // in range else return 0; // out of range } else return 1; } else return 0; }
Example 2
Source File: BIHTree.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private int collideWithRay(Ray r, Matrix4f worldMatrix, BoundingVolume worldBound, CollisionResults results) { TempVars vars = TempVars.get(); try { CollisionResults boundResults = vars.collisionResults; boundResults.clear(); worldBound.collideWith(r, boundResults); if (boundResults.size() > 0) { float tMin = boundResults.getClosestCollision().getDistance(); float tMax = boundResults.getFarthestCollision().getDistance(); if (tMax <= 0) { tMax = Float.POSITIVE_INFINITY; } else if (tMin == tMax) { tMin = 0; } if (tMin <= 0) { tMin = 0; } if (r.getLimit() < Float.POSITIVE_INFINITY) { tMax = Math.min(tMax, r.getLimit()); if (tMin > tMax){ return 0; } } // return root.intersectBrute(r, worldMatrix, this, tMin, tMax, results); return root.intersectWhere(r, worldMatrix, this, tMin, tMax, results); } return 0; } finally { vars.release(); } }
Example 3
Source File: BIHTree.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private int collideWithRay(Ray r, Matrix4f worldMatrix, BoundingVolume worldBound, CollisionResults results) { boundResults.clear(); worldBound.collideWith(r, boundResults); if (boundResults.size() > 0) { float tMin = boundResults.getClosestCollision().getDistance(); float tMax = boundResults.getFarthestCollision().getDistance(); if (tMax <= 0) { tMax = Float.POSITIVE_INFINITY; } else if (tMin == tMax) { tMin = 0; } if (tMin <= 0) { tMin = 0; } if (r.getLimit() < Float.POSITIVE_INFINITY) { tMax = Math.min(tMax, r.getLimit()); } // return root.intersectBrute(r, worldMatrix, this, tMin, tMax, results); return root.intersectWhere(r, worldMatrix, this, tMin, tMax, results); } return 0; }