SOINTERSECTIONDETECTIONACTION(3coin2)

๐Ÿ“ฆ version 2.5.0, in fedora 43, fedora 44

๐Ÿ’– NAME ๐Ÿ’–

Welcome to the SoIntersectionDetectionAction(3coin2) manual, part 1 of 2. Okay so bestie, SoIntersectionDetectionAction is literally the class for detecting intersecting primitives in a scene. It's giving collision-detection main character energy, no cap. โœจ


โœจ SYNOPSIS โœจ

#include <Inventor/collision/SoIntersectionDetectionAction.h>

It inherits from SoAction, so it's lowkey part of the whole action family. ๐Ÿซถ

๐ŸŽ€ Public Types ๐ŸŽ€

  • enum Resp { NEXT_PRIMITIVE, NEXT_SHAPE, ABORT } โ€” the three responses you can return, and yes they are iconic.
  • typedef SoCallbackAction::Response SoIntersectionVisitationCB(void *closure, const SoPath *where) โ€” visitation callback type, slay.
  • typedef SbBool SoIntersectionFilterCB(void *closure, const SoPath *p1, const SoPath *p2) โ€” filter callback type, for when you need to vibe-check pairs.
  • typedef Resp SoIntersectionCB(void *closure, const SoIntersectingPrimitive *p1, const SoIntersectingPrimitive *p2) โ€” the main intersection callback type, periodt.

๐ŸŒˆ Public Types inherited from SoAction ๐ŸŒˆ

  • enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 }
  • enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 }

๐Ÿ’… Public Member Functions ๐Ÿ’…

  • virtual SoType getTypeId (void) const โ€” returns the type id, obviously.
  • void setIntersectionDetectionEpsilon (float epsilon) โ€” set the intersection detection epsilon.
  • float getIntersectionDetectionEpsilon (void) const โ€” get that epsilon back.
  • void setTypeEnabled (SoType type, SbBool enable) โ€” enable or disable a type.
  • SbBool isTypeEnabled (SoType type, SbBool checkgroups=0) const โ€” check if a type is enabled.
  • void setManipsEnabled (SbBool enable) โ€” turn manips on or off.
  • SbBool isManipsEnabled (void) const โ€” are manips enabled? ask.
  • void setDraggersEnabled (SbBool enable) โ€” turn draggers on or off.
  • SbBool isDraggersEnabled (void) const โ€” are draggers enabled? ask.
  • void setShapeInternalsEnabled (SbBool enable) โ€” turn shape internals on or off.
  • SbBool isShapeInternalsEnabled (void) const โ€” are shape internals enabled? ask.
  • void addVisitationCallback (SoType type, SoIntersectionVisitationCB *cb, void *closure) โ€” add a visitation callback.
  • void removeVisitationCallback (SoType type, SoIntersectionVisitationCB *cb, void *closure) โ€” remove that visitation callback.
  • virtual void apply (SoNode *node) โ€” apply to a node.
  • virtual void apply (SoPath *path) โ€” apply to a path.
  • virtual void apply (const SoPathList &paths, SbBool obeysRules=0) โ€” apply to a path list.
  • virtual void setFilterCallback (SoIntersectionFilterCB *cb, void *closure=NULL) โ€” set the filter callback.
  • virtual void addIntersectionCallback (SoIntersectionCB *cb, void *closure=NULL) โ€” add an intersection callback.
  • virtual void removeIntersectionCallback (SoIntersectionCB *cb, void *closure=NULL) โ€” remove an intersection callback.

๐Ÿฆ‹ Public Member Functions inherited from SoAction ๐Ÿฆ‹

All the inherited SoAction functions, because inheritance is real and it's not going anywhere. ๐Ÿ’œ

  • virtual ~SoAction ()
  • virtual SbBool isOfType (SoType type) const
  • void apply (SoAction *beingApplied)
  • virtual void invalidateState (void)
  • AppliedCode getWhatAppliedTo (void) const
  • SoNode * getNodeAppliedTo (void) const
  • SoPath * getPathAppliedTo (void) const
  • const SoPathList * getPathListAppliedTo (void) const
  • const SoPathList * getOriginalPathListAppliedTo (void) const
  • SbBool isLastPathListAppliedTo (void) const
  • PathCode getPathCode (int &numindices, const int *&indices)
  • void traverse (SoNode *const node)
  • SbBool hasTerminated (void) const
  • const SoPath * getCurPath (void)
  • SoState * getState (void) const
  • PathCode getCurPathCode (void) const
  • virtual SoNode * getCurPathTail (void)
  • void usePathCode (int &numindices, const int *&indices)
  • void pushCurPath (const int childindex, SoNode *node=NULL)
  • void popCurPath (const PathCode prevpathcode)
  • void pushCurPath (void)
  • void popPushCurPath (const int childindex, SoNode *node=NULL)
  • void popCurPath (void)
  • void switchToPathTraversal (SoPath *path)
  • void switchToNodeTraversal (SoNode *node)

