[v1]Scaled cylinder

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
KakCAT
Posts: 32
Joined: Mon Apr 14, 2014 2:08 pm

[v1]Scaled cylinder

Post by KakCAT »

Hi,

is is possible to have a scaled Cylinder (with different scale values in axis X and Z) so that , seen from the top, it's an oval instead of a circle, (via the Cylinder entity)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: [v1]Scaled cylinder

Post by Norbo »

While shapes do not have any form of native scaling, it is possible to wrap them in a TransformableShape and use that to apply linear transforms like nonuniform scaling.

So for example, you could do this:

Code: Select all

            var transformableShape = new TransformableShape(new CylinderShape(1, 1), Matrix3x3.CreateScale(2, 1, 1));
That will create a cylinder which is scaled up by a factor of 2 along its local x axis which can then be given to an entity.

(In v2, there's no TransformableShape equivalent planned. In both v1 and the final version of v2, a similar shape can be created using a convex hull approximation.)
KakCAT
Posts: 32
Joined: Mon Apr 14, 2014 2:08 pm

Re: [v1]Scaled cylinder

Post by KakCAT »

thanks for such a fast answer! I'll be porting to v2 as soon as it's stable and gets a character controller, so the v2 bit is important.

I use that cylinder (and other shapes) for triggering, so I could use DetectorVolume instead. Is DetectorVolume (or something similar) being "ported" to v2?

I've been reluctant to use it because I've though that using a box collider instead of a triangle mesh should be faster (and because constructing it may lead to errors building the triangle mesh, while Cylinder is a basic entity), but if it's going to be in v2 (and not the TransformableShape as you said) I'd rather write code that will be reused for v2.

Or should the convex hull you suggested before be faster than the DetectorVolume?

thanks!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: [v1]Scaled cylinder

Post by Norbo »

A primitive box will indeed be much faster than a DetectorVolume. At the same level of detail, a convex hull will also tend to massively outperform mesh based implementations like the DetectorVolume, and I don't plan to bring a DetectorVolume equivalent to v2. (There will be collidable meshes, of course, just not with the specific DetectorVolume style "contained" vs "touching" vs "separated" features.)
KakCAT
Posts: 32
Joined: Mon Apr 14, 2014 2:08 pm

Re: [v1]Scaled cylinder

Post by KakCAT »

Thanks, I'm using a convex hull for the cylinder now, it works and will be more portable to v2 :)
Ekstrom
Posts: 1
Joined: Sat Sep 01, 2018 8:43 am

Re: [v1]Scaled cylinder

Post by Ekstrom »

Out of curiosity, could you use anything else besides the convex hull for the cylinder and get a similar result?
This top notch D-Bal Max review is worth reading.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: [v1]Scaled cylinder

Post by Norbo »

If the goal is a nonuniformly scaled cylinder with ellipsoid caps, not really.

In v1, the full set of options is:
1) TransformableShape wrapping CylinderShape
2) ConvexHullShape approximation
3) Mesh approximation
4) Custom dedicated shape type

#1 is dropped in v2, #3 is way more expensive than #2, and #4 is a lot of work, especially in v2.
Post Reply