C4D_Falloff Class Reference

#include <c4d_falloffdata.h>

Detailed Description

@markprivate Represents a falloff. Allows to sample falloffs.
It is very simple in use: allocate it, call InitFalloff() first then Sample() giving it a point in world space.

Many of the methods are there for use within NodeData/ ObjectData/ToolData plugins and should be called within their likewise counterparts.
For instance Draw should be called from within the corresponding NodeData/ ObjectData/ToolData Draw override, then the falloff will be drawn in the viewport.

C4D_Falloff normally needs a container, this is usually the object's container, from this it gets and sets its own parameters for the description (though they can be set directly using the helper functions).

Note
To add a falloff to a description use AddFalloffToDescription.

Public Types

using IsAllocType = std::true_type
 

Public Member Functions

BaseContainerGetContainerInstance ()
 
void SetTime (BaseTime time)
 
Bool InitFalloff (BaseDocument *doc=nullptr, BaseObject *op=nullptr)
 
Bool InitFalloff (const BaseDocument *doc, const BaseObject *op, FalloffDataData &data) const
 
Bool PreSample (const BaseList2D *op, const BaseDocument *doc, const FieldInput &inputs, FieldOutput &result, const FalloffDataData &data, FIELDSAMPLE_FLAG flags) const
 
void Sample (const BaseList2D *op, const Vector &p, Float *result, const FieldOutput *fieldSamples, const FalloffDataData &data, Bool usespline=true, Float weight=0.0_f, Int index=-1) const
 
void MultiSample (const BaseList2D *op, const Vector *p, Float *result, Int count, const FalloffDataData &data, Bool usespline=true, Float weight=0.0_f) const
 
Bool HasContent () const
 
Bool AddFalloffToDescription (const BaseList2D *op, Description *description, DESCFLAGS_DESC flags, Bool showValue=true, Bool showColor=false, Bool showDirection=false, Bool showRotation=false) const
 
Bool Message (BaseList2D *op, Int32 id, void *m_data=nullptr)
 
Bool Draw (BaseList2D *op, BaseDraw *bd, BaseDrawHelp *bh, DRAWPASS drawpass)
 
Bool CopyTo (C4D_Falloff *dest, BaseList2D *destPtr) const
 
Bool GetDEnabling (const DescID &id, Bool &enabled) const
 
Bool IsFields () const
 
FIELDLIST_FLAGS GetChannelFlags () const
 
void SetChannelFlags (FIELDLIST_FLAGS flags)
 
maxon::Result< BoolGetAccessedObjects (const BaseList2D *op, METHOD_ID method, AccessedObjectsCallback &access) const
 

Private Member Functions

 C4D_Falloff ()
 
 ~C4D_Falloff ()
 

Alloc/Free

static C4D_FalloffAlloc (BaseContainer *parentBc, Int cType=0)
 
static void Free (C4D_Falloff *&node)
 
static void Free (const C4D_Falloff *&node)
 

Dirty

void SetDirty ()
 
Int32 GetDirty (BaseList2D *op, const BaseDocument *doc)
 

Matrix

void SetMg (const Matrix &mg)
 
const MatrixGetMg () const
 

Mode

Bool SetMode (Int32 type)
 
Int32 GetMode () const
 

Handle

Int32 GetHandleCount () const
 
void GetHandle (Int32 i, HandleInfo &info) const
 
void SetHandle (Int32 i, Vector p, const HandleInfo &info)
 

Member Typedef Documentation

◆ IsAllocType

using IsAllocType = std::true_type

Constructor & Destructor Documentation

◆ C4D_Falloff()

C4D_Falloff ( )
private

◆ ~C4D_Falloff()

~C4D_Falloff ( )
private

Member Function Documentation

◆ Alloc()

static C4D_Falloff* Alloc ( BaseContainer parentBc,
Int  cType = 0 
)
static

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

Parameters
[in]parentBcContainer of the parent object where all data is stored
[in]cType(Optional) the type.
Returns
The allocated falloff, or nullptr if the allocation failed.

◆ Free() [1/2]

static void Free ( C4D_Falloff *&  node)
static

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

Parameters
[in,out]nodeThe falloff to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ Free() [2/2]

static void Free ( const C4D_Falloff *&  node)
static

◆ GetContainerInstance()

BaseContainer* GetContainerInstance ( )

Gets the last container the falloff should try to use.

Note
If the falloff has not been given a container at any point it will generate one internally.
Warning
Can be nullptr. If the falloff has been initialized at some point with a container, but subsequently the original container is no longer available this could be a bad pointer.
Returns
The container instance.

◆ SetDirty()

void SetDirty ( )

Sets the falloff dirty.

◆ GetDirty()