๐ŸŒŸ Static Public Member Functions ๐ŸŒŸ

  • static SoType getClassTypeId (void)
  • static void addMethod (const SoType type, SoActionMethod method)
  • static void enableElement (const SoType type, const int stackindex)
  • static void initClass (void)
  • static void setIntersectionEpsilon (float epsilon)
  • static float getIntersectionEpsilon (void)

๐ŸŒˆ Static Public Member Functions inherited from SoAction ๐ŸŒˆ

  • static void initClass (void)
  • static void initClasses (void)
  • static SoType getClassTypeId (void)
  • static void nullAction (SoAction *action, SoNode *node)

๐Ÿ’œ Protected Member Functions ๐Ÿ’œ

  • virtual const SoEnabledElementsList & getEnabledElements (void) const

๐Ÿ’œ Protected Member Functions inherited from SoAction ๐Ÿ’œ

  • SoAction (void)
  • virtual void beginTraversal (SoNode *node)
  • virtual void endTraversal (SoNode *node)
  • void setTerminated (const SbBool flag)
  • virtual SbBool shouldCompactPathList (void) const

โœจ Static Protected Member Functions โœจ

  • static SoEnabledElementsList * getClassEnabledElements (void)
  • static SoActionMethodList * getClassActionMethods (void)

โœจ Static Protected Member Functions inherited from SoAction โœจ

  • static SoEnabledElementsList * getClassEnabledElements (void)
  • static SoActionMethodList * getClassActionMethods (void)

๐Ÿซถ Additional Inherited Members ๐Ÿซถ

๐Ÿ’… Protected Attributes inherited from SoAction ๐Ÿ’…

  • SoState * state
  • SoActionMethodList * traversalMethods

๐Ÿฆ‹ Detailed Description ๐Ÿฆ‹

Okay so the SoIntersectionDetectionAction class is for detecting intersecting primitives in a scene. That's literally the whole assignment. ๐Ÿ’–

Important vibe check: only collisions between actual geometry in the scene are detected. So the contents of some special nodes like e.g. SoText2 and SoImage (which projects to screen-plane bitmap graphics, and not actual polygons) will not be considered for collision detection. Not me finding out your bitmap isn't geometry. ๐Ÿ˜ญ

Below is a simple usage example for this class. It was written as a stand-alone framework set up for profiling and optimization of the SoIntersectionDetectionAction. It tests intersection of all shapes against each other for the loaded file. Iconic, honestly. ๐Ÿ‘‘

#include <stdlib.h>
#include <Inventor/SbTime.h>
#include <Inventor/SoDB.h>
#include <Inventor/SoInteraction.h>
#include <Inventor/collision/SoIntersectionDetectionAction.h>
#include <Inventor/errors/SoDebugError.h>
#include <Inventor/nodekits/SoNodeKit.h>
#include <Inventor/nodes/SoSeparator.h>

static SoIntersectionDetectionAction::Resp
intersectionCB(void * closure,
               const SoIntersectingPrimitive * pr1,
               const SoIntersectingPrimitive * pr2)
{
  (void)fprintf(stdout, "intersection hit!\n");
  return SoIntersectionDetectionAction::NEXT_PRIMITIVE;
}

int
main(int argc, char ** argv)
{
  SoDB::init();
  SoNodeKit::init();
  SoInteraction::init();

  if (argc != 2) {
    (void)fprintf(stderr, "\n\tUsage: testapp <filename.iv>\n\n");
    exit(1);
  }

  SoInput in;
  SbBool ok = in.openFile(argv[1]);
  assert(ok);
  SoSeparator * root = SoDB::readAll(&in);
  assert(root);

  root->ref();

  SoIntersectionDetectionAction ida;
  ida.addIntersectionCallback(intersectionCB, NULL);
  ida.setManipsEnabled(FALSE);
  ida.setDraggersEnabled(FALSE);
  ida.setIntersectionDetectionEpsilon(10.0f);

  SbTime starttime = SbTime::getTimeOfDay();
  SoDebugError::postInfo("main", "SoIntersectionDetectionAction::apply");

  ida.apply(root);

  SoDebugError::postInfo("main", "apply() done after %f seconds.",
                         (SbTime::getTimeOfDay() - starttime).getValue());

  root->unref();

  return 0;
}

