engine icon indicating copy to clipboard operation
engine copied to clipboard

Collision Component Update-Renderer Collision for built-in primitives

Open ASoldo opened this issue 5 years ago • 11 comments

Hi, I'm proposing this feature that will enable us to use built-in primitives and wire them in collision component.

Description

I was trying to add plane primitive to my scene, after that I did add collision and rigidbody to it. Since it is a built in primitive when I choose Mesh option on Collision i need to slot mesh, but I don't have plane mesh in my project and therefore it is not usable. I was forced to use Box Collision and set Y=0.1 and I would like to avoid that.

Feature:

Add extra option in Collision component: Renderer: Slot object/entity that has renderer and use its render mesh as a collision shape. This way, whenever we scale our plane renderer collision shape will also update.

Here is my original problem that I have posted on PC Forum -> https://forum.playcanvas.com/t/plane-collision-setup/23157

Thank you and I hope this can be simple/easy update.

ASoldo avatar Dec 01 '21 09:12 ASoldo

I'm just wondering if you had some problems with using box collider here? Or what reason have you had to not use it. It seems like a pretty easy workaround, that possibly even has performance benefits inside the physics engine, as those base shapes are usually faster than mesh colliders.

mvaligursky avatar Dec 01 '21 09:12 mvaligursky

AFAIK, the physics engine were are using Bullet/Ammo.js doesn't support a bounded plane for collision which is why we don't have it in PlayCanvas. As Martin says, using a thin box would be more performant than using a mesh that represents a plane.

yaustar avatar Dec 01 '21 09:12 yaustar

My problem was when I tried to create a ground/plane for my vehicle to drive on. Desert mesh that is provided in Vehicle demo works perfectly, but then I wanted to create plane/flat surface (no models) and drive on that. Later I did model my own plane in Blender and I had another issue. When I scale my plane collision shape is still that 1x1 original. Problem is that when we use Box Collision we have to do everything manually.

I understand that if i put heavy asset that operations will be slow.

ASoldo avatar Dec 01 '21 10:12 ASoldo

Right, having a fit model option on the collider would be of great help, especially when using box colliders.

leonidaspir avatar Dec 01 '21 10:12 leonidaspir

Yes, exactly!

ASoldo avatar Dec 01 '21 10:12 ASoldo

Is the actual feature request to make it easier to fit a bounding shape to the model rather than using a mesh?

yaustar avatar Dec 01 '21 10:12 yaustar

Personally I would like to have it both, with disclaimer that using heavy assets will result in slow collision detection. But some sort of "here is this primitive mesh that has 2 triangles and 6 verts use this" option. Since it will be used for walls, tilable elements etc. And option to bound shape to model with offset would be great. so for example if we have plane we can set it collider to y=0.1 and also offset y=0.1 so we push collider downward so it matches the plane.

ASoldo avatar Dec 01 '21 10:12 ASoldo

The plane primitive is not going to be possible because it is not supported by the physics engine we use.

It's not the number of verts/polys that is the issue, its about the algorithms that are used detect collisions between primitives is much simpler. A bounded plane is effectively a thin box.

Any mesh collision is going to be more expensive with the cost going up with the poly count.

And option to bound shape to model with offset would be great

Offset is currently a feature request in a separate issue.

yaustar avatar Dec 01 '21 10:12 yaustar

It’s amazing offset isn’t in yet 🤷

On Wed, 1 Dec 2021 at 10:28, Steven @.***> wrote:

The plane primitive is not going to be possible because it is not supported by the physics engine we use.

It's not the number of verts/polys that is the issue, its about the algorithms that are used detect collisions between primitives is much simpler. A bounded plane is effectively a thin box.

And option to bound shape to model with offset would be great

Offset is currently a feature request in a separate issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/playcanvas/engine/issues/3758#issuecomment-983501186, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHPETZAD2DCQFMGL5SDYUTUOX2FTANCNFSM5JEAIUTA .

malDuffin avatar Dec 01 '21 14:12 malDuffin

"Fit model" for collision shape, will not work in cases where any of the ancestors are scaled with a non-uniform scale.

Maksims avatar Dec 01 '21 17:12 Maksims

Please don't close issues unless PR is merged.

mvaligursky avatar Mar 05 '26 14:03 mvaligursky