Giter VIP home page Giter VIP logo

Comments (2)

RandyGaul avatar RandyGaul commented on September 19, 2024

Thanks for this post. I wrote that code ages ago... And it looks buggy. Here is what I use in my qu3e repo, which should be robust.

// Artificial axis bias to improve frame coherence
const r32 kRelTol = r32( 0.95 );
const r32 kAbsTol = r32( 0.01 );
i32 axis;
r32 sMax;
q3Vec3 n;
r32 faceMax = q3Max( aMax, bMax );
if ( kRelTol * eMax > faceMax + kAbsTol )
{
	axis = eAxis;
	sMax = eMax;
	n = nE;
}
else
{
	if ( kRelTol * bMax > aMax + kAbsTol )
	{
		axis = bAxis;
		sMax = bMax;
		n = nB;
	}
	else
	{
		axis = aAxis;
		sMax = aMax;
		n = nA;
	}
}

So then to update our function here (no edge case, just two faces), it can look like:

inline bool BiasGreaterThan( real a, real b )
{
	const real k_relative = 0.95f;
	const real k_absolute = 0.01f;
	if (k_relative * a > b + k_absolute) {
		return true;
	} else {
		return false;
	}
}

Would you like to submit a pull request? If not I can make the modification. Let me know!

from impulseengine.

anon38 avatar anon38 commented on September 19, 2024

Wow thanks for the quick response! Your modification also fixes the issue. No more false negative intersections. However, I'm still experimenting with the bias in my engine (currently have sequential impulse solver+feature based contacts+warm starting working) to determine what is most stable. Interestingly enough, your original bias implementation was very stable with my stacking test cases (essentially just squares stacked in different nxm configurations). But I've come to realize that it is very dependent on the order of my pairs from the broadphase as this affects the distribution of the bias on each body. For example, when I add the bodies to the world in a reverse order, then the original bias becomes more unstable.

Anyway, your change does indeed fix the bug of missing intersections, which was the most critical issue. So you can feel free to make the modification. I'm going to continue to experiment in my own engine with different biases to determine which is most stable.

from impulseengine.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.