btRigidBody::upcast() is a downcast?

B_old
Posts: 79
Joined: Tue Sep 26, 2006 1:10 pm

btRigidBody::upcast() is a downcast?

Post by B_old »

Hi everybody,

I'm currently a bit confused by the name of the btRigidBody::upcast() method. We are casting from btCollisionObject to btRigidBody, which is derived from btCollisionObject, so we are moving down the class-hierarchy.
Or am I getting something wrong here?
robagar
Posts: 48
Joined: Fri May 21, 2010 1:49 am

Re: btRigidBody::upcast() is a downcast?

Post by robagar »

yup, it's the wrong way round. But it kind of makes sense as opposed to going "up" towards the "base" :?
B_old
Posts: 79
Joined: Tue Sep 26, 2006 1:10 pm

Re: btRigidBody::upcast() is a downcast?

Post by B_old »

robagar wrote:But it kind of makes sense as opposed to going "up" towards the "base" :?
I agree, that this can sound confusing at first. But once you are used to viewing and calling it this way, it is even more confusing to encounter stuff that does it the other way round.
What is the intention behind this naming-choice?
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: btRigidBody::upcast() is a downcast?

Post by Flix »

I'm not a C++ expert at all, but I've always thought that "upast" is the cast that goes up in the hierarchy (more derived classes).
B_old
Posts: 79
Joined: Tue Sep 26, 2006 1:10 pm

Re: btRigidBody::upcast() is a downcast?

Post by B_old »

Well, upcasting doesn't have to do with c++ in particular I suppose. I assumed you move upwards the hierarchy in the sense of an UML-diagram for instance ("less" derived class).
http://www.c-sharpcorner.com/UploadFile ... sting.aspx

Maybe there are two different standards as to what means what, although that would be awkward.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btRigidBody::upcast() is a downcast?

Post by Erwin Coumans »

My bad, the name is wrong indeed, it should be a downcast.

Best not to break the API for this, we can put a warning there and fix it for a Bullet 3.x release.
Thanks!
Erwin
B_old
Posts: 79
Joined: Tue Sep 26, 2006 1:10 pm

Re: btRigidBody::upcast() is a downcast?

Post by B_old »

OK, thanks for clearing it up.