all repos — engine.git @ 70d5a5f53436c4848616132f2ff47c4036adc224

Unnamed repository; edit this file 'description' to name the repository.

src/client/render.odin

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
package main

import rl "vendor:raylib"

AABox :: struct {
  min: [3]f32,
  max: [3]f32,
}

debugBoxes:  [dynamic]Maybe(AABox)


Render :: proc() {
	rl.BeginDrawing()
		rl.ClearBackground(rl.GRAY)

		rl.BeginMode3D(camera)
			DisplayDebugBoxes(&debugBoxes, &clientEntityDerivX)
			//DebugHighlightSector(&octree)
		rl.EndMode3D()
	
		DebugPlayerInfo()

	rl.EndDrawing()
}

DebugPlayerInfo :: proc() {
		kinematics, ok := player.kinematics[player.id].?
		if !ok { rl.EndDrawing(); return}

		rl.DrawText(rl.TextFormat("FPS: %i", rl.GetFPS()),10, 10, 20, rl.RED)
		x := ToFloatVector(kinematics.x)
		v := ToFloatVector(kinematics.v)
		a := ToFloatVector(kinematics.a)
		rl.DrawText(rl.TextFormat("Position: %f %f %f", x[0], x[1], x[2]),10, 50, 20, rl.RED)
		rl.DrawText(rl.TextFormat("Velocity: %f %f %f", v[0], v[1], v[2]),10, 100, 20, rl.RED)
		rl.DrawText(rl.TextFormat("Acceleration: %f %f %f", a[0], a[1], a[2]),10, 150, 20, rl.RED)
}

DisplayDebugBoxes :: proc(boxes: ^[dynamic]Maybe(AABox), positions: ^[dynamic]Maybe(DerivXFloat)) {
	for b,i in boxes^ {
		box, ok1 := b.?
		pos, ok2 := positions[i].?
		if !(ok1 && ok2) do continue
		
		length := box.max[0]-box.min[0]
		height := box.max[1]-box.min[1]
		width := box.max[2]-box.min[2]
		rl.DrawCube(pos.x,length,height,width,rl.RED)
	}
}