๐Ÿ•ฐ๏ธ Since ๐Ÿ•ฐ๏ธ

  • Coin 2.1
  • TGS Inventor 2.4

โœจ MEMBER FUNCTION DOCUMENTATION โœจ

Okay bestie, this is the part where we go function by function. Grab a strawberry drink, we're doing all of them, no skipping, no cap. ๐Ÿ’–


๐Ÿ‘‘ getTypeId() โ€” the "who even are you" check

SoType SoIntersectionDetectionAction::getTypeId (void ) const [virtual]

This hands you back the type identification of an action derived from a class that inherits SoAction. It's the thing that makes run-time type checking and "downward" casting possible, iykyk.

Usage example, fr fr:

void bar(SoAction * action)
{
  if (action->getTypeId() == SoGLRenderAction::getClassTypeId()) {
    // safe downward cast, know the type
    SoGLRenderAction * glrender = (SoGLRenderAction *)action;
  }
  return; // ignore if not renderaction
}

For application programmers who wanna extend the library with new actions: you have to override this method in all subclasses. That's typically part of setting up the full type system for extension classes, which usually gets done with the pre-defined macros you get through Inventor/nodes/SoSubAction.h: SO_ACTION_SOURCE, SO_ACTION_INIT_CLASS and SO_ACTION_CONSTRUCTOR.

Want the full lore on writing Coin extensions? Go read the SoAction class documentation. ๐Ÿ“š

Returns the actual type id of an object derived from a class inheriting SoAction. Needs to be overridden in all subclasses.

Implements SoAction.


๐Ÿซถ addMethod() โ€” internal business, don't worry about it

void SoIntersectionDetectionAction::addMethod (const SoType type,
    SoActionMethod method) [static]

This API member is considered internal to the library, since it's not likely to be of interest to the application programmer. That's the whole note. Move along, nothing to see. ๐Ÿ™ˆ

References SoAction::SoAction().


๐Ÿงš enableElement() โ€” also internal, also not your problem

void SoIntersectionDetectionAction::enableElement (const SoType type, const
    int stackindex) [static]

Same energy as above: this API member is considered internal to the library, because it's not likely to be of interest to the application programmer. โœจ


๐ŸŒธ getEnabledElements() โ€” the element roster

const SoEnabledElementsList &
SoIntersectionDetectionAction::getEnabledElements (void ) const
[protected],  [virtual]

Gives you a list of the elements that action instances of this class use when they do traversal operations.

Reimplemented from SoAction.


๐ŸŽ€ setIntersectionDetectionEpsilon() โ€” per-action epsilon, so personal

void SoIntersectionDetectionAction::setIntersectionDetectionEpsilon (float
    epsilon)

Sets the intersection detection distance epsilon value for this action object. It overrides the global value, main character energy. ๐Ÿ’…

See also SoIntersectionDetectionAction::setIntersectionEpsilon() for the important tea about how this setting influences performance. ๐Ÿ‘€


๐Ÿฆ‹ getIntersectionDetectionEpsilon() โ€” read it back

float SoIntersectionDetectionAction::getIntersectionDetectionEpsilon (void )
    const

Returns the set intersection detection distance epsilon value for the action object. That's it, that's the function.


๐Ÿ”ฅ setIntersectionEpsilon() โ€” the GLOBAL epsilon (static, so it hits everybody)

void SoIntersectionDetectionAction::setIntersectionEpsilon (float epsilon)
    [static]

Sets the global intersection detection distance epsilon value.

This makes primitives within the epsilon distance be considered to intersect each other. Yes, that's the whole point. ๐ŸŽฏ

This will affect all intersection detection action objects in use that don't have a locally set value.

The epsilon value is a worldspace value.

โš ๏ธ Be aware that increasing the epsilon value can dramatically increase the number of primitive intersection tests being done to decide intersections. Increasing the epsilon value can therefore cause serious slow-downs in the running time of the intersections checks. Not the slay you want. ๐Ÿ’€

๐ŸŒˆ getIntersectionEpsilon() โ€” the global one, read-only

float SoIntersectionDetectionAction::getIntersectionEpsilon (void ) [static]

Returns the globally set intersection detection distance epsilon value.


๐Ÿ’œ setTypeEnabled() โ€” pick which node types get tested

void SoIntersectionDetectionAction::setTypeEnabled (SoType type, SbBool
    enable)

Sets whether nodes of specific types (including derived objects) should be tested for intersection or not.

See also

  • isTypeEnabled()
  • setManipsEnabled()
  • setDraggersEnabled()

๐Ÿ’– isTypeEnabled() โ€” is this type in or out?

SbBool SoIntersectionDetectionAction::isTypeEnabled (SoType type, SbBool
    checkgroups = 0) const

Returns whether nodes of specific types are enabled or not. You can set the checkgroups argument to TRUE if you want the return value to reflect whether the node will be implicitly enabled/disabled through the settings controlled by the setManipsEnabled() and setDraggersEnabled() functions. ๐Ÿ•ต๏ธ

The default is that all node types are enabled.

๐Ÿšจ Note that derivation checks are not performed โ€” the type needs to be the exact same type as has been disabled with setTypeEnabled().

See also

  • setTypeEnabled()

References SoType::isDerivedFrom().


๐Ÿ“ setManipsEnabled() โ€” manipulators, in or out?

void SoIntersectionDetectionAction::setManipsEnabled (SbBool enable)

Sets whether manipulators in the scene graph should be tested for intersection with other geometry or not.

๐Ÿ‘€ Note that when draggers are disabled with setDraggersEnabled(), this setting has no effect โ€” manipulators are disabled too.

See also

  • isManipsEnabled()
  • setDraggersEnabled()
  • setTypeEnabled()

๐ŸŒŸ isManipsEnabled() โ€” checking the manipulator vibe

SbBool SoIntersectionDetectionAction::isManipsEnabled (void ) const

Returns whether the action is set up to test intersection on manipulators in the scene or not.

๐Ÿ‘€ Note that when draggers are disabled with setDraggersEnabled(), this setting has no effect โ€” manipulators are disabled too.

The default is that manipulators are enabled for intersection testing with other geometry in the scene.

See also

  • setManipsEnabled()

๐Ÿ’… setDraggersEnabled() โ€” draggers, the drama starts here

void SoIntersectionDetectionAction::setDraggersEnabled (SbBool enable)

Sets whether draggers in the scene graph should be tested for intersection with other geometry or not.

๐Ÿšจ Note that when you disable draggers, manipulators are also automatically disabled, although the isManipsDisabled() setting might reflect otherwise. Sneaky, right? ๐Ÿ˜ญ

See also

  • isDraggersEnabled()
  • setManipsEnabled()
  • setTypeEnabled()

๐ŸŒธ isDraggersEnabled() โ€” dragger status check

SbBool SoIntersectionDetectionAction::isDraggersEnabled (void ) const

Returns whether the action is set up to test intersection on draggers in the scene or not.

The default is that draggers are enabled for intersection testing with other geometry in the scene.

See also

  • setDraggersEnabled()

๐ŸŽ€ setShapeInternalsEnabled() โ€” shapes vs. themselves

void SoIntersectionDetectionAction::setShapeInternalsEnabled (SbBool enable)

Sets whether nodes in the scene graph should be checked for intersecting primitives within themselves. Self-reflection, but make it geometry. ๐Ÿชž

Default is FALSE.

See also

  • isShapeInternalsEnabled()

๐Ÿฆ‹ isShapeInternalsEnabled() โ€” the self-intersection status

SbBool SoIntersectionDetectionAction::isShapeInternalsEnabled (void ) const

Returns whether nodes in the scene graph will be checked for intersecting primitives within themselves.

The default value for this setting is FALSE.

See also

  • setShapeInternalsEnabled()

๐Ÿ”ฎ addVisitationCallback() โ€” control the traversal

void SoIntersectionDetectionAction::addVisitationCallback (SoType type,
    SoIntersectionVisitationCB * cb, void * closure)

The scene graph traversal can be controlled with callbacks, and you set them up with this method. Use it just like you would use SoCallbackAction::addPreCallback(). Same energy, different action. โœจ

See also

  • SoCallbackAction::addPreCallback()

๐Ÿงน removeVisitationCallback() โ€” un-control the traversal

void SoIntersectionDetectionAction::removeVisitationCallback (SoType type,
    SoIntersectionVisitationCB * cb, void * closure)

