From: <ah...@un...> - 2009-11-13 03:20:28
|
Hi, > Sorry, would you please present an example of required diamond > inheritance? class Top {}; class Fork : public Top {}; class LeftBranch : public Fork {}; class RightBranch : public Fork {}; class Bottom : public LeftBranch, public RightBranch {}; In this case, Bottom is derived from Fork twice, once via LeftBranch and once via RightBranch. This works in C++. However, when you write: Top* instance = new Bottom(); You get a compiler error because Top is an ambigious base class of Bottom. Simspark wants to do something like zeitgeist::Object* = new Body(); and you get the same error at this point. You should be able to reproduce it by deriving BoxCollider from both Collider and ODEObject in the current version. It's nonsense, but it leads to ODEObject and everything above it being ambigious base classes of BoxCollider. > I wonder why abstract physics classes should be derived > from BaseNode. In order to add an instance of a class to the scenegraph, it has to be derived from BaseNode. That's written in the documentation at some point. This doesn't mean that the abstract classes have to be derived from there, though. I tried an approach that derives the non-abstract classes from BaseNode in a seperate tree and keeps the abstract classes as interfaces and pointer-providers that aren't derived from anything. This, however, gets very ugly because patterns like boost::shared_ptr<Body> body = [...]; [...] body->GetSelf() [...] can be found in many places outside of oxygen. GetSelf is specified in zeitgeist, so if the inheritance from Body to BaseNode is cut, GetSelf isn't known to Body anymore. Figuring out a design that derives Body from BaseNode is by far the easiest solution to that problem. I hope this answers your questions. |