From 0d44402fbe3962605a891b4e635dd3bc2209febc Mon Sep 17 00:00:00 2001 From: Inge Wallin Date: Fri, 19 Dec 2014 23:46:37 +0100 Subject: [PATCH] Make Body inherit Item Previously Body was a root class and all subclasses of Body inherited both Item and Body. This seemed strange. --- stepcore/CLASSES | 23 ++++++++++++----------- stepcore/body.h | 16 ++++++---------- stepcore/particle.h | 2 +- stepcore/rigidbody.h | 4 ++-- stepcore_tests/worldcopy.cc | 3 +-- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/stepcore/CLASSES b/stepcore/CLASSES index 220bace..3d53213 100644 --- a/stepcore/CLASSES +++ b/stepcore/CLASSES @@ -30,7 +30,7 @@ Legend * GslSolver * GslAdaptiveSolver - * Item{world.h} Root class for world items (bodies, forces) + * Item{item.h} Root class for world items (bodies, forces) [world, group, objectErrors, color] * NoteImage Image embedded in a Note @@ -42,17 +42,18 @@ Legend * World The root object for everything visible [time, timeScale, bodies, forces, joints, solvers...] -* Body{world.h} Anything that has dynamic variables that + * Body{body.h} Anything that has dynamic variables that require ODE integration - * Particle(Item, Body) - * ChargedParticle - * GasParticle - * RigidBody(Item, Body) - * Disk - * BasePolygon - * Box - * Polygon - * Plane(Item, Body) Unmovable rigid plane + * Particle(Item, Body) + * ChargedParticle + * GasParticle + * RigidBody(Item, Body) + * Disk + * BasePolygon + * Box + * Polygon + * Plane(Item, Body) Unmovable rigid plane + * Force{world.h} Anything that acts upon bodies changing derivatives of dynamic variables diff --git a/stepcore/body.h b/stepcore/body.h index ea1c1a0..1212643 100644 --- a/stepcore/body.h +++ b/stepcore/body.h @@ -28,31 +28,27 @@ #include // XXX: Replace if Qt is enabled. #include "types.h" -#include "object.h" +#include "item.h" namespace StepCore { -//class World; -//class Solver; -//class Item; -//class ItemGroup; -//class CollisionSolver; -//class ConstraintSolver; - /** \ingroup bodies * \brief Interface for bodies * * Body is anything that has dynamic variables that require ODE integration */ -class Body +class Body : public Item { STEPCORE_OBJECT(Body) public: - Body(): _variablesOffset(0) {} + Body(const QString& name = QString()) + : Item(name) + , _variablesOffset(0) + {} virtual ~Body() {} /** Get count of dynamic variables (not including velocities) */ diff --git a/stepcore/particle.h b/stepcore/particle.h index b9de3af..595a675 100644 --- a/stepcore/particle.h +++ b/stepcore/particle.h @@ -100,7 +100,7 @@ protected: /** \ingroup bodies * \brief Particle with mass */ -class Particle: public Item, public Body +class Particle: public Body { STEPCORE_OBJECT(Particle) diff --git a/stepcore/rigidbody.h b/stepcore/rigidbody.h index aff2488..26edd27 100644 --- a/stepcore/rigidbody.h +++ b/stepcore/rigidbody.h @@ -141,7 +141,7 @@ protected: /** \ingroup bodies * \brief Rigid body */ -class RigidBody: public Item, public Body +class RigidBody: public Body { STEPCORE_OBJECT(RigidBody) @@ -358,7 +358,7 @@ public: /** \ingroup bodies * \brief Unmovable rigid plane */ -class Plane: public Item, public Body +class Plane: public Body { STEPCORE_OBJECT(Plane) diff --git a/stepcore_tests/worldcopy.cc b/stepcore_tests/worldcopy.cc index e3fc5ca..c015ae2 100644 --- a/stepcore_tests/worldcopy.cc +++ b/stepcore_tests/worldcopy.cc @@ -21,8 +21,7 @@ #include #include -class WorldCopyTestItem: public StepCore::Item, - public StepCore::Body, +class WorldCopyTestItem: public StepCore::Body, public StepCore::Force { STEPCORE_OBJECT(WorldCopyTestItem) -- GitLab