Coin
4.0.3
Coin3D core library
|
The SoIntersectionDetectionAction class is for detecting intersecting primitives in a scene. More...
#include <Inventor/collision/SoIntersectionDetectionAction.h>
Public Types | |
enum | Resp { NEXT_PRIMITIVE , NEXT_SHAPE , ABORT } |
typedef Resp | SoIntersectionCB(void *closure, const SoIntersectingPrimitive *p1, const SoIntersectingPrimitive *p2) |
typedef SbBool | SoIntersectionFilterCB(void *closure, const SoPath *p1, const SoPath *p2) |
typedef SoCallbackAction::Response | SoIntersectionVisitationCB(void *closure, const SoPath *where) |
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 } |
Static Public Member Functions | |
static void | addMethod (const SoType type, SoActionMethod method) |
static void | enableElement (const SoType type, const int stackindex) |
static SoType | getClassTypeId (void) |
static float | getIntersectionEpsilon (void) |
static void | initClass (void) |
static void | setIntersectionEpsilon (float epsilon) |
Static Public Member Functions inherited from SoAction | |
static SoType | getClassTypeId (void) |
static void | initClass (void) |
static void | initClasses (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 SoActionMethodList * | getClassActionMethods (void) |
static SoEnabledElementsList * | getClassEnabledElements (void) |
Static Protected Member Functions inherited from SoAction | |
static SoActionMethodList * | getClassActionMethods (void) |
static SoEnabledElementsList * | getClassEnabledElements (void) |
Additional Inherited Members | |
Protected Attributes inherited from SoAction | |
SoState * | state |
SoActionMethodList * | traversalMethods |
The SoIntersectionDetectionAction class is for detecting intersecting primitives in a scene.
Note that 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.
Note also that the SoIntersectionDetectionAction class is not a high-performance component in Coin. Using it in a continuous manner over complex scene graphs is doomed to be a performance killer.
Below is a simple usage example for this class. It was written as a standalone framework set up for profiling and optimization of the SoIntersectionDetectionAction. It tests intersection of all shapes against each other for the loaded file.
|
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 are 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.
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
void SoIntersectionDetectionAction::addVisitationCallback | ( | SoType | type, |
SoIntersectionVisitationCB * | cb, | ||
void * | closure ) |
The scene graph traversal can be controlled with callbacks which you set with this method. Use just like you would use SoCallbackAction::addPreCallback().
|
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):
All paths must start at the same head node. All paths must be sorted in traversal order. The paths must be unique. No path can continue through the end point of another path.
Reimplemented from SoAction.
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.
Reimplemented from SoAction.
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.
If the path ends in an SoGroup node, the action will also traverse the tail node's children.
Reimplemented from SoAction.
|
static |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
|
staticprotected |
Returns list of action methods for this class. The enabledElements and methods variables are protected in the original OIV API. This is not such a good idea, since exposed static class member variables is a major grievance with regard to Win32 DLLs. This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
|
staticprotected |
Returns list of enabled elements for this class. The enabledElements and methods variables are protected in the original OIV API. This is not such a good idea, since exposed static class member variables is a major grievance with regard to Win32 DLLs. This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
This static method returns the SoType object associated with objects of this class.
|
protectedvirtual |
Returns list of enabled elements.
Reimplemented from SoAction.
float SoIntersectionDetectionAction::getIntersectionDetectionEpsilon | ( | void | ) | const |
Returns the set intersection detection distance epsilon value for the action object.
|
static |
Returns the globally set intersection detection distance epsilon value.
SbBool SoIntersectionDetectionAction::isDraggersEnabled | ( | void | ) | const |
Returns whether the actions 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.
SbBool SoIntersectionDetectionAction::isManipsEnabled | ( | void | ) | const |
Returns whether the actions 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.
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
.
SbBool SoIntersectionDetectionAction::isTypeEnabled | ( | SoType | type, |
SbBool | checkgroups = FALSE ) const |
Returns whether nodes of specific types are enabled or not. The checkgroups argument can be set to TRUE if you want the return value to reflect whether the node will be implicit 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()
|
virtual |
Removes a callback set with addIntersectionCallback().
void SoIntersectionDetectionAction::removeVisitationCallback | ( | SoType | type, |
SoIntersectionVisitationCB * | cb, | ||
void * | closure ) |
The scene graph traversal can be controlled with callbacks which you remove with this method. Use just like you would use SoCallbackAction::removePreCallback().
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.
|
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.
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.
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.
void SoIntersectionDetectionAction::setIntersectionDetectionEpsilon | ( | float | epsilon | ) |
Sets the intersection detection distance epsilon value for the action object. This overrides the global value.
See also SoIntersectionDetectionAction::setIntersectionEpsilon() for important information about how this setting influences performance.
|
static |
Sets the global intersection detection distance epsilon value.
This makes primitives within the epsilon distance be considered to intersect each other.
This will affect all intersection detection action objects in use that don't have a locally set value.
The epsilon value is a world space 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.
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.
void SoIntersectionDetectionAction::setShapeInternalsEnabled | ( | SbBool | enable | ) |
Sets whether nodes in the scene graph should be checked for intersecting primitives within themselves.
Default is FALSE
.
Sets whether nodes of specific types (including derived objects) should be tested for intersection or not.