MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / checkWorld

Function checkWorld

3rd_party/Src/ode/ode/src/ode.cpp:138–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136// check the validity of the world data structures
137
138static void checkWorld (dxWorld *w)
139{
140 dxBody *b;
141 dxJoint *j;
142
143 // check there are no loops
144 if (listHasLoops (w->firstbody)) dDebug (0,"body list has loops");
145 if (listHasLoops (w->firstjoint)) dDebug (0,"joint list has loops");
146
147 // check lists are well formed (check `tome' pointers)
148 for (b=w->firstbody; b; b=(dxBody*)b->next) {
149 if (b->next && b->next->tome != &b->next)
150 dDebug (0,"bad tome pointer in body list");
151 }
152 for (j=w->firstjoint; j; j=(dxJoint*)j->next) {
153 if (j->next && j->next->tome != &j->next)
154 dDebug (0,"bad tome pointer in joint list");
155 }
156
157 // check counts
158 int n = 0;
159 for (b=w->firstbody; b; b=(dxBody*)b->next) n++;
160 if (w->nb != n) dDebug (0,"body count incorrect");
161 n = 0;
162 for (j=w->firstjoint; j; j=(dxJoint*)j->next) n++;
163 if (w->nj != n) dDebug (0,"joint count incorrect");
164
165 // set all tag values to a known value
166 static int count = 0;
167 count++;
168 for (b=w->firstbody; b; b=(dxBody*)b->next) b->tag = count;
169 for (j=w->firstjoint; j; j=(dxJoint*)j->next) j->tag = count;
170
171 // check all body/joint world pointers are ok
172 for (b=w->firstbody; b; b=(dxBody*)b->next) if (b->world != w)
173 dDebug (0,"bad world pointer in body list");
174 for (j=w->firstjoint; j; j=(dxJoint*)j->next) if (j->world != w)
175 dDebug (0,"bad world pointer in joint list");
176
177 /*
178 // check for half-connected joints - actually now these are valid
179 for (j=w->firstjoint; j; j=(dxJoint*)j->next) {
180 if (j->node[0].body || j->node[1].body) {
181 if (!(j->node[0].body && j->node[1].body))
182 dDebug (0,"half connected joint found");
183 }
184 }
185 */
186
187 // check that every joint node appears in the joint lists of both bodies it
188 // attaches
189 for (j=w->firstjoint; j; j=(dxJoint*)j->next) {
190 for (int i=0; i<2; i++) {
191 if (j->node[i].body) {
192 int ok = 0;
193 for (dxJointNode *n=j->node[i].body->firstjoint; n; n=n->next) {
194 if (n->joint == j) ok = 1;
195 }

Callers 2

dWorldCheckFunction · 0.85
dTestDataStructuresFunction · 0.85

Calls 2

listHasLoopsFunction · 0.85
dDebugFunction · 0.85

Tested by

no test coverage detected