box2d icon indicating copy to clipboard operation
box2d copied to clipboard

unnecessary compassion in b2_collision.cpp

Open kritma opened this issue 2 years ago • 3 comments

	if (count < 3 || count > b2_maxPolygonVertices)
	{
		// check your data
		return hull;
	}

	count = b2Min(count, b2_maxPolygonVertices); //this line is unnecessary

kritma avatar Jun 10 '23 16:06 kritma

How?

krabhi1 avatar Oct 06 '23 19:10 krabhi1

count must always be less than or equal to b2_maxPolygonVertices according to the preceding if statement, so the call to b2Min is not required.

HughPH avatar Oct 06 '23 19:10 HughPH

@krabhi7 this is same as

if(count < 3) {
    return hull;
}

if(count > b2_maxPolygonVertices) {
    return hull;
}

count = b2Min(count, b2_maxPolygonVertices); // count <= b2_maxPolygonVertices because of early return

kritma avatar Oct 06 '23 22:10 kritma