Closed huweiATgithub closed 3 years ago
I have been doing some work on Box2D-Lite and your ticket caught my attention.
It also looked to me that fp.value
is only ever set to 0 but thats not the case.
If you look at the definition of FeaturePair
we can see that its actually a union type so setting inEdge1
, etc will also affect value
. This seems like just a way to speed up comparisons between all of these char
members using type punning.
union FeaturePair
{
struct Edges
{
char inEdge1;
char outEdge1;
char inEdge2;
char outEdge2;
} e;
int value;
};
Oh, I see. Thank you!
Hi Erin, Thank you for your great illustrative code, it is very good for learning rigid body dynamics.
From Arbiter::Update, https://github.com/erincatto/box2d-lite/blob/227b71b6974ea57ab7e96d40f6374287bd6a0e77/src/Arbiter.cpp#L40-L50 I think FeaturePair.value is used to distinguish contacts. While in Collide.cpp where contacts are computed, the only place to set value is in ClipVertex's constructor which set value=0. https://github.com/erincatto/box2d-lite/blob/227b71b6974ea57ab7e96d40f6374287bd6a0e77/src/Collide.cpp#L44-L49 Does it seem like this value is not correctly assigned for its purpose?
Thank you.