Int32 GetDirty ( BaseList2D op,
const BaseDocument doc 
)

Gets the falloff dirty value.

Note
Useful for checking if the falloff needs to be resampled.
Parameters
[in]docThe document.
Returns
The dirty value.

◆ SetMg()

void SetMg ( const Matrix mg)

Sets the falloff's matrix.

Parameters
[in]mgThe new matrix.

◆ GetMg()

const Matrix& GetMg ( ) const

Gets the falloff's matrix.

Returns
The matrix.

◆ SetMode()

Bool SetMode ( Int32  type)

Sets the falloff mode.

Note
The falloff mode is normally the falloff's ID (see ofalloff_panel.h).
Parameters
[in]typeThe new falloff mode.
Returns
true if the mode was set, otherwise false.

◆ GetMode()

Int32 GetMode ( ) const

Gets the falloff mode.

Note
The fallof's mode is normally the falloff's ID (see ofalloff_panel.h).
Returns
The falloff's mode.

◆ SetTime()

void SetTime ( BaseTime  time)

Sets the current falloff time.
Used for the animated Spline GUI offset, not for any other values currently.

Parameters
[in]timeThe new falloff time.

◆ InitFalloff() [1/2]

Bool InitFalloff ( BaseDocument doc = nullptr,
BaseObject op = nullptr 
)

Initializes the falloff.

Warning
Always call before the sample routines.
Note
It is recommended to fill at least one of the settings, however not compulsory.
Parameters
[in]docOptional document used to retrieve the current time for the animation of the Spline GUI offset.
[in]opOptional object used to set the matrix if given, and if no container is given for bc, its container will be used instead.
Returns
true if successful, otherwise false.

◆ InitFalloff() [2/2]

Bool InitFalloff ( const BaseDocument doc,
const BaseObject op,
FalloffDataData data 
) const

◆ PreSample()

Bool PreSample ( const BaseList2D op,
const BaseDocument doc,
const FieldInput inputs,
FieldOutput result,
const FalloffDataData data,
FIELDSAMPLE_FLAG  flags 
) const

Pre-samples an array of points for much faster usage with fields. Sampling result will be stored internally until the next call to PreSample. Use GetSamples() to read pre-sampling result. Only used with fields. If falloff is in legacy mode, PreSample will return true and do mothing. Use PreSample to allow calls to Sample within parallel for loops.

Parameters
[in]docThe document.
[in]opThe object.
[in]inputsThe point array to sample.
[in]flagsThe sampling flags.
Returns
true if it succeeds, false if it fails.

◆ Sample()

void Sample ( const BaseList2D op,
const Vector p,
Float result,
const FieldOutput fieldSamples,
const FalloffDataData data,
Bool  usespline = true,
Float  weight = 0.0_f,
Int  index = -1 
) const

Samples the falloff for any point in space. NOTE: Do not call Sample within a parallel for loop when using fields without PreSample called first. When using fields: -If user calls PreSample first, Sample will quickly return the pre-sampled result. This case is thread safe. -If PreSample was not called, Sample will sample the fields. This case is not thread safe. When using legacy falloffs: -Sample supports parallel for loops.

Parameters
[in]pThe point to sample in global space (ignored with pre-sampling).
[out]resultAssigned the sampled value.
[in]usesplineUse the GUI spline if it exists (default, ignored with pre-sampling).
[in]weightWeight offset. Equivalent of adding this value to the falloff result before clamping (optional, ignored with fields).
[in]opthe object (ignored with pre-sampling).
[in]indexzero-based index of the sample (when using pre-sampling).

◆ MultiSample()

void MultiSample ( const BaseList2D op,
const Vector p,
Float result,
Int  count,
const FalloffDataData data,
Bool  usespline = true,
Float  weight = 0.0_f 
) const

Samples the falloff for an array of points in space. The result will be returned in the Float array but also stored internally, overwriting the last PreSample call result.

Parameters
[in]pThe array of points to sample. The caller owns the pointed array.
[out]resultAssigned the sampled values.
[in]countThe size of array p.
[in]usesplineUse the GUI spline if it exists (default).
[in]weightAn optional weight offset. Equivalent of adding this value to the falloff result before clamping.
[in]op(Optional) the object.

◆ HasContent()

Bool HasContent ( ) const

Checks to see whether the Falloff has any sampling content.

Returns
True if content, false if not.

◆ AddFalloffToDescription()

Bool AddFalloffToDescription ( const BaseList2D op,
Description description,
DESCFLAGS_DESC  flags,
Bool  showValue = true,
Bool  showColor = false,
Bool  showDirection = false,
Bool  showRotation = false 
) const

Adds the falloff to a description.

