0.6 physics error messages

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
The Burrito
Party member
Posts: 153
Joined: Mon Sep 21, 2009 12:14 am
Contact:

0.6 physics error messages

Post by The Burrito » Wed Nov 04, 2009 1:37 am

Recently I've been noticing a lot of pop up errors from box2d.
I determined that some were related to drawing polygons wrong (as in not listing the coordinates in a counter clockwise fashion).
but I still frequently get this:
box2derror.jpg
box2derror.jpg (45.9 KiB) Viewed 959 times
This is the chunk that its refering to:

Code: Select all

   205 	// Create core polygon shape by shifting edges inward.
   206 	// Also compute the min/max radius for CCD.
   207 	for (int32 i = 0; i < m_vertexCount; ++i)
   208 	{
   209 		int32 i1 = i - 1 >= 0 ? i - 1 : m_vertexCount - 1;
   210 		int32 i2 = i;
   211 
   212 		b2Vec2 n1 = m_normals[i1];
   213 		b2Vec2 n2 = m_normals[i2];
   214 		b2Vec2 v = m_vertices[i] - m_centroid;;
   215 
   216 		b2Vec2 d;
   217 		d.x = b2Dot(n1, v) - b2_toiSlop;
   218 		d.y = b2Dot(n2, v) - b2_toiSlop;
   219 
   220 		// Shifting the edge inward by b2_toiSlop should
   221 		// not cause the plane to pass the centroid.
   222 
   223 		// Your shape has a radius/extent less than b2_toiSlop.
   224 		b2Assert(d.x >= 0.0f);
   225 		b2Assert(d.y >= 0.0f);
   226 		b2Mat22 A;
   227 		A.col1.x = n1.x; A.col2.x = n1.y;
   228 		A.col1.y = n2.x; A.col2.y = n2.y;
   229 		m_coreVertices[i] = A.Solve(d) + m_centroid;
   230 	}
   231 }
I don't really understand whats going on here but my code that causes the problem generates triangles to fill in spaces.
Also on occasion I'm getting crashes that are attributed to random modules, not really sure whats causing them, but I wonder if it might be related.

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: 0.6 physics error messages

Post by bartbes » Wed Nov 04, 2009 6:53 am

It basically means your objects are too small. Keep in mind that in 0.6.0 a physics unit equals 60 pixels by default. (IIRC) So, anything passed to the physics engine is 1/60th the size of what it was in 0.5.0.

User avatar
The Burrito
Party member
Posts: 153
Joined: Mon Sep 21, 2009 12:14 am
Contact:

Re: 0.6 physics error messages

Post by The Burrito » Wed Nov 04, 2009 4:31 pm

OK, I thought it might be something like that, I guess I'll just have to add something to avoid making extremely thin shapes. And I guess changing the scale would help out, since I never had any issues in 0.5.0.
According to the Box2D manual: "Keep the size of moving objects roughly between 0.1 and 10 meters."

world:getMeter() tells me 30
so I take it I should :setMeter() to the smallest value I can without me making moving objects over 10 meters (which will probably be about 10-15)

Thanks for the help.

User avatar
The Burrito
Party member
Posts: 153
Joined: Mon Sep 21, 2009 12:14 am
Contact:

Re: 0.6 physics error messages

Post by The Burrito » Tue Nov 10, 2009 7:05 pm

Well having gotten that sorted, I've found that I get random crashes that are in some way related to destroy().
by removing that line and just writing over the old shapes my random crashes disappear, but after a while I get another box2d error message saying something about pair counts.
Refers to this:

Code: Select all

// Returns existing pair or creates a new one.
   122 b2Pair* b2PairManager::AddPair(int32 proxyId1, int32 proxyId2)
   123 {
   124 	if (proxyId1 > proxyId2) b2Swap(proxyId1, proxyId2);
   125 
   126 	int32 hash = Hash(proxyId1, proxyId2) & b2_tableMask;
   127 
   128 	b2Pair* pair = Find(proxyId1, proxyId2, hash);
   129 	if (pair != NULL)
   130 	{
   131 		return pair;
   132 	}
   133 
   134 	b2Assert(m_pairCount < b2_maxPairs && m_freePair != b2_nullPair);
   135 
   136 	uint16 pairIndex = m_freePair;
   137 	pair = m_pairs + pairIndex;
   138 	m_freePair = pair->next;
   139 
   140 	pair->proxyId1 = (uint16)proxyId1;
   141 	pair->proxyId2 = (uint16)proxyId2;
   142 	pair->status = 0;
   143 	pair->userData = NULL;
   144 	pair->next = m_hashTable[hash];
   145 
   146 	m_hashTable[hash] = pairIndex;
   147 
   148 	++m_pairCount;
   149 
   150 	return pair;
   151 }
I'm assuming something isn't being cleared in box2d, even though it otherwise functions correctly.

User avatar
rude
Administrator
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: 0.6 physics error messages

Post by rude » Tue Nov 10, 2009 7:54 pm

Try 38dc19cb5b9e. :monocle:

User avatar
The Burrito
Party member
Posts: 153
Joined: Mon Sep 21, 2009 12:14 am
Contact:

Re: 0.6 physics error messages

Post by The Burrito » Wed Nov 11, 2009 12:52 am

Yay! thank you for the incredibly prompt fixing.
I think I may finally be out of excuses for why my game doesn't work correctly. ^^

Post Reply

Who is online

Users browsing this forum: No registered users and 63 guests