src/level.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 52 53 54 55 56 |
package main
import cm "common"
import sim "simulation"
import clt "client"
CubeInfo :: struct {
center: [3]cm.iFP,
lwh: [3]cm.iFP
}
InitDebugCube :: proc(
info: CubeInfo,
eKin: ^[dynamic]Maybe(sim.DerivX),
aabbs: ^[dynamic]Maybe(sim.AABB),
boxes: ^[dynamic]Maybe(clt.AABox),
ecKin: ^[dynamic]Maybe(clt.DerivXFloat)
) {
using sim
using cm
using clt
index, found := AvailableSlot()
if !found do return
x := DerivX {
x = info.center,
}
bb := AABB {
solid = true,
min = [3]iFP{-Div(info.lwh[0],TWO_METER),-Div(info.lwh[1],TWO_METER),-Div(info.lwh[2],TWO_METER)},
max = [3]iFP{Div(info.lwh[0],TWO_METER),Div(info.lwh[1],TWO_METER),Div(info.lwh[2],TWO_METER)}
}
b := AABox {
max = cm.ToFloatVector(bb.max),
min = cm.ToFloatVector(bb.min)
}
cx := DerivXFloat {
x = cm.ToFloatVector(x.x)
}
eKin^[index] = x
ecKin^[index] = cx
aabbs^[index] = bb
boxes^[index] = b
// Add Octree to funcuntion procs
AddEntityToNode(index,FindEnclosingNode(bb,x.x,&octree))
}
SpawnLevelObjects :: proc() {
using cm
using clt
InitDebugCube(CubeInfo {
center=[3]iFP{0,-METER,0},
lwh=[3]iFP{TWO_METER,TWO_METER,TWO_METER}
}, sim.entityDerivX[0], sim.entityAABB[0], &debugBoxes, &clientEntityDerivX)
}
|