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

Method Collide

ogsr_engine/xrGame/PHObject.cpp:86–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void CPHObject::Collide()
87{
88 if (m_flags.test(fl_ray_motions))
89 {
90 CPHMoveStorage* tracers = MoveStorage();
91 CPHMoveStorage::iterator I = tracers->begin(), E = tracers->end();
92 for (; E != I; ++I)
93 {
94 const Fvector *from = 0, *to = 0;
95 Fvector dir;
96 I.Positions(from, to);
97 if (from->x == -dInfinity)
98 continue;
99 dir.sub(*to, *from);
100 float magnitude = dir.magnitude();
101 if (magnitude < EPS)
102 continue;
103 dir.mul(1.f / magnitude);
104 g_SpatialSpacePhysic->q_ray(ph_world->r_spatial, 0, STYPE_PHYSIC, *from, dir, magnitude); //|ISpatial_DB::O_ONLYFIRST
105#ifdef DEBUG
106 if (ph_dbg_draw_mask.test(phDbgDrawRayMotions))
107 {
108 DBG_OpenCashedDraw();
109 DBG_DrawLine(*from, Fvector().add(*from, Fvector().mul(dir, magnitude)), D3DCOLOR_XRGB(0, 255, 0));
110 DBG_ClosedCashedDraw(30000);
111 }
112
113#endif
114 qResultVec& result = ph_world->r_spatial;
115 qResultIt i = result.begin(), e = result.end();
116 for (; i != e; ++i)
117 {
118 CPHObject* obj2 = static_cast<CPHObject*>(*i);
119 if (obj2 == this || !obj2->m_flags.test(st_dirty))
120 continue;
121 dGeomID motion_ray = ph_world->GetMotionRayGeom();
122 dGeomRayMotionSetGeom(motion_ray, I.dGeom());
123 dGeomRayMotionsSet(motion_ray, (const dReal*)from, (const dReal*)&dir, magnitude);
124 NearCallback(this, obj2, motion_ray, obj2->dSpacedGeom());
125 }
126 }
127 }
128 CollideDynamics();
129 ///////////////////////////////
130 if (CPHCollideValidator::DoCollideStatic(*this))
131 CollideStatic(dSpacedGeom(), this);
132 m_flags.set(st_dirty, FALSE);
133}
134void CPHObject::CollideDynamics()
135{
136 g_SpatialSpacePhysic->q_box(ph_world->r_spatial, 0, STYPE_PHYSIC, spatial.sphere.P, AABB);

Callers

nothing calls this directly

Calls 15

DBG_OpenCashedDrawFunction · 0.85
DBG_DrawLineFunction · 0.85
DBG_ClosedCashedDrawFunction · 0.85
dGeomRayMotionSetGeomFunction · 0.85
dGeomRayMotionsSetFunction · 0.85
NearCallbackFunction · 0.85
CollideStaticFunction · 0.85
PositionsMethod · 0.80
q_rayMethod · 0.80
testMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected