Skip to content

Instantly share code, notes, and snippets.

@Pierre-Terdiman
Pierre-Terdiman / gist:9388e5c29a8f678d7278275c73bce29b
Last active November 9, 2024 07:48
Adding PhysX to tinyBVH benchmark
See https://github.com/jbikker/tinybvh
PhysX is a general purpose library not focused on raycasts and the best setup for raycast performance may not be obvious.
Here is the code I used in the tiny BVH benchmark. Results: https://x.com/PierreTerdiman/status/1854629430246748455
Adapted from https://github.com/NVIDIA-Omniverse/PhysX/tree/main/physx/snippets/snippetpathtracing
For building:
#ifdef PHYSX_BUILD
const bool quantized = false; // quantized trees use less memory but are usually slower for raycasts
const bool useSAH = false; // SAH build is much slower but can give slightly better perf. Not the PhysX default.
#include <ctype.h>
#include <chrono>
#include <iostream>
#include "PxPhysicsAPI.h"
#include "../snippetcommon/SnippetPrint.h"
#include "../snippetcommon/SnippetPVD.h"
#include "../snippetutils/SnippetUtils.h"
#ifdef RENDER_SNIPPET
#include "../snippetrender/SnippetRender.h"
#endif
@Pierre-Terdiman
Pierre-Terdiman / gist:d51dacd0f1edd7d356242e97657b12ed
Created February 17, 2017 16:00
Preview of part 14 - merging my unrolled version (the "safe loop" here) with Ryg's version converted to C++
#ifdef SAFE_VERSION
#define SIMD_OVERLAP_TEST (_mm_movemask_ps(_mm_cmpngt_ps(b, _mm_load_ps(box)))==15)
#else
#define SIMD_OVERLAP_TEST (_mm_movemask_ps(_mm_cmpnle_ps(_mm_load_ps(box), b))==12)
#endif
bool Meshmerizer::CompleteBoxPruning(udword nb, const AABB* list, Container& pairs)
{
// Checkings