Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Simulator Class Reference

#include <Simulator.h>

Inheritance diagram for Simulator:

World IunctusSimulator PacSimulator SpherusSimulator List of all members.

Public Member Functions

Public Attributes

Protected Member Functions

Protected Attributes

Private Member Functions

Private Attributes


Detailed Description

The main class of the Thyrix simulator.

Definition at line 13 of file Simulator.h.


Constructor & Destructor Documentation

Simulator::Simulator  ) 
 

Definition at line 9 of file Simulator.cpp.

References contacts, contactSolver, dtDefault, isContact, and realTime.

Simulator::~Simulator  )  [virtual]
 

Definition at line 23 of file Simulator.cpp.

References deleteObjects().


Member Function Documentation

void Simulator::advanceTime  )  [virtual]
 

Performs a timestep. It needs to be virtual because of the use of abstract Simulator classes in GUI-related base classes. This method may be overridden to include fitness computing, agent tracking etc.

Implements World.

Definition at line 51 of file Simulator.cpp.

References applyMouseForce(), ContactSolver::computeContacts(), contacts, contactSolver, controll(), deleteContacts(), detectContacts(), fillContactMatrix(), Integrator::getDt(), indexContacts(), integrator, isContact, objects, realTime, and ContactSolver::uploadForces().

void Simulator::applyMouseForce  ) 
 

Adds the mouse force to the external forces (and torques) of the object dragged with the mouse.

Definition at line 262 of file Simulator.cpp.

References PhysicalObject::alpha, draggedObject, PhysicalObject::externalForce, PhysicalObject::externalTorque, PhysicalObject::r, Vector2::rotate(), Vector2::x, and Vector2::y.

Referenced by advanceTime().

void Simulator::computeContacts  ) 
 

Definition at line 225 of file Simulator.cpp.

References ContactSolver::computeContacts(), and contactSolver.

void Simulator::controll  )  [protected, virtual]
 

Definition at line 45 of file Simulator.cpp.

References PhysicalObject::controll(), and objects.

Referenced by advanceTime().

void Simulator::deleteContacts  )  [private]
 

Deletes all previous contact information: the global vector of contacts, and the contacts of all objects.

Definition at line 229 of file Simulator.cpp.

References contacts, and objects.

Referenced by advanceTime().

void Simulator::deleteObjects  )  [private]
 

Deletes the object list and the included objects.

Definition at line 41 of file Simulator.cpp.

References objects, and purgeContainer().

Referenced by ~Simulator().

void Simulator::detectContacts  )  [virtual]
 

Reimplemented in IunctusSimulator.

Definition at line 135 of file Simulator.cpp.

References contacts, PhysicalObject::detectContacts(), Simulator::ObjectPair::o1, sortedObjects, sortObjects(), xContacts, and xyContacts.

Referenced by advanceTime(), IunctusSimulator::detectContacts(), and ComposedPhysicalObject::detectContacts().

void Simulator::draw GUI gui  )  [virtual]
 

Reimplemented from World.

Definition at line 279 of file Simulator.cpp.

References World::draw(), objects, and GUI::setBrushColor().

void Simulator::fillContactMatrix  ) 
 

Computes the matrix used for contact force computation.

Definition at line 212 of file Simulator.cpp.

References contacts, and contactSolver.

Referenced by advanceTime().

virtual double Simulator::getDt  )  const [inline, virtual]
 

Reimplemented from World.

Definition at line 18 of file Simulator.h.

References Integrator::getDt(), and integrator.

void Simulator::indexContacts  ) 
 

Indexes the contacts, resets to zero the contact data structures, allocates memory for them if needed.

Definition at line 198 of file Simulator.cpp.

References PhysicalObject::alpha, contacts, contactSolver, and ContactSolver::init().

Referenced by advanceTime().

virtual void Simulator::onMouseLeftDown float  x,
float  y
[inline, virtual]
 

Reimplemented from World.

Definition at line 61 of file Simulator.h.

References World::onMouseLeftDown(), and setMouseForce().

virtual void Simulator::onMouseLeftUp float  x,
float  y
[inline, virtual]
 

Reimplemented from World.

