godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.2k stars 20.22k forks source link

Error 3D physics, violation collision mesh RigidBody and other body #4831

Closed DimitriyPS closed 5 years ago

DimitriyPS commented 8 years ago

Linux Mint 17.3 Cinnamon, Godot 2.0.3

Error 3D physics, violation collision mesh RigidBody and other body

I was faced with a problem: the failure of border collision meshes. This leads to the fact that the objects with the body of type RigidBody falls through other objects.

I tried to upload a collision mesh from Blender (-colonly) and created it in the Godot link Unloaded from the Blender collision meshes don't work at all, collision meshes created in Godot are working with an error.

Maybe I did something wrong. So I asked council: link Apparently nobody knows how to fix this error.

I experimented and found a compromise solution. I have not uploaded a collision mesh from Blender and created in Godot: "BoxShape", "CapsuleShape", etc. It reduces the symptoms error of physics. It is obvious that it is often not acceptable. This approach does not allow to fully develop a game with modern graphics.

Additionally I have studied third-party example link. And it turned out that there is also a problem with physics. Possible using a weapon to throw the enemy outside the game cards (for this purpose it is necessary to pinch in the corner and intensively to attack). Also using mines and being against the wall you can throw the player outside the playing card (game character).

Summing up, I think it's a problem in the physics engine. I think this is a very serious problem when creating a 3D game with interactive space.

slapin commented 8 years ago

-colonly produce static collision/ Please provide more detail on your exact scene setup. 3D collisions are done using SAT algorithm, which requires all collisions between all shapes explicitly specified to calculate penetration depth. So you have to be careful with your shapes and bodies.

slapin commented 8 years ago

Also I encountered various bugs with trimesh (concave) vs anything when shape is complex, but these are usually can be fixed enabling collision debugging and looking into the collision results. Also myself I did not have any collision problems with latest Godot (master) as I use simple shapes for my RigidBody and complex shapes for StaticBody. Also remember you can have many simple shapes for RigidBody. Also you can't scale them and can't put shapes into subscene without proper code handling this (these will not be added automatically). So the solution is to use simpe shapes (I usually use Sphere for bottom and Box for the rest of the body). Also in Godot collision shapes are not animatable, so you can't change configuration on the run. So if you have your character in various very different poses (walking/standing, sitting on chair, laying on bed) you will need separate RigidBody setups for each pose/state. Modifying shape transform matrices on the run is possible, but leads to unpredictable results due to physics engine calculations based on these, also the sizes of bodies should not be modified on the run. So if you want to have changes - have multiple bodies and switch them. You can generate the setup in code, just don't modify active ones. Deleting and creating of RigidBody is ok.

DimitriyPS commented 8 years ago

I accidentally pressed the wrong button. Not intentionally has closed the "bug report". Here is a minimal example: test.zip

I put a translucent texture on terrain, what would you see as the pallets pass through terrain.

Attention! In this example, the generated CollisionShape can be replaced by a simple "BoxShape". But it is only in this example. When creating the real game we are working with complex forms and this approach is unacceptable.

slapin commented 8 years ago

I deleted your CollisionShape from landscape and generated one anew from editor menu. Now pallets do not drop through. Analysing 2 meshes, yours and the one generated by Godot I see that Godot one is more dense, also its topology is closer to the original mesh topology. Probably you will want to change your collision generator algorithm, if you generate it yourself or analyse why Godot generates different trimesh collision for you, if you use importer to generate collision..

slapin commented 8 years ago

Enable collision debugging and see for yourself.

DimitriyPS commented 8 years ago

I deleted your CollisionShape from landscape and generated one anew from editor menu.

I did it...didn't work. Video the replacing CollisionMesh

Analysing 2 meshes

How to analyze them? The original mesh was unloaded from Blender 3D (-colonly).

Probably you will want to change your collision generator algorithm, if you generate it yourself or analyse why Godot generates different trimesh collision for you, if you use importer to generate collision..

I didn't plan to study the device physics engine. I was planning to use standard methods of generating geometry (including CollisionMesh)... as well as the physics. This was completely unexpected problem. It still keeps me from further developing my project.

Additional information. I previously wrote:

Additionally I have studied third-party example link. And it turned out that there is also a problem with physics. Possible using a weapon to throw the enemy outside the game cards (for this purpose it is necessary to pinch in the corner and intensively to attack). Also using mines and being against the wall you can throw the player outside the playing card (game character).

