, bounds()
, radius(0.0f)
, state()
+, model_transform(1.0f)
+, view_transform(1.0f)
+, speed(0.0f)
, heading(0.0f, 0.0f, -1.0f)
, max_vel(5.0f)
, max_force(25.0f)
Ray Entity::Aim(const ExactLocation::Coarse &chunk_offset) const noexcept {
glm::mat4 transform = ViewTransform(chunk_offset);
- return Ray{ glm::vec3(transform[3]), -glm::vec3(transform[2]) };
+ Ray ray{ glm::vec3(transform[3]), -glm::vec3(transform[2]) };
+ ray.Update();
+ return ray;
}
void Entity::Update(World &world, float dt) {
candidates.clear();
- // TODO: convert to coords based iteration and trim based
- // on ray direction
+ // TODO: change this so the test starts at the chunk of the ray's
+ // origin and "walks" forward until it hits (actually casting
+ // the ray, so to say). if this performs well (at least, better
+ // than now), this could also qualify for the chunk test itself
+ // see Bresenham's line algo or something similar
for (Chunk *cur_chunk : *index) {
float cur_dist;
if (cur_chunk && cur_chunk->Intersection(ray, reference, cur_dist)) {
PrimitiveMesh debug_mesh;
PlainColor &prog = viewport.WorldColorProgram();
for (const Entity &entity : entities) {
- debug_buf.OutlineBox(entity.Bounds(), glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
+ debug_buf.OutlineBox(entity.Bounds(), glm::tvec4<unsigned char>(255, 0, 0, 255));
debug_mesh.Update(debug_buf);
prog.SetM(entity.Transform(players.front().GetEntity().ChunkCoords()));
debug_mesh.DrawLines();