AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxCollide::Line Class Reference

A line shape for intersection tests, mostly for depth sensing and picking. More...

#include <Line.h>

+ Inheritance diagram for agxCollide::Line:

Public Types

enum  Type {
  GROUP, BOX, CAPSULE, CYLINDER,
  LINE, PLANE, SPHERE, TRIMESH,
  HEIGHT_FIELD, CONVEX, WIRE_SHAPE, CONE,
  HOLLOW_CONE, HOLLOW_CYLINDER, NUM_TYPES
}
 Define the type of a Shape. More...
 

Public Member Functions

 Line (const agx::Vec3 &p1, const agx::Vec3 &p2)
 Constructor. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
ShapeGroup * asGroup ()
 Auto-cast shape to group. More...
 
const ShapeGroup * asGroup () const
 Auto-cast shape to group. More...
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
virtual agx::Real calculateBoundingRadius (BoundingAABB &localAABB) const
 Calculate the bounding volume (AABB) into localAABB and calculate the bounding radius based on the new AABB size. More...
 
virtual agx::SPDMatrix3x3 calculateInertia (agx::Real mass) const override
 Calculate inertia for line shape, will return identity matrix for line object. More...
 
virtual BoundingAABB calculateLocalBound () const override
 Calculate a local bounding volume for shape. More...
 
virtual Shape * clone () const
 Create a clone. More...
 
const BoundingAABB & getBoundingVolume () const
 
virtual agx::Vec3 getCenter () const
 
const char * getClassName () const override
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::Physics::Geometry::LinePtr getEntity () const
 
agx::Vec3 getFirstPoint () const
 Returns the first point, in local coordinates. More...
 
Geometry * getGeometry ()
 
const Geometry * getGeometry () const
 
agx::UInt32 getIndex () const
 This index is given at creation of this object. More...
 
agx::AffineMatrix4x4 getLocalTransform () const
 
agx::UInt32 getModifiedCount () const
 
int getReferenceCount () const
 
const agxCollide::RenderData * getRenderData () const
 If this is a ShapeGroup, then this method will return nullptr as the render data is stored in the actual children (Box, Mesh etc. More...
 
agx::Vec3 getSecondPoint () const
 Returns the second point, in local coordinates. More...
 
agxStream::StorageAgent * getStorageAgent () const override
 
virtual agx::Vec3 getSupportPoint (const agx::Vec3 &supportDirection) const override
 Gets support point. More...
 
agx::AffineMatrix4x4 getTransform () const
 
agx::UInt8 getType () const
 
const char * getTypeName () const
 
agx::Uuid getUuid () const
 
virtual agx::Real getVolume () const override
 Volume of line-shape, will return 0.0 for line objects. More...
 
virtual bool hasSupportFunction () const override
 Checks if line shape has support function, will return true for line object. More...
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool isFinished () const
 
bool isGroup () const
 
virtual void propagateTransform (const agx::AffineMatrix4x4 &transform)
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
virtual void restore (agxStream::InputArchive &in) override
 
void set (const agx::Vec3 &p1, const agx::Vec3 &p2)
 Set first and second point, in local coordinates. More...
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object. More...
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More...
 
void setFirstPoint (const agx::Vec3 &p)
 Set first point (start point), in local coordinates. More...
 
virtual void setRenderData (agxCollide::RenderData *renderData)
 Store render data with the Shape. More...
 
void setSecondPoint (const agx::Vec3 &p)
 Set second point (end point), in local coordinates. More...
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object. More...
 
virtual void store (agxStream::OutputArchive &out) const override
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
virtual const BoundingAABB & updateBoundingVolume () override
 Update the bounding volume for shape. More...
 

Static Public Member Functions

static BoundingAABB calculateBound (const agx::AffineMatrix4x4 &transform, const agx::Vec3 &firstPoint, const agx::Vec3 &secondPoint)
 Calculate a bounding volume for line shape from parameters. More...
 
static BoundingAABB calculateBound (const agx::AffineMatrix4x4 &transform, const BoundingAABB &localBound)
 
static agxStream::Serializable * create (agxStream::InputArchive &)
 
static agxStream::Serializable * create ()
 
static const char * getConstructClassId ()
 
static const char * getTypeName (agx::UInt8 type)
 
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

 Line ()
 
virtual ~Line (void)
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
void generateUuid ()
 
agx::UInt32 incrementModifiedCount ()
 Increment the number of times the shape have been modified. More...
 
void syncronizeShapeIndex ()
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

agx::Physics::Geometry::ShapeRef m_entity
 
Geometry * m_geometry
 
Mutex m_mutex
 
ObserverContainer m_observers
 
ShapeGroup * m_parent
 
AtomicValue m_refCount
 
agxCollide::RenderDataRef m_renderData
 
agx::Index m_shapeIndex
 

Detailed Description

A line shape for intersection tests, mostly for depth sensing and picking.

The contacts with lines will therefore behave differently than all other shape contacts.

Note
Not to be used for modeling for general contacts, e.g. rigid body dynamics.

Details about the contact behavior:

The Line Shape is special in that its use is not in rigid body simulation, but in other fields as e.g. mouse picking or depth computation for unknown geometries. Thus, the computation of contact point, normal and depth differs from that of the other Shapes. The Line Shape represents mathematically a line segment, defined by two points \(P_0\) and \(P_1\), which define the normalized Line direction \(d = \frac{P_1 - P_0}{||P_1 - P_0||}\) The Line can thus be presented as \( P_0 + t d, 0 \le t \le ||P_1 - P_0|| \).

If a Line does not intersect the other Shape, no contact is reported.

If a Line intersects Shape, the first point in contact \(P_c\) along the infinite version of the line is reported as contact point. The surface normal of the Shape is reported as contact normal. The parameter \(t_c\) is the value which realizes \(P_c = P_0 + t_c d\). \(1 - t_c\) is reported as length; this corresponds to how long the Line has to be pushed back in its direction in order to just touch the overlap point \(P_c\).

Definition at line 55 of file ollide/Line.h.

Member Enumeration Documentation

enum agxCollide::Shape::Type
inherited

Define the type of a Shape.

Enumerator
GROUP 
BOX 
CAPSULE 
CYLINDER 
LINE 
PLANE 
SPHERE 
TRIMESH 
HEIGHT_FIELD 
CONVEX 
WIRE_SHAPE 
CONE 
HOLLOW_CONE 
HOLLOW_CYLINDER 
NUM_TYPES 

Definition at line 58 of file Shape.h.

Constructor & Destructor Documentation

agxCollide::Line::Line ( const agx::Vec3 &  p1,
const agx::Vec3 &  p2 
)

Constructor.

The endpoints of the line are in local coordinates.

Parameters
p1First endpoint
p2Second endpoint - Has to be different than p1.
virtual agxCollide::Line::~Line ( void  )
protectedvirtual
agxCollide::Line::Line ( )
inlineprotected

Definition at line 143 of file ollide/Line.h.

Member Function Documentation

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
ShapeGroup * agxCollide::Shape::asGroup ( )
inherited

Auto-cast shape to group.

Definition at line 385 of file Shape.h.

References agxAssert.

const ShapeGroup * agxCollide::Shape::asGroup ( ) const
inherited

Auto-cast shape to group.

Definition at line 390 of file Shape.h.

template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
BoundingAABB agxCollide::Line::calculateBound ( const agx::AffineMatrix4x4 &  transform,
const agx::Vec3 &  firstPoint,
const agx::Vec3 &  secondPoint 
)
static

Calculate a bounding volume for line shape from parameters.

Parameters
transformTransformation matrix
firstPointFirst point of line
secondPointSecond point of line
Returns
Axis Aligned Bounding Box

Definition at line 163 of file ollide/Line.h.

References agx::Vec3T< Real >::componentMax(), agx::Vec3T< Real >::componentMin(), agx::BoundT< T >::max(), agx::BoundT< T >::min(), and agxData::transform().

BoundingAABB agxCollide::Shape::calculateBound ( const agx::AffineMatrix4x4 &  transform,
const BoundingAABB &  localBound 
)
staticinherited
Returns
a bounding box calculated from a transformed (transform) AABB (localBound)

Definition at line 417 of file Shape.h.

virtual agx::Real agxCollide::Shape::calculateBoundingRadius ( BoundingAABB &  localAABB) const
virtualinherited

Calculate the bounding volume (AABB) into localAABB and calculate the bounding radius based on the new AABB size.

Returns
the radius of the bounding sphere surrounding the AABB.

Reimplemented in agxCollide::Sphere.

virtual agx::SPDMatrix3x3 agxCollide::Line::calculateInertia ( agx::Real  mass) const
overridevirtual

Calculate inertia for line shape, will return identity matrix for line object.

Parameters
massMass of shape
Returns
inertia matrix

Implements agxCollide::Shape.

virtual BoundingAABB agxCollide::Line::calculateLocalBound ( ) const
overridevirtual

Calculate a local bounding volume for shape.

Returns
Axis Aligned Bounding Box

Implements agxCollide::Shape.

static agxStream::Serializable* agxCollide::Line::create ( )
inlinestatic

Definition at line 139 of file ollide/Line.h.

static agxStream::Serializable* agxCollide::Line::create ( agxStream::InputArchive &  )
inlinestatic

Definition at line 139 of file ollide/Line.h.

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
void agxStream::Serializable::generateUuid ( )
protectedinherited
const BoundingAABB & agxCollide::Shape::getBoundingVolume ( ) const
inherited
Returns
the bounding volume of the shape, in global coordinates.

Definition at line 412 of file Shape.h.

agx::Vec3 agxCollide::Shape::getCenter ( ) const
inlinevirtualinherited
Returns
the center (local, relative to the Shape) of the shape. This is in most cases 0,0,0 - but can have other positions, e.g. in Convex shapes.

Reimplemented in agxCollide::Mesh, agxCollide::HollowCone, and agxCollide::Cone.

Definition at line 503 of file Shape.h.

const char* agxCollide::Line::getClassName ( ) const
inlineoverridevirtual
Returns
the class name of this class.

Reimplemented from agxStream::Serializable.

Definition at line 139 of file ollide/Line.h.

static const char* agxCollide::Line::getConstructClassId ( )
inlinestatic

Definition at line 139 of file ollide/Line.h.

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
bool agxStream::Serializable::getEnableSerialization ( ) const
inherited
Returns
true if serialization is enabled for this object

Definition at line 273 of file Serializable.h.

bool agxStream::Serializable::getEnableUuidGeneration ( )
inherited
Returns
true if Uuid:s should be generated for each new Serializable object
agx::Physics::Geometry::LinePtr agxCollide::Line::getEntity ( ) const
inline

Definition at line 148 of file ollide/Line.h.

References agxCollide::Shape::m_entity.

Referenced by getFirstPoint(), and getSecondPoint().

agx::Vec3 agxCollide::Line::getFirstPoint ( ) const

Returns the first point, in local coordinates.

Definition at line 153 of file ollide/Line.h.

References getEntity(), agx::Physics::Geometry::LinePtr::line(), and agx::LineT< T >::p1.

Geometry * agxCollide::Shape::getGeometry ( )
inherited
Returns
pointer to the associated Geometry, null if none.

Definition at line 399 of file Shape.h.

const Geometry * agxCollide::Shape::getGeometry ( ) const
inherited
Returns
pointer to the associated Geometry, null if none.

Definition at line 403 of file Shape.h.

agx::UInt32 agxStream::Serializable::getIndex ( ) const
inherited

This index is given at creation of this object.

It is guaranteed to be unique for the lifetime of this library instance. As long as the application is running. This value is not serialized or restored. A new object will always get a new index no matter how it is created.

Returns
an instance index of this object. This is unique for the lifetime of this library instance.

Definition at line 247 of file Serializable.h.

agx::AffineMatrix4x4 agxCollide::Shape::getLocalTransform ( ) const
inherited
Returns
the transform relative to its parent (Geometry) of this Shape
agx::UInt32 agxCollide::Shape::getModifiedCount ( ) const
inherited
Returns
number of times the shape have been modified. Increments at every set method.

Definition at line 454 of file Shape.h.

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
const agxCollide::RenderData* agxCollide::Shape::getRenderData ( ) const
inherited

If this is a ShapeGroup, then this method will return nullptr as the render data is stored in the actual children (Box, Mesh etc.

shapes) You need to go through each child and access the render data from those.

Returns
the render data stored with the shape.
agx::Vec3 agxCollide::Line::getSecondPoint ( ) const

Returns the second point, in local coordinates.

Definition at line 158 of file ollide/Line.h.

References getEntity(), agx::Physics::Geometry::LinePtr::line(), and agx::LineT< T >::p2.

agxStream::StorageAgent* agxCollide::Line::getStorageAgent ( ) const
inlineoverridevirtual
Returns
the storage agent

Implements agxStream::Serializable.

Definition at line 139 of file ollide/Line.h.

virtual agx::Vec3 agxCollide::Line::getSupportPoint ( const agx::Vec3 &  supportDirection) const
overridevirtual

Gets support point.

Parameters
supportDirection
Returns
support point

Reimplemented from agxCollide::Shape.

agx::AffineMatrix4x4 agxCollide::Shape::getTransform ( ) const
inherited
Returns
the transform of this Shape

Definition at line 407 of file Shape.h.

agx::UInt8 agxCollide::Shape::getType ( ) const
inherited
Returns
The shape type.

Definition at line 377 of file Shape.h.

Referenced by agxCollide::ColliderTable::getCollider().

static const char* agxCollide::Shape::getTypeName ( agx::UInt8  type)
staticinherited
Returns
a string name for the given Type type
const char* agxCollide::Shape::getTypeName ( ) const
inherited
Returns
The shape type name.
agx::Uuid agxStream::Serializable::getUuid ( ) const
inherited
Returns
a unique id for this instance.

Definition at line 268 of file Serializable.h.

virtual agx::Real agxCollide::Line::getVolume ( ) const
overridevirtual

Volume of line-shape, will return 0.0 for line objects.

Returns
agx::Real volume

Implements agxCollide::Shape.

virtual bool agxCollide::Line::hasSupportFunction ( ) const
overridevirtual

Checks if line shape has support function, will return true for line object.

Returns
true if it has a support function

Reimplemented from agxCollide::Shape.

agx::UInt32 agxCollide::Shape::incrementModifiedCount ( )
protectedinherited

Increment the number of times the shape have been modified.

Returns
the incremented value.

Definition at line 459 of file Shape.h.

Referenced by agxCollide::Mesh::setBottomMargin().

template<typename T >
bool agx::Referenced::is ( ) const
inherited
bool agxStream::Serializable::isFinished ( ) const
inherited
Returns
true if this class is restored correctly and should not be deleted during destruction of an Archive.

Definition at line 252 of file Serializable.h.

bool agxCollide::Shape::isGroup ( ) const
inherited
Returns
True if the shape is a group.

Definition at line 381 of file Shape.h.

References agxData::getType().

virtual void agxCollide::Shape::propagateTransform ( const agx::AffineMatrix4x4 &  transform)
virtualinherited
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

virtual void agxCollide::Line::restore ( agxStream::InputArchive &  in)
overridevirtual
void agxCollide::Line::set ( const agx::Vec3 &  p1,
const agx::Vec3 &  p2 
)

Set first and second point, in local coordinates.

Parameters
p1First point
p2Second point - Has to be different than p1.
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxStream::Serializable::setEnableSerialization ( bool  flag)
inherited

Set to false to disable serialization of this object.

It will just be ignored during serialization (writing). It is still possible to restore TO this object.

static void agxStream::Serializable::setEnableUuidGeneration ( bool  flag)
staticinherited

Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.

void agxStream::Serializable::setFinished ( )
inherited

Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.

void agxCollide::Line::setFirstPoint ( const agx::Vec3 &  p)

Set first point (start point), in local coordinates.

Parameters
pFirst point. Has to be different than the second point.
virtual void agxCollide::Shape::setRenderData ( agxCollide::RenderData *  renderData)
virtualinherited

Store render data with the Shape.

If the shape is a Group, the render data will be stored in all the children and NOT in the actual ShapeGroup. It is better to actually access the actual primitives and store the render data there instead of the group.

void agxCollide::Line::setSecondPoint ( const agx::Vec3 &  p)

Set second point (end point), in local coordinates.

Parameters
pSecond point. Has to be different than the first point.
void agxStream::Serializable::setUuid ( const agx::Uuid &  uuid)
inherited

Explicitly set a Uuid on a serializable object.

Use this method with great care, as it can result in non-unique identifiers in the system!

virtual void agxCollide::Line::store ( agxStream::OutputArchive &  out) const
overridevirtual
void agxCollide::Shape::syncronizeShapeIndex ( )
protectedinherited
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

virtual const BoundingAABB& agxCollide::Line::updateBoundingVolume ( )
overridevirtual

Update the bounding volume for shape.

Returns
Updated Axis Aligned Bounding Box

Implements agxCollide::Shape.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

agx::Physics::Geometry::ShapeRef agxCollide::Shape::m_entity
protectedinherited
Geometry* agxCollide::Shape::m_geometry
protectedinherited

Definition at line 266 of file Shape.h.

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

ShapeGroup* agxCollide::Shape::m_parent
protectedinherited

Definition at line 270 of file Shape.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

agxCollide::RenderDataRef agxCollide::Shape::m_renderData
protectedinherited

Definition at line 267 of file Shape.h.

agx::Index agxCollide::Shape::m_shapeIndex
protectedinherited

Definition at line 268 of file Shape.h.


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