MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / IsPointInCylinder

Function IsPointInCylinder

physics/findintersection.cpp:1260–1281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1258}
1259
1260bool IsPointInCylinder(vector *normal, vector *cylinder_pnt, vector *edir, float elen, const float rad,
1261 const vector *pnt, vector *mdir, bool *f_collide) {
1262 float plen = (*pnt - *cylinder_pnt) * *edir;
1263
1264 if (plen < 0.0f || plen > elen) {
1265 return false;
1266 }
1267
1268 vector newp = *cylinder_pnt + *edir * plen;
1269 *normal = *pnt - newp;
1270
1271 if (vm_NormalizeVector(normal) >= rad) {
1272 return false;
1273 }
1274
1275 if (*normal * *mdir >= 0.0f)
1276 *f_collide = false;
1277 else
1278 *f_collide = true;
1279
1280 return true;
1281}
1282
1283// check if a sphere intersects a face -- this can be optimized (only need 2d stuff after rotation)
1284int check_vector_to_cylinder(vector *colp, vector *intp, float *col_dist, vector *wall_norm, const vector *p0,

Callers 1

check_vector_to_cylinderFunction · 0.85

Calls 1

vm_NormalizeVectorFunction · 0.85

Tested by

no test coverage detected