Open Boyan-In-Christ opened 5 years ago
Dear Ali,
Thank you so much for your quick reply. But for some reasons I also need to make several polygons be contained in a big polygon. Does it possible by using polygon type?
Thank you so much!
Could you try using polygons instead?
As far as I know edge/chair work with static bodies (like ground), so not useful for this case.
As far as I know if your container is dynamic this is the common solution: http://piqnt.com/planck.js/Tumbler
Thank you so much Ali, this helped a lot. it is now much better. I referenced http://piqnt.com/planck.js/Tumbler also http://piqnt.com/planck.js/Mixer Both "polygon" or "edge" seems could work as the element of building the bounding box for lots of objects. I did two implementations. The first one still have some intersections. The second one seems like what you mentioned before. One more question: When I use the first implementation how to avoid intersections? Can I set some repelling force on the body, so that when such attachments exist, the body can be separated? Each body can keep some distance from other bodies? Thank you so much!!
Could you share your testbed on codepen/jsbin?
Dear Ali, I made a codepen, here is the link: https://codepen.io/bozheng-stokes/pen/abormNX There can be intersections somehow. You could also change "box" to "edge", by change var use_box = true; var use_edge = false; to var use_box = false; var use_edge = true;
Thank you very much for your advice on this.
Could you try setting walls as bullet?
~Bullet didn't fix it, but I was able to fix it with this:~
let distance_joint_setting = {
frequencyHz: 0.4,
dampingRatio: 0.01
};
Great example by the way, thanks for sharing it! I will add it to list of projects made with planck.js, if you don't mind?
Dear Ali, thank you for your time on this. This parameters are very tricky...is there any best practices? I don't mind you use this code. But I used the code of computing convex Hull from others. Maybe it is better to change it to boxes instead of convex hulls. If you don't mind, I have one more question from my side. Seems the settings of parameters are quite tricky. If I change the density of the fixture or parameters of the simulation the result can be different. Intersection can still be there. Can this be solved? Is it because of collision computation? I saw a open source project
https://github.com/Sinova/Collisions/blob/master/README.md#anchor-demos
Can this be integrated into Planck.js? Thanks again and nice weekend!
Actually my first suggestion (setting bullet: true for walls) was correct. I was setting that for other bodies by mistake. Please ignore my other suggestion.
Just change line 181 to var body = world.createDynamicBody({ bullet: true });
.
That's a very interesting open-source project, but I'm just maintaining planck.js right now.
Thank you very much Ali. It indeed works. But actually these objects are not at a high speed, why they still can cause intersections? Also the computational cost of setting them to bullets is really high. When I set objects' bullet to true, the computation time seems exponentially increased according to the number of the bullet objects. How is the difficulty of solving this in planck.js? Many Thanks again!!
You may also be able to fix it by adjusting planck.internal.Settings
variables. But I don't know much more.
Also I recommend discussing this with Box2D community as well, Planck.js is based on Box2D.
Dear Ali, first thank you for this simple and powerful library you have developed. I am using it in my research. And I met a problem. when I try to make packed convex hulls. These hulls I used connected "edge" shape. The code is like this:
when I use DistanceJoint to drew these "convex hull" body together, After the simulation, it results these intersections. The setting of DistanceJoint I used is:
The simulation setting is:
When I change this convex hulls into "chain" type, seems the result it the same. Do you have any idea about this? Do these settings influence the result? How to avoid intersections? Many thanks!!