(updated) Plane creation in dgMeshEffect is commented out

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

(updated) Plane creation in dgMeshEffect is commented out

Postby agi_shi » Wed May 11, 2011 6:30 pm

Look:
Code: Select all
dgMeshEffect::dgMeshEffect (dgMemoryAllocator* const allocator, const dgMatrix& planeMatrix, dgFloat32 witdth, dgFloat32 breadth, dgInt32 material, const dgMatrix& textureMatrix0, const dgMatrix& textureMatrix1)
   :dgPolyhedra(allocator)
{
   _ASSERTE (0);
/*

(lots of code)

This seems to be the case in 2.33, as well as the latest SVN versions of both 200 and 300. I need to create a plane mesh in order to use NewtonMeshClip() to "cut" one of my meshes. It's a really cool idea, but I can't do it unless I can create a plane mesh :(
Image
When the portals close, I want to "cut" the physics objects :twisted:
Last edited by agi_shi on Thu May 12, 2011 6:50 pm, edited 1 time in total.
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: Plane creation in dgMeshEffect is commented out

Postby Julio Jerez » Wed May 11, 2011 8:27 pm

agi, this is because I was thinking ofo using boollean to do that operation, but you are right, I will uncomment and make usable again tonight.

I did not know you were using that, you are not using it for real time are you?
The old method was fast enought to use in real time with small meshes, but it si a futile effort because boollean are too prompt to roundoff errors, therefore I re-wrote using extend presicion arithmetic

I am glad you want to use it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Plane creation in dgMeshEffect is commented out

Postby agi_shi » Wed May 11, 2011 8:32 pm

Julio Jerez wrote:agi, thsi si because I was thonkin to use teh bollean to do that operation, bu you are right
I will uncomment and make usable again tonight.

Okay awesome, let me know when it's up on SVN :) Hopefully I can recompile tomorrow morning before heading off to school so I can work on it :mrgreen:

I did not know you were using that, you are not using it for real time are you?
The old methof was for wokrjed in real time but it si a futile effort, because boollean are too promt to roundoff errors, therefore I re-wrote using extend presicion arithmetic

I am glad you want to use it,

It depends on what you mean by real time. While objects are inside the portal, everything is controlled by processing and rejecting contacts and clever graphics tricks. However, when the portals close, I want to use NewtonMeshClip() to "cut" the objects and leave only the parts that weren't inside the portal :twisted:
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: Plane creation in dgMeshEffect is commented out

Postby Julio Jerez » Thu May 12, 2011 9:58 am

Ok I check in the function,

thi si shwo you use it

Code: Select all
NewtonMesh* backMesh;
NewtonMesh* frontMesh;
dMatrix planeMatrix (GetIdentityMatrix());
planeMatrix.m_front = dVector (0, 1, 0, 0); // this is the plane normal
planeMatrix.m_up = dVector (1, 0, 0, 0); // the alignment on the plane normal
planeMatrix.m_right = planeMatrix.m_front * planeMatrix.m_up;
planeMatrix.m_posit = dVector (0, 0, 0, 1.0); // this is the plane origin

dMatrix texMatrix (GetIdentityMatrix());
texMatrix[0][0] = 4; // u scaling
texMatrix[1][1] = 4; // v scaling
NewtonMeshPlaneClip(mesh, &planeMatrix[0][0], &texMatrix[0][0], tex0, &backMesh, &frontMesh);
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Plane creation in dgMeshEffect is commented out

Postby agi_shi » Thu May 12, 2011 4:35 pm

Hey,

Awesome! :mrgreen: :twisted:
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: (updated) Plane creation in dgMeshEffect is commented ou

Postby agi_shi » Thu May 12, 2011 6:54 pm

Hey Julio,

Everything works great except for one thing - sometimes, when I use NewtonMeshClipPlane() to cut a sphere in half, the halves are missing 1 triangle.

Here is such a "bad" cut:
Image

And here is a "good" cut:
Image

It's probably just some simple little bug, any ideas?
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: (updated) Plane creation in dgMeshEffect is commented ou

Postby Julio Jerez » Thu May 12, 2011 7:17 pm

does it always happens?
has you seen it with some like a Box?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: (updated) Plane creation in dgMeshEffect is commented ou

Postby agi_shi » Thu May 12, 2011 7:25 pm

It doesn't always happen, only sometimes, and only with a sphere. I've tried boxes, cylinders, and cones - all of these work fine every single time.

So it only happens with a sphere, and only some of the time. Weird :|

(see the GIFs I linked to, one is when it worked good, and one is when it worked bad)
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: (updated) Plane creation in dgMeshEffect is commented ou

Postby Julio Jerez » Thu May 12, 2011 10:52 pm

I have an idea why it happens, I beleiev it is because teh plane is passing throught a vertex. and teh clipper fail vecause it does no consider vertex clip.
I beleiev it alway had tha bug an dI never saw itbecause I never test with spheres, which are higher rest than other models.

If that is the case I will have to set up a test that reproduce it the error. But I can no do it right now, I will do this weekend.

The one thing you coud do is to show the wire frame of the clipped mesh and inspect if the clipped plane is very close to a vertex of the sphere, that will confirm visually if my suspition is right.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: (updated) Plane creation in dgMeshEffect is commented ou

Postby Julio Jerez » Tue May 17, 2011 11:44 am

Agi can you sync to SNV and see if teh chek that I put to detect the clip bug is valid

if you sync buidl in debug mode I add to assetr to this function
void dgMeshEffect::PlaneClipMesh (const dgMatrix& planeMatrix, const dgMatrix& planeTextMatrix, dgInt32 planeMaterial, dgMeshEffect** const left, dgMeshEffect** const right) const

in file c:\Users\Julio\Desktop\newton-dynamics\coreLibrary_200\source\physics\dgMeshEffect.cpp
if I am correct the assert soudl hit whn eteh bug happens,
I believ it is when teh mesh happn to have a face in whin one edge is already in teh plane, if teh is the case the code leave teh edge uncolored.

Basically teh thenioqhe I use is very simple it work liek this

1-for all vertices mark in wich side of the plane they are +, -, zero
2-splite each edge going across the plane,
3-Insert a parallel edge on each polygon with one edge going fron the plane to the positive size and one edge going from the negative to the negative side of the plane
4- new inserted edges are collored + for the edge side on the positive side, and negative for the edge side on the negative size of the plane.
3-this is where the bug happens because if a face already hase and edge on teh plane themn teh edge is not collored, and the Cap algorithm fail to cap that edge.

It is eassy to fixe but feir sI like you ro run the test and see if teh mesh tha show the bug are the one that hit the ASSERTE.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: (updated) Plane creation in dgMeshEffect is commented ou

Postby Julio Jerez » Wed May 18, 2011 10:04 am

Ok I think I added teh fix, but I am noit sure if that was teh cause of teh Bug.

I cliipd 1000 spher with randon cut planes with teh origon and teh center of the sphere.
The code seems to work, but I did no seee the visual.
please when you have a chance to test it let me know if that was the problem.

if it was not, then the bug is in the Capping function itself. but I do not know what could be other than round error form point too close.

Let me know you findings.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: (updated) Plane creation in dgMeshEffect is commented ou

Postby agi_shi » Sat May 28, 2011 9:02 am

Okay thanks a lot for your work Julio, I will let you know what happens when I get a chance to test it, I've been a little busy lately :(
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 6 guests