MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ObjectCollision

Method ObjectCollision

engine/Poseidon/World/Simulation/Collisions.cpp:148–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146#define DIAG_VISIBLE_THROUGH 0
147
148void Landscape::ObjectCollision(CollisionBuffer& retVal, Object* with, const Frame& withPos, bool onlyVehicles) const
149{
150 if (!with->GetShape()->GeometryLevel())
151 {
152 return; // no geometry - no test
153 }
154 Vector3Val nPos = withPos.Position();
155 Vector3Val oPos = with->Position();
156 float radius = with->GetRadius();
157 int xMin, xMax, zMin, zMax;
158 ObjRadiusRectangle(xMin, xMax, zMin, zMax, oPos, nPos, radius);
159 int x, z;
160 for (x = xMin; x <= xMax; x++)
161 {
162 for (z = zMin; z <= zMax; z++)
163 {
164 const ObjectList& list = _objects(x, z);
165 int n = list.Size();
166 for (int i = 0; i < n; i++)
167 {
168 Object* obj = list[i];
169 if (obj == with)
170 {
171 continue;
172 }
173 if (obj->GetType() == Network && obj->GetShape()->FindGeometryLevel() < 0)
174 {
175 continue; // no collisions with roads
176 }
177 if (obj->GetType() == Temporary)
178 {
179 continue; // no collisions with temporary
180 }
181 if (obj->GetType() == TypeTempVehicle)
182 {
183 continue;
184 }
185 if (onlyVehicles)
186 {
187 if (obj->Static())
188 {
189 continue;
190 }
191 }
192 // do not collide with "soft" dead objects (man bodies, trees)
193 if (!obj->HasGeometry())
194 {
195 continue;
196 }
197 // ObjectCollision(retVal,obj,with,withPos,prec);
198 obj->Intersect(retVal, with);
199 }
200 }
201 }
202}
203
204struct CheckObjectCollisionContext
205{

Callers 15

ClipCameraFunction · 0.80
ScanContactPointsMethod · 0.80
DrawFlaresMethod · 0.80
SimulateMethod · 0.80
DirectHitCheckFunction · 0.80
SimulateMethod · 0.80
SimulateMethod · 0.80
SimulateMethod · 0.80
SimulateMethod · 0.80
SimulateMethod · 0.80
SimulateMethod · 0.80
AIPilotMethod · 0.80

Calls 9

ObjRadiusRectangleFunction · 0.85
GeometryLevelMethod · 0.80
FindGeometryLevelMethod · 0.80
IntersectMethod · 0.80
GetShapeMethod · 0.45
PositionMethod · 0.45
SizeMethod · 0.45
GetTypeMethod · 0.45
HasGeometryMethod · 0.45

Tested by

no test coverage detected