Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ include_directories(BEFORE
"${PROJECT_BINARY_DIR}/data"
)

# Tracy profiler integration (optional, propagates to all OBJECT libraries)
if(COIN_USE_TRACY)
add_definitions(-DTRACY_ENABLE -DCOIN_USE_TRACY)
include_directories("${COIN_TRACY_INCLUDE_DIR}")
endif()

# add include dirs for non targets
if(NOT "${COIN_TARGET_INCLUDE_DIRECTORIES}" STREQUAL "")
include_directories(${COIN_TARGET_INCLUDE_DIRECTORIES})
Expand Down Expand Up @@ -264,6 +270,20 @@ target_include_directories(${PROJECT_NAME}
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
)
target_link_libraries(${PROJECT_NAME} PRIVATE ${COIN_TARGET_LINK_LIBRARIES})

# Tracy profiler integration (optional)
# Use -undefined dynamic_lookup on macOS so Tracy symbols are resolved lazily
# at runtime. When loaded by FreeCAD (TracyClient present), profiling is active.
# When loaded by pivy standalone, CoinTracyConfig.h's runtime check via dlsym
# detects TracyClient's absence and disables zones.
if(COIN_USE_TRACY)
target_include_directories(${PROJECT_NAME} PRIVATE "${COIN_TRACY_INCLUDE_DIR}")
target_compile_definitions(${PROJECT_NAME} PRIVATE TRACY_ENABLE COIN_USE_TRACY)
if(APPLE)
target_link_options(${PROJECT_NAME} PRIVATE "-undefined" "dynamic_lookup")
endif()
endif()

if(NOT COIN_BUILD_MAC_FRAMEWORK)
target_include_directories(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
endif()
Expand Down
11 changes: 11 additions & 0 deletions src/CoinTracyConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef COIN_TRACY_CONFIG_H
#define COIN_TRACY_CONFIG_H

#ifdef COIN_USE_TRACY
#include <tracy/Tracy.hpp>
#define CoinZoneScopedN(name) ZoneScopedN(name)
#else
#define CoinZoneScopedN(x)
#endif

#endif // COIN_TRACY_CONFIG_H
22 changes: 22 additions & 0 deletions src/actions/SoHandleEventAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

#include <Inventor/actions/SoHandleEventAction.h>

#include "CoinTracyConfig.h"

#include <Inventor/SbViewportRegion.h>
#include <Inventor/events/SoEvent.h>
#include <Inventor/elements/SoSwitchElement.h>
Expand All @@ -61,6 +63,7 @@
#include <Inventor/misc/SoState.h>

#include "actions/SoSubActionP.h"
#include "caches/SoSceneBVH.h"

// *************************************************************************

Expand Down Expand Up @@ -357,6 +360,7 @@ SoHandleEventAction::getPickedPoint(void)
const SoPickedPointList &
SoHandleEventAction::getPickedPointList(void)
{
CoinZoneScopedN("SoHandleEventAction::getPickedPointList");
SoRayPickAction * ra = PRIVATE(this)->getPickAction();
if (!PRIVATE(this)->pickvalid || !PRIVATE(this)->didpickall) {
ra->setPickAll(TRUE);
Expand Down Expand Up @@ -411,10 +415,20 @@ SoHandleEventActionP::getPickAction(void) const
void
SoHandleEventActionP::doPick(SoRayPickAction * ra)
{
CoinZoneScopedN("SoHandleEventAction::doPick");
if (!this->event || !this->pickroot) return;

SbBool didapply = FALSE;
ra->setPoint(this->event->getPosition());

// Scene-level BVH: set the active BVH for SoShape::rayPick() to use.
// On first pick: shapes collect their world-space bboxes.
// On subsequent picks: the first shape triggers a BVH query to populate
// the candidate set, then all shapes self-filter.
SoSceneBVH * sceneBVH = SoSceneBVH::getForRoot(this->pickroot);
SoSceneBVH::setCollecting(sceneBVH);
SoSceneBVH::setActiveCandidates(NULL); // reset from previous pick

if (this->owner->getWhatAppliedTo() == SoAction::PATH) {
const SoPath * path = this->owner->getPathAppliedTo();
if (path->getHead() == this->pickroot) {
Expand All @@ -436,6 +450,14 @@ SoHandleEventActionP::doPick(SoRayPickAction * ra)
}
}
if (!didapply) ra->apply(this->pickroot);

SoSceneBVH::setCollecting(NULL);

// Build scene BVH from collected shapes (first pick only)
if (sceneBVH && !sceneBVH->isBuilt() && sceneBVH->numShapes() > 0) {
sceneBVH->build();
}

this->didpickall = ra->isPickAll();
this->pickvalid = TRUE;
}
Expand Down
9 changes: 9 additions & 0 deletions src/caches/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# source files
set(COIN_CACHES_FILES
SoBoundingBoxCache.cpp
SoBVHCache.cpp
SoChildBVH.cpp
SoSceneBVH.cpp
SoCache.cpp
SoConvexDataCache.cpp
SoGLCacheList.cpp
Expand All @@ -15,6 +18,12 @@ set(COIN_CACHES_FILES

# Files excluded from public API documentation, included in complete documentation.
set(COIN_CACHES_INTERNAL_FILES
SoBVHCache.h
SoBVHCache.cpp
SoChildBVH.h
SoChildBVH.cpp
SoSceneBVH.h
SoSceneBVH.cpp
SoGlyphCache.h
SoGlyphCache.cpp
SoShaderProgramCache.h
Expand Down
Loading
Loading