after fixing the StaticMeshes generated from my planet-chunks (Some of the vertices were 'NaN'. I don't even know how you handled this on mesh creation without throwing an exception xD) they are pretty fast
Now I'm stuck with another problem:
My RayCasts are very inaccurate. I don't know why, but when pointing (=selecting) towards the planet, I get sometimes the correct chunk selected and sometimes I get the chunk from the other side.
For a better explanation I made a video:
http://youtu.be/tFXsXPNUNfc
The big box around the whole planet has a side length of 2 and is centered at zero, indicating the 'high precision area' (-1 to 1).
As you can see, I just slightly changing my crosshair and I select the chunk behind on the other side. In addition I made a collision box I shoot towards the planet. Sometimes it collides with the planet, sometimes it went's through it.
When moving closer (producing smaller chunks [quadtree]. The greater parent chunk is removed from space) the collision with box/ray totally fails.
Here is my ray cast code:
Code: Select all
//This is OpenTK's equivalent to XNA's Matrix.Forward
if (planet.PlanetSpace.RayCast(new Ray(camera.Position, -camera.CameraMatrix.Row2.Xyz), out raycastResult))
{
if (raycastResult.HitObject as BEPUphysics.Collidables.StaticMesh != null) //Check if result is a chunk
{
var entityCollision = raycastResult.HitObject as BEPUphysics.Collidables.StaticMesh; //Get the StaticMesh
var box = entityCollision.BoundingBox; // Get the Boundingbox from StaticMesh
selectionBox = new WireBox(this, box.GetCorners()); // Create a visible wirebox from the BoundingBox for drawing
Console.WriteLine("HIT: " + raycastResult.HitData.Location); // Write HitData
}
}
Any ideas?
When I create the shooting box larger than 0.09 (i.e. 0.1) in side length, the box is colliding correct every time (but I even want a 0.0000001 sized box colliding correctly ).-
Is 0.1 maybe the smallest that BEPUphysics can handle ?