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

Method UpdateObjectBox

ogsr_engine/xrGame/PHMovementControl.cpp:1167–1198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1165}
1166
1167void CPHMovementControl::UpdateObjectBox(CPHCharacter* ach)
1168{
1169 if (!m_character || !m_character->b_exist)
1170 return;
1171 if (!ach || !ach->b_exist)
1172 return;
1173 Fvector cbox;
1174 PKinematics(pObject->Visual())->CalculateBones();
1175 pObject->BoundingBox().getradius(cbox);
1176 const Fvector& pa = cast_fv(dBodyGetPosition(ach->get_body()));
1177 const Fvector& p = cast_fv(dBodyGetPosition(m_character->get_body()));
1178 Fvector2 poses_dir;
1179 poses_dir.set(p.x - pa.x, p.z - pa.z);
1180 float plane_dist = poses_dir.magnitude();
1181 if (plane_dist > 2.f)
1182 return;
1183 if (plane_dist > EPS_S)
1184 poses_dir.mul(1.f / plane_dist);
1185 Fvector2 plane_cam;
1186 plane_cam.set(Device.vCameraDirection.x, Device.vCameraDirection.z);
1187 plane_cam.normalize_safe();
1188 Fvector2 plane_i;
1189 plane_i.set(pObject->XFORM().i.x, pObject->XFORM().i.z);
1190 Fvector2 plane_k;
1191 plane_k.set(pObject->XFORM().k.x, pObject->XFORM().k.z);
1192 float R = _abs(poses_dir.dotproduct(plane_i) * cbox.x) + _abs(poses_dir.dotproduct(plane_k) * cbox.z);
1193 R *= poses_dir.dotproduct(plane_cam); //(poses_dir.x*plane_cam.x+poses_dir.y*plane_cam.z);
1194 Calculate(Fvector().set(0, 0, 0), Fvector().set(1, 0, 0), 0, 0, 0, 0);
1195 m_character->SetObjectRadius(R);
1196 ach->ChooseRestrictionType(CPHCharacter::rtStalker, 1.f, m_character);
1197 m_character->UpdateRestrictionType(ach);
1198}
1199
1200void CPHMovementControl::SetPathDir(const Fvector& v)
1201{

Callers 1

UpdateCLMethod · 0.80

Calls 15

PKinematicsFunction · 0.85
dBodyGetPositionFunction · 0.85
VisualMethod · 0.80
SetObjectRadiusMethod · 0.80
UpdateRestrictionTypeMethod · 0.80
_absFunction · 0.50
CalculateBonesMethod · 0.45
getradiusMethod · 0.45
get_bodyMethod · 0.45
setMethod · 0.45
magnitudeMethod · 0.45
mulMethod · 0.45

Tested by

no test coverage detected