C++ API Reference
MMeshIntersector Class Reference

Mesh intersector. More...

#include <MMeshIntersector.h>

Public Member Functions

 MMeshIntersector (void)
 Constructor.
 
virtual ~MMeshIntersector (void)
 Destructor.
 
MStatus create (MObject &meshObject, const MMatrix &matrix=MMatrix::identity, const MIntArray *facesOfInterest=nullptr)
 Changed in 2020.0 More...
 
bool isCreated (void) const
 This method returns true if the intersector is created. More...
 
MStatus getClosestPoint (const MPoint &point, MPointOnMesh &meshPoint, double maxDistance=DBL_MAX) const
 This method finds the closest point. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Detailed Description

Mesh intersector.

The MMeshIntersector class contains methods for efficiently finding the closest point on a mesh. An octree algorithm is used to find the closest point.

The create() method builds the internal data required for the algorithm. As a result, calls to it should be minimized as it is a heavy operation.

This class allows multiple threads to evaluate closest points simultaneously as the method getClosestPoint is threadsafe.

Examples:
closestPointCmd/closestPointCmd.cpp, and splatDeformer/splatDeformer.cpp.

Member Function Documentation

MStatus create ( MObject meshObject,
const MMatrix matrix = MMatrix::identity,
const MIntArray facesOfInterest = nullptr 
)

Changed in 2020.0

This method creates the data required by the intersector.

2020.0:
facesOfInterest parameter added

It is a heavy operation that should be called only when necessary.

Parameters
[in]meshObjecta kMesh or kMeshData object
[in]matrixspecify the mapping to apply for transforming points that are specified in the getClosestPoint method into the object space of the mesh.
[in]facesOfInterestfaces to be considered by the intersector.
Returns
Status code
Status Codes:
  • MS::kSuccess The mesh intersector was created
  • MS::kInvalidParameter object is not a kMesh or kMeshData
  • MS::kFailure other internal failure
Examples:
closestPointCmd/closestPointCmd.cpp, and splatDeformer/splatDeformer.cpp.
bool isCreated ( void  ) const

This method returns true if the intersector is created.

False is return otherwise.

MStatus getClosestPoint ( const MPoint point,
MPointOnMesh meshPoint,
double  maxDistance = DBL_MAX 
) const

This method finds the closest point.

Information is returned in the meshPoint object.

This method is threadsafe.

Parameters
[in]pointSpecifies the location for which to evaluate the closest point on the mesh. `point' is transformed using the matrix parameter passed to the create() method, so for example if your matrix maps world to object space, then `point' should be specified in world space.
[out]meshPointResulting closest point in object space.
[in]maxDistanceMaximum distance to consider in object space.
Returns
Status code
Status Codes:
  • MS::kSuccess The mesh point was found
  • MS::kFailure object error, create not called
Examples:
closestPointCmd/closestPointCmd.cpp, and splatDeformer/splatDeformer.cpp.
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.

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