SOCALLBACK(3iv)

πŸ’– SoCallback β€” bestie's guide to custom behavior during actions πŸ’–

okay so this is SoCallback(3IV), from the Inventor fam, and she is literally the "insert your own vibe here" node. Let's get into it πŸŽ€


🌸 INHERITS FROM

SoBase > SoFieldContainer > SoNode > SoCallback

the whole ancestry, no skips, we love a bloodline πŸ‘‘


✨ SYNOPSIS

#include <Inventor/nodes/SoCallback.h>

typedef void        SoCallbackCB(void *userData, SoAction *action)

Methods from class SoCallback:

                     SoCallback()
void                setCallback(SoCallbackCB *func, void *userData = NULL)
static SoType       getClassTypeId()

Methods from class SoNode:

void                setOverride(SbBool state)
SbBool              isOverride() const
SoNode *            copy(SbBool copyConnections = FALSE) const
virtual SbBool      affectsState() const
static SoNode *     getByName(const SbName &name)
static int          getByName(const SbName &name, SoNodeList &list)

Methods from class SoFieldContainer:

void                setToDefaults()
SbBool              hasDefaultValues() const
SbBool              fieldsAreEqual(const SoFieldContainer *fc) const
void                copyFieldValues(const SoFieldContainer *fc, SbBool
                         copyConnections = FALSE)
SbBool              set(const char *fieldDataString)
void                get(SbString &fieldDataString)
virtual int         getFields(SoFieldList &resultList) const
virtual SoField *   getField(const SbName &fieldName) const
SbBool              getFieldName(const SoField *field, SbName &fieldName)
                         const
SbBool              isNotifyEnabled() const
SbBool              enableNotify(SbBool flag)

Methods from class SoBase:

void                ref()
void                unref() const
void                unrefNoDelete() const
void                touch()
virtual SoType      getTypeId() const
SbBool              isOfType(SoType type) const
virtual void        setName(const SbName &name)
virtual SbName      getName() const

πŸ¦‹ DESCRIPTION

so basically this node is the general mechanism for sliding callback functions into a scene graph πŸ’… the callback function you register with the node gets called every single time the node is traversed while any scene graph action is happening. periodt.

the callback function gets handed a pointer to the action being performed, plus a user data pointer that you registered along with the callback function. iconic combo honestly 🫢

you can use this node to make nonstandard OpenGL calls while rendering. and if you do?? be careful not to interfere with Inventor's use of OpenGL. that's the rule, no cap.

if you use a callback node for GL rendering, you should be careful to follow render caching rules. and like β€” if your callback node can make different rendering calls each time it's traversed, then it cannot be cached. in that case the node should invalidate any open caches, like in this example:

void
myCallbackFunc(void *d, SoAction *action) {
    if (action->isOfType(SoGLRenderAction::getClassTypeId())) {
                    // Make my custom GL calls
                    ((MyClass *) d)->myRender();

                    // Invalidate the state so that a cache is not made
                    SoCacheElement::invalidate(action->getState());
    }
}

πŸ’… METHODS

  • SoCallback() β€” creates a callback node with default settings. baby's first callback ✨
  • void setCallback(SoCallbackCB *func, void *userData = NULL) β€” sets the pointer to the callback function and the user data. by default, the function pointer in the node is NULL and it does absolutely nothing, which is lowkey the safest default ngl πŸ™ˆ
  • static SoType getClassTypeId() β€” returns the type identifier for this class. iykyk πŸŽ€

πŸ”₯ ACTION BEHAVIOR

SoGLRenderAction, SoBoundingBoxAction, SoPickAction

calls the specified callback function for all actions. all of them. every time. she's committed πŸ’–


πŸ“ FILE FORMAT/DEFAULTS

Callback {
}

look at her. empty. minimal. main character energy πŸ‘‘


🌈 SEE ALSO

SoAction, SoCallbackAction, SoEventCallback


okay that's the whole page bestie, you ate that πŸ’– this was SoCallback(3IV), straight out of the Inventor source, dated however old the manual page is β€” mwah, slay, go write some callbacks 🧚✨