Definition at line 66 of file Simulator.h.

References World::onMouseLeftUp(), and unsetMouseForce().

void Simulator::registerObject PhysicalObject object  ) 
 

Adds the object to the objects array.

Definition at line 30 of file Simulator.cpp.

References objects, PhysicalObject::registerPrimitives(), and sortedObjects.

Referenced by IunctusSimulator::IunctusSimulator(), PacSimulator::PacSimulator(), and SpherusSimulator::SpherusSimulator().

void Simulator::registerPrimitive PhysicalObject object  ) 
 

Adds the object to the primitives array.

Definition at line 37 of file Simulator.cpp.

References primitives.

Referenced by PhysicalObject::registerPrimitives(), Elastoid::registerPrimitives(), and ComposedPhysicalObject::registerPrimitives().

void Simulator::setMouseForce float  x,
float  y
 

Definition at line 236 of file Simulator.cpp.

References draggedObject, draggingPoint, and objects.

Referenced by onMouseLeftDown().

void Simulator::setup  )  [inline]
 

Needs to be called after all objects were registered by the simulator, if we use box sorting for broad phase contact detection.

Definition at line 33 of file Simulator.h.

void Simulator::sortObjects int  n  )  [private]
 

Sorts the n=0,1 list of sorted objects, with insertion sort.

Definition at line 173 of file Simulator.cpp.

References PhysicalObject::boxMin, and sortedObjects.

Referenced by detectContacts().

void Simulator::unsetMouseForce  ) 
 

Definition at line 252 of file Simulator.cpp.

References draggedObject.

Referenced by onMouseLeftUp().


Member Data Documentation

GlobalContactInfoVector Simulator::contacts
 

The global list of contacts. This is a list of objects, not a list of pointers.

Definition at line 88 of file Simulator.h.

Referenced by advanceTime(), deleteContacts(), detectContacts(), fillContactMatrix(), indexContacts(), and Simulator().

ContactSolver* Simulator::contactSolver
 

Definition at line 75 of file Simulator.h.

Referenced by advanceTime(), computeContacts(), fillContactMatrix(), indexContacts(), and Simulator().

PhysicalObject* Simulator::draggedObject
 

The object dragged by the mouse.

Definition at line 53 of file Simulator.h.

Referenced by applyMouseForce(), setMouseForce(), and unsetMouseForce().

Vector2 Simulator::draggingPoint
 

Definition at line 54 of file Simulator.h.

Referenced by setMouseForce().

Integrator Simulator::integrator [protected]
 

Definition at line 92 of file Simulator.h.

Referenced by advanceTime(), and getDt().

bool Simulator::isContact [private]
 

Definition at line 106 of file Simulator.h.

Referenced by advanceTime(), and Simulator().

PhysicalObjectPVector Simulator::objects
 

The list of top level objects in the environment (borders, ball, agents, etc.). This list owns the objects. The top level objects may contain member objects, that they own.

Definition at line 80 of file Simulator.h.

Referenced by advanceTime(), controll(), deleteContacts(), deleteObjects(), draw(), registerObject(), and setMouseForce().

PhysicalObjectPVector Simulator::primitives
 

The list of low level objects (primitives) in the environment. The list does not own the objects. Currently, not used.

Definition at line 84 of file Simulator.h.

Referenced by registerPrimitive().

real Simulator::realTime [protected]
 

Definition at line 96 of file Simulator.h.

Referenced by advanceTime(), and Simulator().

PhysicalObjectPVector Simulator::sortedObjects[2] [private]
 

Lists of objects used for contact detection. The 2 lists correspond to the x and respectively y coordinates used for sorting.

Definition at line 110 of file Simulator.h.

Referenced by detectContacts(), registerObject(), and sortObjects().

std::set<ObjectPair> Simulator::xContacts [private]
 

Definition at line 131 of file Simulator.h.

Referenced by detectContacts().

std::set<ObjectPair> Simulator::xyContacts [private]
 

Definition at line 131 of file Simulator.h.

Referenced by detectContacts().


The documentation for this class was generated from the following files:

Thyrix homepageUsers' guide

(C) Arxia 2004-2005