MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / PrepareRopes

Method PrepareRopes

TombEngine/Renderer/RendererDraw.cpp:357–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355 }
356
357 void Renderer::PrepareRopes(RenderView& view)
358 {
359 for (const auto& rope : Ropes)
360 {
361 if (!rope.active)
362 continue;
363
364 auto translationMatrix = Matrix::CreateTranslation(rope.position.ToVector3());
365 auto absolutePoints = std::array<Vector3, 24>{};
366
367 for (int i = 0; i < rope.segment.size(); i++)
368 {
369 const auto* segment = &rope.PrevMeshSegments[i];
370
371 auto relPos = Vector3(segment->x >> FP_SHIFT, segment->y >> FP_SHIFT, segment->z >> FP_SHIFT);
372 auto prevOutput = Vector3::Transform(relPos, translationMatrix);
373
374 segment = &rope.meshSegment[i];
375
376 relPos = Vector3(segment->x >> FP_SHIFT, segment->y >> FP_SHIFT, segment->z >> FP_SHIFT);
377 auto currentOutput = Vector3::Transform(relPos, translationMatrix);
378
379 auto absolutePos = Vector3::Lerp(prevOutput, currentOutput, GetInterpolationFactor());
380 absolutePoints[i] = absolutePos;
381 }
382
383 for (int i = 0; i < (rope.segment.size() - 1); i++)
384 {
385 const auto& pos0 = absolutePoints[i];
386 const auto& pos1 = absolutePoints[i + 1];
387 auto pos = (pos0 + pos1) / 2;
388
389 auto dir = pos1 - pos0;
390 dir.Normalize();
391
392 AddSpriteBillboardConstrained(
393 &_sprites[Objects[ID_DEFAULT_SPRITES].meshIndex + SPR_EMPTY1],
394 pos, _rooms[rope.room].AmbientLight * g_Level.Items[rope.index].Model.Color,
395 PI_DIV_2, 1.0f, Vector2(32.0f, Vector3::Distance(pos0, pos1)), BlendMode::AlphaBlend, dir, false, view);
396 }
397 }
398 }
399
400 void Renderer::DrawLines2D()
401 {

Callers

nothing calls this directly

Calls 6

LerpFunction · 0.85
Vector3Function · 0.50
Vector2Function · 0.50
ToVector3Method · 0.45
sizeMethod · 0.45
NormalizeMethod · 0.45

Tested by

no test coverage detected