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

Method Calculate

ogsr_engine/xrGame/PHMovementControl.cpp:124–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void CPHMovementControl::Calculate(Fvector& vAccel, const Fvector& camDir, float /**ang_speed/**/, float jump, float /**dt/**/, bool /**bLight/**/)
125{
126 Fvector previous_position;
127 previous_position.set(vPosition);
128 m_character->IPosition(vPosition);
129
130 if (bExernalImpulse)
131 {
132 vAccel.add(vExternalImpulse);
133 m_character->ApplyForce(vExternalImpulse);
134 vExternalImpulse.set(0.f, 0.f, 0.f);
135
136 bExernalImpulse = false;
137 }
138
139 float mAccel = vAccel.magnitude();
140 m_character->SetCamDir(camDir);
141 m_character->SetMaximumVelocity(mAccel / 10.f);
142 m_character->SetAcceleration(vAccel);
143 if (!fis_zero(jump))
144 m_character->Jump(vAccel);
145
146 m_character->GetSavedVelocity(vVelocity);
147 fActualVelocity = vVelocity.magnitude();
148 gcontact_Was = m_character->ContactWas();
149
150 //////
151 UpdateCollisionDamage();
152 if (m_character->LastMaterialIDX() != u16(-1))
153 {
154 const SGameMtl* last_material = GMLib.GetMaterialByIdx(m_character->LastMaterialIDX());
155 if (last_material->Flags.test(SGameMtl::flInjurious))
156 {
157 gcontact_HealthLost += Device.fTimeDelta * last_material->fInjuriousSpeed;
158 }
159 }
160
161 auto* cdi = CollisionDamageInfo();
162
163 if (auto* hcb = cdi->HitCallback())
164 {
165 hcb->call(nullptr, fMinCrashSpeed, fMaxCrashSpeed, fContactSpeed, gcontact_HealthLost, cdi);
166 }
167
168 TraceBorder(previous_position);
169 CheckEnvironment(vPosition);
170 bSleep = false;
171 m_character->Reinit();
172}
173
174void CPHMovementControl::UpdateCollisionDamage()
175{

Callers

nothing calls this directly

Calls 15

fis_zeroFunction · 0.85
PH_DBG_ObjectTrackFunction · 0.85
MsgFunction · 0.85
ApplyForceMethod · 0.80
SetCamDirMethod · 0.80
GetSavedVelocityMethod · 0.80
ContactWasMethod · 0.80
HitCallbackMethod · 0.80
PositionMethod · 0.80
GetSmothedVelocityMethod · 0.80
setMethod · 0.45
IPositionMethod · 0.45

Tested by

no test coverage detected