SnapCore Class Reference

#include <c4d_snapdata.h>

Detailed Description

The Snap Interface, must be allocated either with AutoAlloc, or Alloc() and freed after use with Free().

Private Member Functions

 SnapCore ()
 

Alloc/Free

static SnapCoreAlloc (void)
 
static void Free (SnapCore *&p)
 

Snap/Intersect

Bool Init (BaseDocument *doc, BaseDraw *bd, AtomArray *exclude=nullptr)
 
Bool Update (void)
 
Bool Snap (const Vector &p, SnapResult &result, SNAPFLAGS flags=SNAPFLAGS::NONE)
 
Bool Intersect (const Vector &p, const Vector &n, Bool plane, SnapResult &result, SNAPFLAGS flags=SNAPFLAGS::NONE)
 

Inferred

BaseObjectAddInferred (BaseDocument *doc, const Matrix &mat, INFERREDGUIDETYPE type)
 
Bool FlushInferred (void)
 

Miscellaneous

void SetToolObject (BaseObject *op)
 
void SetCustomExcludeList (maxon::BaseArray< SnapExclude > *snapExcludeList)
 

Constructor & Destructor Documentation

◆ SnapCore()

SnapCore ( )
private

Member Function Documentation

◆ Alloc()

static SnapCore* Alloc ( void  )
static

Allocates a snap core. Destroy the allocated snap core with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated snap core, or nullptr if the allocation failed.

◆ Free()

static void Free ( SnapCore *&  p)
static

Destructs snap cores allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in]pThe snap core to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ Init()

Bool Init ( BaseDocument doc,
BaseDraw bd,
AtomArray exclude = nullptr 
)

Snap initialization routine.

Parameters
[in]docThe current document. The caller owns the pointed document.
[in]bdThe BaseDraw to initialize. The caller owns the pointed BaseDraw.
[in]excludeAn array of objects to exclude from being snapped to. The caller owns the pointed array.
Returns
True on success of initializing the snap.

◆ Update()

Bool Update ( void  )

Updates the snaps to use the current settings.

Returns
true if successful, otherwise false.

◆ Snap()

Bool Snap ( const Vector p,
SnapResult result,
SNAPFLAGS  flags = SNAPFLAGS::NONE 
)

Snap routine.

Parameters
[in]pThe position to snap to in global space.
[out]resultThe position to snap to in global space.
[in]flagsThe flags to limit snapping on selection or to a specific type: SNAPFLAGS
Returns
true on success of finding a snap point, false if no point was found in range to snap to.

◆ Intersect()

Bool Intersect ( const Vector p,
const Vector n,
Bool  plane,
SnapResult result,
SNAPFLAGS  flags = SNAPFLAGS::NONE 
)

Snap intersection routine.

Parameters
[in]pThe position to snap to in global space.
[in]nThe normal of the guide being intersected with in global space.
[in]planetrue if the intersection should be with a plane, false if with a ray/line.
[out]resultThe result of the successful intersection, user owns this.
[in]flagsThe flags to limit snapping on selection or to a specific type: SNAPFLAGS
Returns
true on success of finding an intersection, false if no intersection was found in range.

◆ AddInferred()

BaseObject* AddInferred ( BaseDocument doc,
const Matrix mat,
INFERREDGUIDETYPE  type 
)

Adds an inferred guide point, line or plane to the scene for snapping to.

Parameters
[in]docThe current document. The caller owns the pointed document.
[in]matThe matrix for the point (axis), line, or plane, z points along the line or as the normal for the plane.
[in]typeThe type of inferred guide to add: INFERREDGUIDETYPE
Returns
true on success of adding the guide, false for a memory error attempting to do so.

◆ FlushInferred()

Bool FlushInferred ( void  )

Flushes inferred system guides and inferred elements.

Note
Should be called at mouse release.
Returns
true if all inferred guides were removed, otherwise false.

◆ SetToolObject()

void SetToolObject ( BaseObject op)

Sets the active object and pass it to snap system if is created from current tool.

Note
Important for tool guide.
Parameters
[in]opThe new object created in the tool. The caller owns the pointed object.

◆ SetCustomExcludeList()

void SetCustomExcludeList ( maxon::BaseArray< SnapExclude > *  snapExcludeList)

Passes to the snap a new exclusion list.

Note
Has to be done before a snap call and will stay valid just for the next snap session.
This is useful if different exclusion types are needed during the drag without reinitializing the class.
Parameters
[in]snapExcludeListA pointer to a maxon::BaseArray of exclusion data or nullptr to clear internal pointer. The caller owns the pointed array.