I'm a newbie in Blender and I'm scripting in Python a routine that arranges irregular bodies according to a placement algorithm (Using AI and self-learning methods).

The problem I have so far is that when I place bodies in a systematic way, bodies could interfere (collide). The problem could be solved by using a complex contact algorithm (Contact detection) or you can make my life easier and give me a way to do it without going to the animation step.

Another perspective, is there any pre-scripted contact algorithms for irregular bodies? If so where can I find it?

  • $\begingroup$ I believe the downvotes are probably due to poor formatting on your text, that made everything appear as header text. sin four dashes ---- will create a heading $\endgroup$ – Duarte Farrajota Ramos Oct 10 '18 at 11:31
  • $\begingroup$ The first and last paragraphs makes sense but the middle one seems to contradict what you are doing in Blender. Can you use the built in Rigid Body Simulations? Do you want to detect collisions in Python either statically or with a rigid body simulation? Are you looking for a Python based collision algorithm to replicate the rigid body options? $\endgroup$ – rob Oct 10 '18 at 11:42
  • $\begingroup$ Apologies, pretty sure I'm not clear enough. I need to activate body collision during the design phase if you used Autodesk 3ds max you can find such an option to activate collision between bodies during the design phase (Static) without the animation. It will be amazing if I can find something similar. Thx mates $\endgroup$ – Mahmoud S. M. Shaqfa Oct 10 '18 at 11:52
  • $\begingroup$ I'm working on a problem that sort of (Packing problem) it's an optimization problem in the first place. I will be packing irregular bodies in a limited volume. I wanna make sure that the bodies are not interfering each other during the process. $\endgroup$ – Mahmoud S. M. Shaqfa Oct 10 '18 at 12:00

You talk about a packing problem variation and optimisation on it in you comments so I assume you want fairly fast solutions as far as runtime is concerned (what algorithms are you using for optimisation?). You best bet for packing would be to use some kind of bvh tree to do the work. Blender provides a built in implementation https://docs.blender.org/api/blender_python_api_current/mathutils.bvhtree.html that supports overlap testing which should help.

  • $\begingroup$ I'm developing currently an algorithm for that based on metaheuristic algorithms. Exactly, I need something in real-time to check the contact and find any violations for the packed bodies during the packing problem. I didn't understand yet how BVH tool will work on my code .. I will try to find some time to read about it. Many thanks $\endgroup$ – Mahmoud S. M. Shaqfa Oct 10 '18 at 21:35
  • $\begingroup$ The principle of bvh (bounding volume heirarchy) is to create a tree of simple enclosing volumes (e.g axis aligned bounding boxes) that allow fast elimination of shapes that cannot intersect so you reduce the number of complex checks that need to be done. The trouble with blenders implementation might be that you can't efficiently update as you go from python, I'm not sure. $\endgroup$ – Sazerac Oct 13 '18 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.