Here's a video for clarity: Link

Vidio is clearly seen as an intense attack I pushed 2 drone outside locations. So a problem with physics not just me.

DimitriyPS commented 8 years ago

I have no significant experience working in different Game IDE. But I do know that BGE doesn't make mistakes of the physics engine.

I think it is not correct that when you use declared (documented) methods of generating CollisionMesh - an error may occur.

slapin commented 8 years ago

Well, I can't watch your video. I just deleted collision shape from terrain scene, selected "landscape lod0" and used Mesh/Create trimesh static body. I think you generated wrong mesh (wrong geometry) so it messed-up collision. Try to compare mesh generated with Godot with yours. The algorithm is quite direct.

DimitriyPS commented 8 years ago

I just deleted collision shape from terrain scene, selected "landscape lod0" and used Mesh/Create trimesh static body.

I just repeated exactly these operations. It doesn't work. Before that (in the video) I did a little bit wrong, I did "Create trimesh collision sibling". I can send mesh in Blender 3D if that helps. All normals are look in the same direction, no duplicate vertices.

DimitriyPS commented 8 years ago

Here's the grid: test.blend.zip Export to Godot was produced "Better Collada Exporter for Blender"

slapin commented 8 years ago

Which version of engine do you use? I use git master.

DimitriyPS commented 8 years ago

Which version of engine do you use?

As I wrote in the first post: 2.0.3 - stable release. "Better Collada Exporter" - update along with the Godot.

I use git master.

This is the version "nightly build"? Between 2.0.3 and "git master" modification physics?

slapin, I'm not trying to say that in Godot the physics algorithms are bad. I'm not an expert in this field. I study the information from the documentation. Or turn to the community for advice. I try to do everything right... but the result is negative.

I really like the Godot. I study Godot and in parallel, developing my 3D game. I was going to fill the game world with things they possible player interaction. But now it is completely pointless. Things just fall through the floor. I did everything in accordance with the documentation. I tried to ask for advice from the community. But things still fall through the floor. I think it's not right.

I am ready to provide any materials: an example Godot project, 3D mesh, screenshots, videos, profile hardware. If I'm doing something wrong, I want to understand what I'm doing wrong. And then probably need to correct/supplement the documentation. If this is a problem in the code Godot, I want to help (than I can) that would fix it.

slapin commented 8 years ago

Well, I don't have issues like yours. Probably @reduz can help here, but I simply replace your collision with one generated in Godot editor and it works. I really understand your pain as I came through it all myself and as 3D is not really widely used by Godot community it is area where it is hard to get community answers. For your particular setup I see no problem when I delete your collision for terrain and replace with one generated in Godot editor. Anyway, on the wild goose chase, have you tried replace your pallet collision with a box? Does it improve anything for you? And if you generate both terrain as trimesh static body and box for a pallet, does it work better for you?

DimitriyPS commented 8 years ago

I spent a lot of experiments. I've shifted the center of the model, simplified/complicated meshes. The only way to guarantee that objects will not fall through through the floor:

  1. StaticBody - CollisionShape => Shape => NOT ConcavePolygonShape;
  2. RigidBody - CollisionShape => Shape => NOT ConcavePolygonShape.

If StaticBody or RigidBody "ConcavePolygonShape" then they start to sink through the floor.

But do not use "ConcavePolygonShape" - means to not use actual graphics complex shapes.

DimitriyPS commented 8 years ago

Let me submit an inquiry. If possible please include this bug in release 2.1 Godot. Honestly, I don't know difficult fix or not and how much it will take time. But if possible, please correct it before the release Godot 2.1.

I'm developing a 3D game in Godot 2.0.3. I created items in the game, created containers, created an inventory interface to the player... in short, I have created a basic system of play things and everything connected with it. I would like to show techno-demo a certain circle of people, but presently it's not possible.

bojidar-bg commented 8 years ago

I haven't read the whole conversation, but is this a duplicate of #4591? (Edit: or #4159)

DimitriyPS commented 8 years ago

I haven't read the whole conversation, but is this a duplicate of #4591? (Edit: or #4159)

I can't be absolutely sure, but my problem is similar to: #4591

DimitriyPS commented 8 years ago

I understand the solution of this bug was sent to the 3.0 version. This is due to the reconstruction of the 3D engine?

Now we are all waiting for the intermediate version 2.1. How much is planned versions between from 2.1 before 3.0? How to plan it will take time?

