Skip to content

Instantly share code, notes, and snippets.

@Pierre-Terdiman
Pierre-Terdiman / gist:9dfd924840eca5c97b67b637289e5360
Created May 9, 2025 23:18
Box-on-plane jumps instead of sliding smoothly (MuJoCo 3.2.2)
<!--
Simple box-on-plane test. I expected the box sliding smoothly on the plane
(both have low friction, etc) but instead the box starts jumping (at 60 Hz).
I have to decrease the timestep significantly for this to start working.
Any idea how to make this work at 60 Hz ?
-->
<mujoco model="SlidingBox">
<statistic meansize="1"/>
<option timestep="0.016666"/>
<!--<option timestep="0.002"/> <!-- even at 500Hz the cube eventually starts jumping -->
@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