reactphysics3d icon indicating copy to clipboard operation
reactphysics3d copied to clipboard

Fix Issue #416: Implement dynamic resource file location for testbed

Open killerdevildog opened this issue 6 months ago • 0 comments

This commit addresses the hardcoded relative path issue that caused problems when different compilers/IDEs placed executables in different directories.

Key Changes:

  • Added ResourceManager class for dynamic resource path discovery
  • Searches up to 4 parent directories for testbed/shaders and testbed/meshes
  • Supports RP3D_RESOURCE_PATH environment variable override
  • Maintains backwards compatibility with fallback to relative paths
  • Uses std::filesystem for cross-platform path handling

Files Added:

  • testbed/common/ResourceManager.h - Header with dynamic path discovery API
  • testbed/common/ResourceManager.cpp - Implementation with filesystem search
  • dynamicresourcefilelocation.md - Comprehensive documentation

Files Modified:

  • testbed/src/SceneDemo.cpp - Updated shader and mesh folder paths
  • testbed/common/*.cpp - Updated all hardcoded mesh paths (Box, Sphere, etc.)
  • testbed/scenes//.cpp - Updated scene-specific mesh paths
  • testbed/CMakeLists.txt - Added ResourceManager to build system

Benefits:

  • Cross-platform compatibility across different build environments
  • No manual configuration required for developers
  • Robust error handling with informative fallback warnings
  • Performance optimized with path caching

Tested successfully with CMake build system - application now runs without file not found errors regardless of build directory structure.

killerdevildog avatar Jul 30 '25 05:07 killerdevildog