Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: SphereShape #724

Closed
jslee02 opened this issue May 12, 2016 · 5 comments
Closed

Proposal: SphereShape #724

jslee02 opened this issue May 12, 2016 · 5 comments
Milestone

Comments

@jslee02
Copy link
Member

jslee02 commented May 12, 2016

This might be silly (and was declined before), but I'd like to try one more time. 😓

We have used EllipsoidShape to represent sphere by setting the radii to be the same since a sphere is a special case of an ellipsoid. However, we could use the speciality of the sphere to take the advantage of cheaper collision checking algorithms for spheres from the collision detectors. We could still use ellipsoid to create sphere shape in the collision detectors when the radii are the same, but modifying the radii not to be the same would require to change the collision detector's shape to ellipsoid (and vice versa) once we have collision shape refresh feature. Still we could handle this using ellipsoid, but I imagine having SphereShape would be more straigtforward and clean in implementation.

@mxgrey
Copy link
Member

mxgrey commented May 12, 2016

From an abstraction standpoint it would seem silly for SphereShape to be its own class, independent from EllipsoidShape, but I agree that from an implementation standpoint it completely makes sense, because the machinery used to collision check an EllipsoidShape is so different from the optimized machinery that could get used for SphereShape. 👍

@psigen
Copy link
Collaborator

psigen commented May 12, 2016

I agree that this is an extremely useful special case to handle independently.

If anything, the EllipsoidShape class might do some special casing to handle itself like a SphereShape (or even internally construct a SphereShape) when radii are equal, but there are many places where we would want to semantically distinguish spheres from ellipsoids.

I guess another alternative would be a lot of boilerplate involving branching on an isSphere check on EllipsoidShape, but I don't see a huge downside to simply having another Shape.

@mxgrey
Copy link
Member

mxgrey commented May 12, 2016

I guess another alternative would be a lot of boilerplate involving branching on an isSphere check on EllipsoidShape

I think the main issue here is that we ultimately want to be able to change parameters of shapes (such as dimensionality) on the fly. For most collision detectors, we're implementing EllipsoidShape as a mesh, because most collision detectors don't have an ellipsoid primitive. So tweaking the dimensions of the EllipsoidShape would typically mean adjusting the values in some vertices. On the other hand, if the user suddenly makes the EllipsoidShape into a sphere or away from a sphere, we would have to completely change the collision information for that Shape from a mesh into a primitive, or vice-versa. This is doable, but I think it tends to involve a significant amount of overhead. In general I've noticed that adding new shapes to the collision engines tends to take a noticeable amount of time. This would probably confuse a user who expects a change from the dimensions (1, 2, 1) to (1, 1, 1) to not take much longer than a change from (1, 2, 1) to (1, 2 ,2).

@psigen
Copy link
Collaborator

psigen commented May 12, 2016

@mxgrey: Totally agree, I was only posting the alternative for completeness.

Trying to shoehorn the two shapes together would require a lot of boilerplate and add performance losses in rather strange places (since the underlying data structure would need to change when moving from an ellipsoid to a sphere and vice versa).

@mkoval
Copy link
Collaborator

mkoval commented May 12, 2016

I also agree with @mxgrey and @psigen. Combining the two shapes introduces a lot of boilerplate and (potentially) performance overhead. It makes sense to add a separate SphereShape class.

@jslee02 jslee02 added this to the DART 6.1.0 milestone Jul 20, 2016
@jslee02 jslee02 mentioned this issue Jul 20, 2016
@jslee02 jslee02 closed this as completed Aug 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants