AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
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 Member Functions

 Line (const agx::Vec3 p1, const agx::Vec3 p2)
 Constructor.
 
 AGXSTREAM_DECLARE_SERIALIZABLE_BASE (agxCollide::Line)
 
virtual agx::SPDMatrix3x3 calculateInertia (agx::Real mass) const override
 Calculate inertia for line shape, will return identity matrix for line object.
 
virtual BoundingAABB calculateLocalBound () const override
 Calculate a local bounding volume for shape.
 
agx::Physics::Geometry::LinePtr getEntity () const
 
agx::Vec3 getFirstPoint () const
 Returns the first point, in local coordinates.
 
agx::Vec3 getSecondPoint () const
 Returns the second point, in local coordinates.
 
virtual agx::Vec3 getSupportPoint (const agx::Vec3 &supportDirection) const override
 Gets support point.
 
virtual agx::Real getVolume () const override
 Volume of line-shape, will return 0.0 for line objects.
 
virtual bool hasSupportFunction () const override
 Checks if line shape has support function, will return true for line object.
 
void set (const agx::Vec3 &p1, const agx::Vec3 &p2)
 Set first and second point, in local coordinates.
 
void setFirstPoint (const agx::Vec3 &p)
 Set first point (start point), in local coordinates.
 
void setSecondPoint (const agx::Vec3 &p)
 Set second point (end point), in local coordinates.
 
virtual const BoundingAABB & updateBoundingVolume () override
 Update the bounding volume for shape.
 
- Public Member Functions inherited from agxCollide::Shape
ShapeGroup * asGroup ()
 Auto-cast shape to group.
 
const ShapeGroup * asGroup () const
 Auto-cast shape to group.
 
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.
 
virtual agx::SPDMatrix3x3 calculateInertia (agx::Real mass) const =0
 Calculate the inertia for the shape given a mass.
 
virtual BoundingAABB calculateLocalBound () const =0
 Calculate the bounding volume in the local coordinate system.
 
virtual Shape * clone () const
 Create a clone.
 
const BoundingAABB & getBoundingVolume () const
 
virtual agx::Vec3 getCenter () const
 
agx::Physics::Geometry::ShapePtr getEntity () const
 
Geometry * getGeometry ()
 
const Geometry * getGeometry () const
 
agx::AffineMatrix4x4 getLocalTransform () const
 
agx::UInt32 getModifiedCount () const
 
agxCollide::RenderData * getRenderData ()
 If this is a ShapeGroup, then this method will return nullptr as the render data is stored in the actual children (Box, Mesh etc.
 
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.
 
virtual agx::Vec3 getSupportPoint (const agx::Vec3 &supportDirection) const
 Returns the support point on face of the shape.
 
agx::AffineMatrix4x4 getTransform () const
 
agx::UInt8 getType () const
 
const char * getTypeName () const
 
virtual agx::Real getVolume () const =0
 Return the volume of the shape.
 
virtual bool hasSupportFunction () const
 
bool isGroup () const
 
virtual void propagateTransform (const agx::AffineMatrix4x4 &transform)
 
virtual void setRenderData (agxCollide::RenderData *renderData)
 Store render data with the Shape.
 
virtual const BoundingAABB & updateBoundingVolume ()=0
 Calculate the bounding volume based on the current Shape parameters including transformation.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 

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.
 
static agxStream::Serializable * create (agxStream::InputArchive &)
 
- Static Public Member Functions inherited from agxCollide::Shape
static BoundingAABB calculateBound (const agx::AffineMatrix4x4 &transform, const BoundingAABB &localBound)
 
static const char * getTypeName (agx::UInt8 type)
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Public Member Functions inherited from agxStream::Serializable
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
 

Protected Member Functions

 Line ()
 
virtual ~Line (void)
 
- Protected Member Functions inherited from agxCollide::Shape
 Shape (Type type, agx::Physics::Geometry::ShapePtr entity=agx::Physics::Geometry::ShapeModel::createInstance())
 Constructor.
 
virtual ~Shape ()
 Destructor.
 
agx::UInt32 incrementModifiedCount ()
 Increment the number of times the shape have been modified.
 
void syncronizeShapeIndex ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 

Additional Inherited Members

- Public Types inherited from agxCollide::Shape
enum  Type {
  GROUP , BOX , CAPSULE , CYLINDER ,
  LINE , PLANE , SPHERE , TRIMESH ,
  HEIGHT_FIELD , CONVEX , WIRE_SHAPE , CONE ,
  HOLLOW_CONE , HOLLOW_CYLINDER , TIRE_SHAPE , NUM_TYPES
}
 Define the type of a Shape. More...
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agxCollide::Shape
agx::Physics::Geometry::ShapeRef m_entity
 
Geometry * m_geometry
 
agx::ref_ptr< agx::Referenced > m_internalData
 
ShapeGroup * m_parent
 
agxCollide::RenderDataRef m_renderData
 
agx::Index m_shapeIndex
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

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 agxCollide/Line.h.

Constructor & Destructor Documentation

◆ Line() [1/2]

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.

◆ ~Line()

virtual agxCollide::Line::~Line ( void  )
protectedvirtual

◆ Line() [2/2]

agxCollide::Line::Line ( )
inlineprotected

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

Member Function Documentation

◆ AGXSTREAM_DECLARE_SERIALIZABLE_BASE()

agxCollide::Line::AGXSTREAM_DECLARE_SERIALIZABLE_BASE ( agxCollide::Line  )

◆ calculateBound()

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 agxCollide/Line.h.

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

◆ calculateInertia()

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.

◆ calculateLocalBound()

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

Calculate a local bounding volume for shape.

Returns
Axis Aligned Bounding Box

Implements agxCollide::Shape.

◆ create()

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

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

◆ getEntity()

agx::Physics::Geometry::LinePtr agxCollide::Line::getEntity ( ) const
inline

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

References agxCollide::Shape::m_entity.

Referenced by getFirstPoint(), and getSecondPoint().

◆ getFirstPoint()

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

Returns the first point, in local coordinates.

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

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

◆ getSecondPoint()

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

Returns the second point, in local coordinates.

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

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

◆ getSupportPoint()

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

Gets support point.

Parameters
supportDirection
Returns
support point

Reimplemented from agxCollide::Shape.

◆ getVolume()

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.

◆ hasSupportFunction()

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.

◆ set()

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.

◆ setFirstPoint()

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.

◆ setSecondPoint()

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.

◆ updateBoundingVolume()

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

Update the bounding volume for shape.

Returns
Updated Axis Aligned Bounding Box

Implements agxCollide::Shape.


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