Inheriting Constraints...

Oct 11, 2010 at 6:29 AM

In order to properly inherit a constraint (so you can make a new one), some variables need to have protected accessibility, if only for reading:

  • Mass
  • World
  • InverseWorld
  • MassWorld
  • Probably more...

I can throw in protected getters for these values, but I am trying to make it as easy as possible for me to integrate new versions of Henge3D.

What do you think?

Coordinator
Oct 13, 2010 at 2:27 AM

I don't have a strong preference on which way to expose these; either protected or public would be fine I think. Normally I'd use a property getter with an internal setter, but I'm concerned about the fact that the CF framework doesn't inline short functions, making property calls much more expensive than they need to be.

My inclination would be to just make those fields public.

Oct 13, 2010 at 5:55 PM

As I tell my students: always use the most restrictive accessibility you can.

In this case, making many of those fields public would probably confuse a user more than help them, since average folk don't need them in the majority of cases.  I would recommend making such fields protected in your next release.  If a user is inheriting parts of the physics engine, they probably have a decent clue about what they're doing.  Of course, be sure to include HTML comments on anything that is not private :-).

Cheers.

Coordinator
Oct 13, 2010 at 7:52 PM

Unfortunately, many best practices have to go out the window when dealing with CF. The problem with making it protected is that the engine won't be able to access those fields directly, which it needs to do. So public is really the only option in some cases.