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

Function dCollideTransform

3rd_party/Src/ode/ode/src/collision_transform.cpp:120–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118// also be a transformed geom, but this case is not handled specially.
119
120int dCollideTransform (dxGeom *o1, dxGeom *o2, int flags,
121 dContactGeom *contact, int skip)
122{
123 dIASSERT (skip >= (int)sizeof(dContactGeom));
124 dIASSERT (o1->type == dGeomTransformClass);
125
126 dxGeomTransform *tr = (dxGeomTransform*) o1;
127 if (!tr->obj) return 0;
128 dUASSERT (tr->obj->parent_space==0,
129 "GeomTransform encapsulated object must not be in a space");
130 dUASSERT (tr->obj->body==0,
131 "GeomTransform encapsulated object must not be attached "
132 "to a body");
133
134 // backup the relative pos and R pointers of the encapsulated geom object,
135 // and the body pointer
136 dReal *posbak = tr->obj->pos;
137 dReal *Rbak = tr->obj->R;
138 dxBody *bodybak = tr->obj->body;
139
140 // compute temporary pos and R for the encapsulated geom object.
141 // note that final_pos and final_R are valid if no GEOM_AABB_BAD flag,
142 // because computeFinalTx() will have already been called in
143 // dxGeomTransform::computeAABB()
144
145 if (tr->gflags & GEOM_AABB_BAD) tr->computeFinalTx();
146 tr->obj->pos = tr->final_pos;
147 tr->obj->R = tr->final_R;
148 tr->obj->body = o1->body;
149
150 // do the collision
151 int n = dCollide (tr->obj,o2,flags,contact,skip);
152
153 // if required, adjust the 'g1' values in the generated contacts so that
154 // thay indicated the GeomTransform object instead of the encapsulated
155 // object.
156 if (tr->infomode) {
157 for (int i=0; i<n; i++) {
158 dContactGeom *c = CONTACT(contact,skip*i);
159 c->g1 = o1;
160 }
161 }
162
163 // restore the pos, R and body
164 tr->obj->pos = posbak;
165 tr->obj->R = Rbak;
166 tr->obj->body = bodybak;
167 return n;
168}
169
170//****************************************************************************
171// public API

Callers

nothing calls this directly

Calls 3

dCollideFunction · 0.85
computeFinalTxMethod · 0.80
CONTACTFunction · 0.70

Tested by

no test coverage detected