Note
Use this function within the implementation of NodeData::GetDDescription.
Parameters
[in]descriptionThe description to add the falloff GUI to.
[in]flagsGetDescription flags.
[in]showValue(Optional) True to show, false to hide the value channel of the FieldList.
[in]showColor(Optional) True to show, false to hide the color channel of the FieldList.
[in]showDirection(Optional) True to show, false to hide the direction channel of the FieldList.
[in]showRotation(Optional) True to show, false to hide the rotation channel of the FieldList.
Returns
true if successful, otherwise false.

◆ Message()

Bool Message ( BaseList2D op,
Int32  id,
void *  m_data = nullptr 
)

Sends messages to the falloff.

Note
Use this function from within the implementation of NodeData::Message to pass all messages on to the falloff, or just send a message with it normally as needed.
Parameters
[in]idThe message type: MSG
[in,out]m_dataThe message data. The sender owns the pointed data.
Returns
true if successful, otherwise false.

◆ GetHandleCount()

Int32 GetHandleCount ( ) const

Gets the number of handles for the falloff.

Note
Use this function from within the implementation of ObjectData::GetHandleCount.
Returns
The handle count.

◆ GetHandle()

void GetHandle ( Int32  i,
HandleInfo info 
) const

Gets a handle for the falloff.

Note
Use this function from within the implementation of ObjectData::GetHandle.
Parameters
[in]iThe handle index.
[out]infoFilled with the information for handle i.

◆ SetHandle()

void SetHandle ( Int32  i,
Vector  p,
const HandleInfo info 
)

Called to set a handle for the falloff.

Note
Use this function from within the implementation of ObjectData::SetHandle.
Parameters
[in]iThe handle index.
[in]pThe new position for handle i.
[out]infoThe information for handle i.

◆ Draw()

Bool Draw ( BaseList2D op,
BaseDraw bd,
BaseDrawHelp bh,
DRAWPASS  drawpass 
)

Draws the falloff in the viewport.

Note
Use this function from within the implementation of ObjectData::Draw or ToolData::Draw.
Parameters
[in]bdThe editor's view. The caller owns the pointed base draw.
[in]bhThe editor's view help. The caller owns the pointed base draw help.
[in]drawpassThe draw pass: DRAWPASS
Returns
true if successful, otherwise false.

◆ CopyTo()

Bool CopyTo ( C4D_Falloff dest,
BaseList2D destPtr 
) const

Copies the falloff.

Note
Use this function from within the implementation of NodeData::CopyTo; necessary for handles to work correctly with the undo system in Cinema 4D.
Parameters
[out]destThe destination falloff.
Returns
true if successful, otherwise false.

◆ GetDEnabling()

Bool GetDEnabling ( const DescID id,
Bool enabled 
) const

Disables falloff parameters when falloff type is infinite.

Since
R19.SP2
Note
Use this function within the implementation of NodeData::GetDEnabling():
Bool MyNodeDataObject::GetDEnabling(const GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc) const
{
if (!node)
return true;
if (_fallOff) // _fallOff is C4D_Falloff* type
{
if (op)
{
const BaseContainer& bc = op->GetDataInstanceRef();
Bool enabled = true;
Bool handled = m_pFallOff->GetDEnabling(id, bc, enabled);
if (handled)
return enabled;
}
}
return SUPER::GetDEnabling(node, id, t_data, flags, itemdesc);
}
PyCompilerFlags * flags
Definition: ast.h:14
Definition: c4d_basecontainer.h:48
Definition: c4d_baseobject.h:248
Definition: lib_description.h:355
Definition: c4d_gedata.h:83
Represents a C4DAtom that resides in a 4D list.
Definition: c4d_baselist.h:1976
maxon::Bool Bool
Definition: ge_sys_math.h:51
DESCFLAGS_ENABLE
Definition: ge_prepass.h:3388
PyObject * op
Definition: object.h:520
Definition: node.h:10
Parameters
[in]idThe parameter id.
[out]enabledThe parameter enabled state.
Returns
true if handled, otherwise false.

◆ IsFields()

Bool IsFields ( ) const

Checks whether the Falloff is using fields or not.

Returns
@true if the falloff is using fields rather than old falloffs}

◆ GetChannelFlags()

FIELDLIST_FLAGS GetChannelFlags ( ) const

When working with Fields this retrieves the current display channel flags for the FieldList

Returns
The channel flags.

◆ SetChannelFlags()

void SetChannelFlags ( FIELDLIST_FLAGS  flags)

When working with Fields this sets the channel flags that control how the FieldLIst will display.

Parameters
[in]flagsThe flags to set.

◆ GetAccessedObjects()

maxon::Result<Bool> GetAccessedObjects ( const BaseList2D op,
METHOD_ID  method,
AccessedObjectsCallback access 
) const