SODATASENSOR(3iv)

✨ SoDataSensor ✨

okay bestie, welcome to the SoDataSensor page from the 3IV manual πŸŽ€ this one's an abstract base class and it's literally the blueprint for every sensor that glues itself to a part of your scene graph and yells at you when that thing changes. main character energy fr πŸ’…


🌸 NAME 🌸

SoDataSensor β€” the abstract base class for sensors attached to parts of a scene. like, the concept of a sensor, not the sensor itself, iykyk πŸ¦‹


🧬 INHERITS FROM 🧬

SoSensor > SoDelayQueueSensor > SoDataSensor

it's giving family tree. three generations deep, all iconic πŸ‘‘


πŸ“œ SYNOPSIS πŸ“œ

#include <Inventor/sensors/SoDataSensor.h>

methods that come from SoDataSensor itself:

void                setDeleteCallback(SoSensorCB *function, void *data)
SoNode *            getTriggerNode() const
SoField *           getTriggerField() const
SoPath *            getTriggerPath() const
void                setTriggerPathFlag(SbBool flag)
SbBool              getTriggerPathFlag() const

methods it inherits from SoDelayQueueSensor:

void                setPriority(uint32_t pri)
uint32_t            getPriority()
static uint32_t     getDefaultPriority()
virtual void        schedule()
virtual void        unschedule()
virtual SbBool      isScheduled()

methods it inherits from SoSensor:

void                setFunction(SoSensorCB *callbackFunction)
SoSensorCB *        getFunction() const
void                setData(void *callbackData)
void *              getData() const

πŸ’« DESCRIPTION πŸ’«

so data sensors detect changes to scene graph objects β€” that's paths, nodes, or fields β€” and then they trigger their callback function the moment that object changes. that's the whole vibe. no cap 🫢

data sensors also hand you a delete callback, which gets called just before the object your sensor is attached to gets deleted. cute, right?

⚠️ but bestie listen β€” that callback should not try to modify the object in any way. like, none. because core dumps may result πŸ˜­πŸ’€ do not test this.

and then β€” priority zero data sensors also come with methods you can call inside your callback function to figure out exactly which node, field, or path set off the sensor. detective mode fr πŸ”βœ¨


πŸ› οΈ METHODS πŸ› οΈ

void setDeleteCallback(SoSensorCB *function, void *data)

sets a callback that'll be called when the object your sensor is sensing gets deleted. it's the goodbye text of callbacks πŸ₯²


SoNode * getTriggerNode() const

SoField * getTriggerField() const

if this is a priority 0 data sensor, it returns the node/field that got modified and caused this sensor to trigger. slay.

it returns NULL if the sensor wasn't triggered because a node/field changed β€” for example, if schedule() was called on the sensor instead β€” or if this sensor isn't a priority 0 sensor at all. πŸ™ˆ

heads up though: one single change to the scene graph can cause multiple nodes or fields to get modified (field-to-field connections said "not me minding my business"), so the node or field you get back might not be the only one that changed. ⭐

SoPath * getTriggerPath() const

void setTriggerPathFlag(SbBool flag)

SbBool getTriggerPathFlag() const

if this is a priority 0 data sensor, this returns a path to the node that caused your sensor to trigger. πŸ¦‹

but here's the tea β€” recreating that path to the node that changed is relatively expensive, so you have to call setTriggerPathFlag(TRUE) before the sensor is scheduled. if you don't call it, or if the sensor wasn't triggered because a node changed, this returns NULL. and it also returns NULL if this isn't a priority 0 sensor. so many NULLs, so little time πŸ’€


πŸ‘€ SEE ALSO πŸ‘€

SoNodeSensor, SoPathSensor, SoFieldSensor, SoDelayQueueSensor

go read those next bestie, they're all in their own lane and they all ate 🌈


that's the whole page!! ty for coming to my ted talk, this was SoDataSensor(3IV) and yes the manual name is doing a little double appearance moment at the bottom like a signature πŸ’– mwah, go forth and sensor responsibly, ily πŸŽ€βœ¨