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

Method Render

ogsr_engine/xrGame/Level_Bullet_Manager.cpp:311–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311void CBulletManager::Render()
312{
313#ifdef DEBUG
314 // 0-рикошет
315 // 1-застрявание пули в материале
316 // 2-пробивание материала
317 if (g_bDrawBulletHit)
318 {
319 extern FvectorVec g_hit[];
320 FvectorIt it;
321 u32 C[3] = {0xffff0000, 0xff00ff00, 0xff0000ff};
322 RCache.set_xform_world(Fidentity);
323 for (int i = 0; i < 3; ++i)
324 for (it = g_hit[i].begin(); it != g_hit[i].end(); ++it)
325 {
326 Level().debug_renderer().draw_aabb(*it, 0.01f, 0.01f, 0.01f, C[i]);
327 }
328 }
329#endif
330
331 if (m_BulletsRendered.empty())
332 return;
333
334 u32 bullet_num = m_BulletsRendered.size();
335
336 UIRender->StartPrimitive((u32)bullet_num * 12, IUIRender::ptTriList, IUIRender::pttLIT);
337
338 for (auto& bullet : m_BulletsRendered)
339 {
340 if (!bullet.flags.allow_tracer)
341 continue;
342 if (!bullet.flags.skipped_frame)
343 continue;
344
345 float length = bullet.speed * float(m_dwStepTime) / 1000.f; // dist.magnitude();
346
347 if (length < m_fTracerLengthMin)
348 continue;
349
350 if (length > m_fTracerLengthMax)
351 length = m_fTracerLengthMax;
352
353 float width = m_fTracerWidth;
354 float dist2segSqr = SqrDistancePointToSegment(Device.vCameraPosition, bullet.pos, Fvector().mul(bullet.dir, length));
355 //---------------------------------------------
356 float MaxDistSqr = 1.0f;
357 float MinDistSqr = 0.09f;
358 if (dist2segSqr < MaxDistSqr)
359 {
360 if (dist2segSqr < MinDistSqr)
361 dist2segSqr = MinDistSqr;
362
363 width *= _sqrt(dist2segSqr / MaxDistSqr); //*MaxDistWidth/0.08f;
364 }
365 if (Device.vCameraPosition.distance_to_sqr(bullet.pos) < (length * length))
366 {
367 length = Device.vCameraPosition.distance_to(bullet.pos) - 0.3f;
368 }

Callers

nothing calls this directly

Calls 15

_sqrtFunction · 0.85
draw_aabbMethod · 0.80
StartPrimitiveMethod · 0.80
distance_to_sqrMethod · 0.80
FlushPrimitiveMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
mulMethod · 0.45
distance_toMethod · 0.45

Tested by

no test coverage detected