New btInternalEdgeUtility has been added
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
Re: New btInternalEdgeUtility has been added
I tried today's svn and I can no-longer reproduce the small difference I made the video about. This is good because I don't have time to write a test case
All the meshes still seem to be double-sided though? I came to actually quite like the idea of single sided triangles because if you have a wall made of two big parallel triangles facing in opposite directions with a few inches gap between them, it stops projectiles getting jammed inside the wall. However this is still happening with latest svn (unless I built it wrong or something).
All the meshes still seem to be double-sided though? I came to actually quite like the idea of single sided triangles because if you have a wall made of two big parallel triangles facing in opposite directions with a few inches gap between them, it stops projectiles getting jammed inside the wall. However this is still happening with latest svn (unless I built it wrong or something).
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: New btInternalEdgeUtility has been added
Great, thanks for testing it.sparkprime wrote:I tried today's svn and I can no-longer reproduce the small difference I made the video about. This is good because I don't have time to write a test case
All the meshes still seem to be double-sided though?
This is considered bad artworktwo big parallel triangles facing in opposite directions with a few inches gap between them
The btInternalEdgeUtility only acts on contacts on an edge boundary, so it won't help in general. So in our current implementation it is not the mesh but the btInternalEdgeUtility that assumes single-sided triangles by default. This means that it adjusts the normal (for contacts on edges) in the direction of the triangle normal, even if the object is mainly on the other side of the triangle. You could modify the code to deal with single-sided triangle meshes in general, but that is a separate topic.
The options BT_TRIANGLE_CONCAVE_DOUBLE_SIDED+BT_TRIANGLE_CONVEX_DOUBLE_SIDED will make an attempt to adjust the contact normal independent of triangle normal.
Thanks,
Erwin
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
Re: New btInternalEdgeUtility has been added
Is there a better way to do it with triangles though? With hulls / boxes it would work flawlessly but tool support for those is less common. What artists like to do is just do a low poly mesh first as a placeholder as they're building up the scene. Then they do a highpoly mesh for graphics and reuse the placeholder mesh for distant renders and for physics. So it's nice if this can be the typical workflow, with only a minority of problems to be 'corrected' after testing by adding convex shapes in key places.Erwin Coumans wrote:This is considered bad artworktwo big parallel triangles facing in opposite directions with a few inches gap between them
Ah that is interesting... I have a contact_added hack for gimpact meshes that makes them 1-way by reflecting the contact normal if it is not pointing within 90 degrees of the inferred triangle normal. I might try that but should it be used before or after the edge normal adjustment? Seems like it might break things.The btInternalEdgeUtility only acts on contacts on an edge boundary, so it won't help in general. So in our current implementation it is not the mesh but the btInternalEdgeUtility that assumes single-sided triangles by default. This means that it adjusts the normal (for contacts on edges) in the direction of the triangle normal, even if the object is mainly on the other side of the triangle. You could modify the code to deal with single-sided triangle meshes in general, but that is a separate topic.
Erwin
-
- Posts: 16
- Joined: Tue Jul 08, 2008 7:28 am
Re: New btInternalEdgeUtility has been added
i encount a new problem, when i start my program,don't do anything but leave the car on the ground,(the car didn't crash or contact with any bvhShap, just on a bvhShap),a few minutes later,the car just go crazy,then flew away...its behaviour just like the old version(like i double side problem)..
please test it with my test case....
please test it with my test case....
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: New btInternalEdgeUtility has been added
The car doesn't start in (deep) penetration, and you are not driving/colliding at all? That sounds strange, because without collisions the internal edge utility isn't used.edl wrote: i encount a new problem, when i start my program,don't do anything but leave the car on the ground,(the car didn't crash or contact with any bvhShap, just on a bvhShap),a few minutes later,the car just go crazy,then flew away...its behaviour just like the old version(like i double side problem)..
please test it with my test case....
Can you please file a bug report with more details in the google issue tracker, and attach the test case?
http://code.google.com/p/bullet/issues/list
Thanks a lot,
Erwin
-
- Posts: 16
- Joined: Tue Jul 08, 2008 7:28 am
Re: New btInternalEdgeUtility has been added
I am so sorry,it seems my mistakeErwin Coumans wrote:The car doesn't start in (deep) penetration, and you are not driving/colliding at all? That sounds strange, because without collisions the internal edge utility isn't used.edl wrote: i encount a new problem, when i start my program,don't do anything but leave the car on the ground,(the car didn't crash or contact with any bvhShap, just on a bvhShap),a few minutes later,the car just go crazy,then flew away...its behaviour just like the old version(like i double side problem)..
please test it with my test case....
Can you please file a bug report with more details in the google issue tracker, and attach the test case?
http://code.google.com/p/bullet/issues/list
Thanks a lot,
Erwin
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: New btInternalEdgeUtility has been added
Thanks a lot for the extra testing, I'm glad the btInternalEdgeUtility wasn't the cause for problems.edl wrote: I am so sorry,it seems my mistake
Thanks,
Erwin
-
- Posts: 8
- Joined: Tue Jun 02, 2009 5:52 am
Re: New btInternalEdgeUtility has been added
Hi Erwin,
I've been trying to in-place save the btTriangleInfoMap data, but stopped because btHashMap is private and didn't want to hack the bullet code.
Is there any in-place serialization planned for this?
Thanks
Ales Mlakar
Zootfly
I've been trying to in-place save the btTriangleInfoMap data, but stopped because btHashMap is private and didn't want to hack the bullet code.
Is there any in-place serialization planned for this?
Thanks
Ales Mlakar
Zootfly
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: New btInternalEdgeUtility has been added
I want to add btInternalEdgeUtility support for the new btSerializer (and btBulletFile/btBulletWorldImporter)JaZzBrE wrote:I've been trying to in-place save the btTriangleInfoMap data, but stopped because btHashMap is private and didn't want to hack the bullet code.
Is there any in-place serialization planned for this?
Although this is not in-place serialization, it is very efficient and more compatible (cross-platform, 32/64bit, big/little endian, float/double precision conversions etc).
Would that be sufficient too?
Thanks,
Erwin
-
- Posts: 8
- Joined: Tue Jun 02, 2009 5:52 am
Re: New btInternalEdgeUtility has been added
Hi Erwin,
well it seems I've missed this release But yes this would probably work!
I've managed to save btTriangleInfoMap into our resource file now, with no bullet hacks, I just had to find a way to de-private the class (which is writing a bit hacky public class that looks the same as btHashMap, and just casting it).
On build time I just endian swap the data and save, and on load time I use the initializeFromBuffer on the four arrays.
Thanks a lot!
Ales Mlakar
Zootfly
well it seems I've missed this release But yes this would probably work!
I've managed to save btTriangleInfoMap into our resource file now, with no bullet hacks, I just had to find a way to de-private the class (which is writing a bit hacky public class that looks the same as btHashMap, and just casting it).
On build time I just endian swap the data and save, and on load time I use the initializeFromBuffer on the four arrays.
Thanks a lot!
Ales Mlakar
Zootfly
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: New btInternalEdgeUtility has been added
Ok, btHashMap data is now protected (not private anymore), and some more preparations for btTriangleInfoMap serialization:
http://code.google.com/p/bullet/source/detail?r=2025
Thanks,
Erwin
http://code.google.com/p/bullet/source/detail?r=2025
Thanks,
Erwin
-
- Posts: 8
- Joined: Tue Jun 02, 2009 5:52 am
Re: New btInternalEdgeUtility has been added
Hehe good one, thanks!
Ales Mlakar
Zootfly
Ales Mlakar
Zootfly
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
Re: New btInternalEdgeUtility has been added
I updated today and now I get a segfault here
temporary workaround is to stop using the edge adjustment utility
any ideas?
Code: Select all
(gdb) bt
#0 0x08756c9e in btAlignedObjectArray<btTriangleInfo>::capacity() const ()
#1 0x08756bf6 in btHashMap<btHashInt, btTriangleInfo>::findIndex(btHashInt const&) const ()
#2 0x08756872 in btHashMap<btHashInt, btTriangleInfo>::find(btHashInt const&) ()
#3 0x087540c9 in btAdjustInternalEdgeContacts (cp=..., colObj0=0x236a9d50, colObj1=0x2350fbb0, partId0=0, index0=1055, normalAdjustFlags=0)
at /home/spark/gritengine/dependencies/bullet/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp:467
any ideas?
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: New btInternalEdgeUtility has been added
sparkprime wrote:I updated today and now I get a segfault here
temporary workaround is to stop using the edge adjustment utilityCode: Select all
(gdb) bt #0 0x08756c9e in btAlignedObjectArray<btTriangleInfo>::capacity() const () #1 0x08756bf6 in btHashMap<btHashInt, btTriangleInfo>::findIndex(btHashInt const&) const () #2 0x08756872 in btHashMap<btHashInt, btTriangleInfo>::find(btHashInt const&) () #3 0x087540c9 in btAdjustInternalEdgeContacts (cp=..., colObj0=0x236a9d50, colObj1=0x2350fbb0, partId0=0, index0=1055, normalAdjustFlags=0) at /home/spark/gritengine/dependencies/bullet/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp:467
any ideas?
As usual, can you reproduce it in a Bullet demo or share a zipped .bullet file (using Bullet 2.76 this is trivial).
Otherwise, good luck with debugging the code.
Thanks,
Erwin
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
Re: New btInternalEdgeUtility has been added
The problem is that I'm using compounds containing bvh mesh data as well as other primitives. I am using this hack locally to fix this problem. I suggest you at least put in the assert and that you consider redesigning things at some point in the future to make Bullet less fragile for this kind of use case. I really think a 'bvh of primitives' is the way forward, it's much simpler, more powerful, and more robust than the current collision shape system.
Code: Select all
Index: src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp
===================================================================
--- src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp (revision 2044)
+++ src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp (working copy)
@@ -2,6 +2,7 @@
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
+#include "BulletCollision/CollisionShapes/btCompoundShape.h"
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
#include "LinearMath/btIDebugDraw.h"
@@ -456,7 +457,24 @@
if (colObj0->getCollisionShape()->getShapeType() != TRIANGLE_SHAPE_PROXYTYPE)
return;
- btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape();
+ const btCollisionShape *root = colObj0->getRootCollisionShape();
+ if (root->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) {
+ const btCompoundShape *compound = (const btCompoundShape*) root;
+ // hunt for a trimesh in the compound
+ int found = 0;
+ for (int i=0 ; i<compound->getNumChildShapes() ; ++i) {
+ const btCollisionShape *s = compound->getChildShape(i);
+ if (s->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) {
+ found++;
+ root = s;
+ }
+ }
+ assert(found==1);
+ }
+
+ assert(root->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE);
+
+ btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)root;
btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap();
if (!triangleInfoMapPtr)
return;