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

Function collide_camera

ogsr_engine/xrGame/ActorCameraCollision.cpp:343–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343void collide_camera(CCameraBase& camera, float _viewport_near, CPhysicsShellHolder* l_actor, bool on_ladder)
344{
345 ZoneScoped;
346
347 // CPhysicsShellHolder* l_actor = smart_cast<CPhysicsShellHolder*>( Level().CurrentEntity() );
348 VERIFY(l_actor);
349 update_current_entity_camera_collision(l_actor);
350 Fvector box_size;
351 Fmatrix xform;
352 get_camera_box(box_size, xform, camera, _viewport_near);
353 CPhysicsShell* shell = actor_camera_shell;
354 VERIFY(shell);
355 CPhysicsElement* roote = shell->get_ElementByStoreOrder(0);
356 VERIFY(roote);
357 CODEGeom* root_geom = roote->geometry(0);
358 VERIFY(root_geom);
359 CBoxGeom* box = smart_cast<CBoxGeom*>(root_geom);
360 VERIFY(box);
361 Fvector old_box_size;
362 Fmatrix old_form;
363 get_old_camera_box(old_box_size, old_form, roote, box);
364 if (clamp_change(old_form, xform, EPS, EPS, EPS, EPS) && Fvector().sub(old_box_size, box_size).magnitude() < EPS)
365 return;
366
367 //static Fvector cam_vDirection = {0.f, 0.f, 0.f};
368 //static Fvector cam_vPosition = {0.f, 0.f, 0.f};
369 //static Fvector collided_vPosition = camera.vPosition;
370 //static bool collided = false;
371 //float cam_diff = Fvector().sub(cam_vPosition, camera.vPosition).magnitude();
372 //float cam_ddiff = Fvector().sub(cam_vDirection, camera.vDirection).magnitude();
373 //bool cam_moved = !fis_zero(cam_diff, 0.01f) || !fis_zero(cam_ddiff, 0.001f);
374 //if (collided && !cam_moved)
375 //{
376 // camera.vPosition = collided_vPosition;
377 // return;
378 //}
379 //else if (!cam_moved)
380 //{
381 // return;
382 //}
383 //cam_vDirection = camera.vDirection;
384 //cam_vPosition = camera.vPosition;
385 //collided = false;
386
387 if (on_ladder)
388 return;
389
390 set_camera_collision(box_size, xform, roote, box);
391
392 /*
393 #ifdef DEBUG
394 if( dbg_draw_camera_collision )
395 {
396 debug_output().DBG_DrawMatrix( Fmatrix().translate( xform.c ), 1 );
397 shell->dbg_draw_geometry( 1, D3DCOLOR_XRGB(0, 0, 255 ) );
398 }
399 #endif
400 */

Callers 1

cam_UpdateMethod · 0.85

Calls 13

get_camera_boxFunction · 0.85
get_old_camera_boxFunction · 0.85
set_camera_collisionFunction · 0.85
do_collide_and_moveFunction · 0.85
DirectionMethod · 0.80
clamp_changeFunction · 0.50
geometryMethod · 0.45
magnitudeMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected