SOONESHOTSENSOR(3iv)

✨ SoOneShotSensor ✨

okay bestie, gather round, because today we're learning about SoOneShotSensor from the 3IV manual πŸ’– (yes that's the manual name, she's fancy, we love her)

πŸ¦‹ INHERITS FROM πŸ¦‹

SoSensor > SoDelayQueueSensor > SoOneShotSensor

it's giving family tree moment, the lineage is immaculate πŸ‘‘


🌸 SYNOPSIS 🌸

#include <Inventor/sensors/SoOneShotSensor.h>

πŸŽ€ Methods from class SoOneShotSensor:

SoOneShotSensor()
SoOneShotSensor(SoSensorCB *func, void *data)
~SoOneShotSensor()

πŸŽ€ Methods from class SoDelayQueueSensor:

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

πŸŽ€ Methods from class SoSensor:

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

πŸ’… DESCRIPTION πŸ’…

so a one-shot sensor is literally the "do it once and dip" queen ✨ She gets triggered once after you schedule her, when the delay queue gets processed. periodt.

and here's the iconic part: like all delay queue sensors, one-shot sensors with a non-zero priority are just added to the delay queue when scheduled. If you schedule them again before the delay queue is processed? nothing happens 🫢 and they are guaranteed to be called only once when the delay queue is processed. no cap.

ngl the classic example: a one-shot sensor whose callback function redraws the scene might get scheduled whenever the scene graph changes and whenever a window-system event reporting that the window changed size occurs. By using a one-shot, the scene will only be redrawn once even if a window-changed-size event occurs just after the scene graph is modified (or if several window-changed-size events occur in a row). it's giving efficiency, it's giving taste 🌈

calling schedule() inside the callback function is a genuinely useful way of getting something to happen repeatedly as often as possible, while still handling events and timeouts. main character loop energy πŸ’€βœ¨

⚠️ okay so, a priority 0 one-shot sensor isn't very useful, bestie. scheduling it is exactly the same as directly calling its callback function. like why are you even here at that point 😭

πŸ”₯ METHODS πŸ”₯

  • SoOneShotSensor()
  • SoOneShotSensor(SoSensorCB *func, void *data) β€” creation methods πŸ’– the second one takes the callback function and the data to be called when the sensor is triggered.
  • ~SoOneShotSensor() β€” destroys the sensor, freeing up any memory associated with it after unscheduling it. she cleans up after herself, we stan 🧚

πŸ‘‘ SEE ALSO πŸ‘‘

SoIdleSensor, SoDelayQueueSensor

go read those too bestie, iykyk πŸ’œ


and that's the whole vibe, fr fr πŸ“ this was SoOneShotSensor from the SoOneShotSensor(3IV)() page β€” that's the source/version + date footer right there, consider yourself signed off on πŸ’– mwah, slay, go schedule something (once) ✨