The scene graph traversal can be controlled with callbacks, and you remove them with this method. Use it just like you would use SoCallbackAction::removePreCallback().

See also

  • SoCallbackAction::removePreCallback()

๐ŸŒˆ apply() โ€” on a node

void SoIntersectionDetectionAction::apply (SoNode * root) [virtual]

Applies the action to the scene graph rooted at root.

โš ๏ธ Note that you should not apply an action to a node with a zero reference count. The behavior in that case is undefined. Don't do it, bestie, it's not giving.

Reimplemented from SoAction.

References SoAction::apply(), SoOutput::closeFile(), SbTime::getTimeOfDay(), SoGetPrimitiveCountAction::getTriangleCount(), SoGetBoundingBoxAction::getXfBoundingBox(), SoOutput::openFile(), and SoDebugError::postInfo().


๐Ÿซถ apply() โ€” on a path

void SoIntersectionDetectionAction::apply (SoPath * path) [virtual]

Applies the action to the parts of the graph defined by path.

Note that an SoPath will also contain all nodes that may influence e.g. geometry nodes in the path. So for instance, applying an SoGLRenderAction on an SoPath will render that path as expected in the view, where geometry will get its materials, textures, and other appearance settings correctly. Iconic behaviour, honestly. ๐Ÿ’–

If the path ends in an SoGroup node, the action will also traverse the tail node's children.

Reimplemented from SoAction.

References SoAction::apply(), and SoGetBoundingBoxAction::getXfBoundingBox().


๐Ÿ”ฅ apply() โ€” on a whole path list

void SoIntersectionDetectionAction::apply (const SoPathList & pathlist,
    SbBool obeysrules = 0) [virtual]

Applies action to the graphs defined by pathlist. If obeysrules is set to TRUE, pathlist must obey the following four conditions (which is the case for path lists returned from search actions for non-group nodes and path lists returned from picking actions):

  1. All paths must start at the same head node.
  2. All paths must be sorted in traversal order.
  3. The paths must be unique.
  4. No path can continue through the end point of another path.

See also

  • SoAction::apply(SoPath * path)

Reimplemented from SoAction.

References SoAction::apply(), and SoGetBoundingBoxAction::getXfBoundingBox().


๐ŸŽฏ setFilterCallback() โ€” the pre-flight check

void SoIntersectionDetectionAction::setFilterCallback
    (SoIntersectionFilterCB * cb, void * closure = NULL) [virtual]

This callback is called when two shapes are found to have intersecting bounding boxes, and are about to be checked for real intersection between their primitives. It's the bouncer at the door. ๐Ÿšช

When intersection epsilon values are in use, bounding box intersection testing is done approximately and will trigger the filter callback on boxes that are further from each other than the epsilon length. (Yes, it gets fuzzy. That's the tradeoff.)

  • If the callback returns TRUE, the intersection test will be performed.
  • If the callback returns FALSE, the intersection testing will be skipped.
๐Ÿ’… The API allows only one filter callback.

๐Ÿ’œ addIntersectionCallback() โ€” found one!

void SoIntersectionDetectionAction::addIntersectionCallback
    (SoIntersectionCB * cb, void * closure = NULL) [virtual]

Adds a callback to be called when two intersecting primitives are found in the scene.

  • If the callback returns ABORT, the intersection detection is aborted. ๐Ÿ›‘
  • If the callback returns NEXT_SHAPE, the intersection detection between these two shapes is aborted and the action continues checking other shapes.
  • If the callback returns NEXT_PRIMITIVE, the intersection detection testing continues checking the other primitives in these two shapes.

See also

  • removeIntersectionCallback()

๐Ÿงน removeIntersectionCallback() โ€” un-found it

void SoIntersectionDetectionAction::removeIntersectionCallback
    (SoIntersectionCB * cb, void * closure = NULL) [virtual]

Removes a callback set with addIntersectionCallback().

See also

  • addIntersectionCallback()

๐ŸŒŸ AUTHOR ๐ŸŒŸ

Generated automatically by Doxygen for Coin from the source code. (Not a human, not a girl with a keyboard, just vibes and a parser. ๐Ÿ˜ญ)


And that's the whole page, bestie!! ๐ŸŽ€ This was Coin, Version 2.5.0, the man page for SoIntersectionDetectionAction(3) โ€” go forth and detect those intersections, you absolute icon. ๐Ÿ’–โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from