[ODE] C++

Russ Smith russ at q12.org
Sun Nov 4 18:49:01 MST 2001


Colin Reed wrote:
> A problem that I am having is that even though a C++
> interface is provided, because the internals of the engine are still
> C you are missing out on a whole load of benefits from a true C++
> system.

hi,

the external C++ interface is a very thin wrapper on top of the C API.
it doesn't get you any additional functionality or ease of use, and
i don't use it myself. what problems are you having??

ODE itself needs a C++ compiler right now, as some C++ features are
used internally for convenience. however ODE's class hierarchy is quite
shallow and would not really benefit from full scale object
orientation. the obvious place where OOP techniques could be used are
for the collision geometry objects, and the joint objects. however in
both cases C++ is actually more limiting that useful:
  * joint objects are harder to place into easily traversable joint
    groups, because the C++ new() arena allocation scheme makes no
    guarantees about how the object is placed into the arena slot.
  * virtual functions on geometry objects: for N geometry classes there
    are O(n^2) object-object collision handling functions. there is
    no clear way to associate these functions with a particular class.
  * class identification by vtable pointer would need C++ RTTI,
    which has a runtime overhead, not to mention it would require C++
    linkage in the host application.
  * if exception handling, RTTI or global objects are used then ODE
    would require C++ linkage in the host application, and future
    binary compatibility would be lost.
  * the end result: excessive use of C++ would incur a space penalty
    if binary compatibility in to be maintained.

the core ODE interface itself should remain in C, as C++ interface
design is always a more contentious subject because there are *so* many
more choices (overload functions? operators? STL-like? class
hierarchies? namespaces? templates??). a C interface is:
  * cleaner - people are more able to agree what is "good".
  * binary compatable between compilers (e.g. for a shared lib).
    C++ libs compiled for VC++ are useless for GCC, etc.

> Are there any plans to convert to true C++?

only if there is a demonstratable benefit. at this stage, i don't
think there is.

russ.

--
Russell Smith
http://www.q12.org




More information about the ODE mailing list