I don't want to offend anyone, don't get me wrong. I occasionally encounter problems in Godot. I write a bug report and say to myself, "everything is fine, while it is necessary to suffer". But this error of physics is much more serious. She makes Godot unsuitable for development a full-fledged 3D games. My game is not ready, but I'm planning to present the accumulated material to certain groups of people. It is very inconvenient to explain to people: "Yes, the inventory falling through the floor... but wait... a year or two... and they will stop falling through the floor...". It spoils all impression from the demo.

Please, if possible, to expedite the fix for this problem.

kubecz3k commented 7 years ago

@DimitriyPS Can you recheck if it's still present in current main?

DimitriyPS commented 7 years ago

In Godot 2.1.3-stabile is a very (!) actual! Godot 3.0-alpha I haven't used.

Demo project: https://github.com/godotengine/godot/issues/4831#issuecomment-222228978

kubecz3k commented 7 years ago

possibly related to https://github.com/godotengine/godot/issues/9954

DimitriyPS commented 6 years ago

I tested the problem in Godot 3.

With the default settings, the problem is manifest. Especially if the subject is small. The solution can be an increase in the frequency of physics:

000

This decision raises concerns for performance.

slapin commented 6 years ago

for small an/or fast object this is usually solved by CCD. I don't know if Godot3 can enable it. This is still can consume quite a few of CPU cycles, but better than increasing number of physics steps.

On Fri, Jun 22, 2018 at 11:43 AM, DimitriyPS notifications@github.com wrote:

I tested the problem in Godot 3.

With the default settings, the problem is manifest. Especially if the subject is small. The solution can be an increase in the frequency of physics:

[image: 000] https://user-images.githubusercontent.com/11189223/41767045-4c589856-7611-11e8-8bdb-e483c9140fd0.png

This decision raises concerns for performance.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/4831#issuecomment-399369030, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAX0_2G_VsNFs9bHgYYSMVlJsMUmfhrks5t_K5MgaJpZM4IoCSJ .

DimitriyPS commented 6 years ago

default

I didn't notice any change. The object flies through the floor like the floor not there.

DimitriyPS commented 6 years ago

Additionally: I found that KinematicBody behaves even less stable than StaticBody. When a 3D character stands on an object (KinematicBody), he is constantly in it partially immersed and pushed back - so infinitely "pulsates".

If possible, I want to know about plans to improve works the physical engine.

slapin commented 6 years ago

I think it would be great if you would provide minimal scene set up to see this. I use new godot master for a while now and did not see this so there must be some catch in here.

On Mon, Jul 16, 2018 at 11:50 AM, DimitriyPS notifications@github.com wrote:

Additionally: I found that KinematicBody behaves even less stable than StaticBody. When a 3D character stands on an object (KinematicBody), he is constantly in it partially immersed and pushed back - so infinitely "pulsates".

If possible, I want to know about plans to improve works the physical engine.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/4831#issuecomment-405183126, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAX03_15JRPFWA0amEMLY2NKsGBOJm3ks5uHFO_gaJpZM4IoCSJ .

DimitriyPS commented 6 years ago

Yes you are right. I thought about it myself. But the project is a bit "overgrown", subtract the minimal scene several difficult.

If I record video and show the topology of the scenes, will it help?

slapin commented 6 years ago

The best way would be if you could just set up with Godot primitives. My project is complicated enough too, but when I encounter a problem I first try to make separate project and set up with minimal system possible. I increase complexity step by step until I find the problem reproducible, this way I can isolate the problem and find where this might happen. Messing with complex setups is always hard when you try to find what is actually wrong.

On Mon, Jul 16, 2018 at 4:46 PM, DimitriyPS notifications@github.com wrote:

Yes you are right. I thought about it myself. But the project is a bit "overgrown", subtract the minimal scene several difficult.

If I record video and show the topology of the scenes, will it help?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/4831#issuecomment-405252309, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAX0wHMX-jfu-XC2990cHiV4MnHPT65ks5uHJkcgaJpZM4IoCSJ .

DimitriyPS commented 6 years ago

I'll prepare a minimal demo. It's gonna take some time.

DimitriyPS commented 5 years ago

I've been struggling with this problem since the day I started working at Godot. This issue has been and versions 3.0.X. Don't know what was done... but in 3.1.1 everything works as it should!!!

I'm not superstitious... but I'm afraid to jinx it... nevertheless can be close! Hope this problem doesn't come back!!!