From cf2abfcfe34a9b3e4cf5af193d1f320374416267 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 18 Jan 2025 16:19:41 +1100 Subject: convert models and editor to use ecs --- model.cpp | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) (limited to 'model.cpp') diff --git a/model.cpp b/model.cpp index ccef4c6..7f2ac7f 100644 --- a/model.cpp +++ b/model.cpp @@ -464,54 +464,3 @@ void Model_Scene::destroy(Device* dev) { for (i = 0; i < count; i++, instance++) instance->destroy(dev, h); } - -std::pair Model_Scene::pick( - const Camera& cam, - int w, - int h, - int mx, - int my -) { - int i, c = count; - v2f uv = (2.0f * v2f(mx, my) - v2f(w, h)) / (float)h; - v4f e = - cam.get_proj().inverse() * - v4f(uv.x, uv.y, -1.0f, 1.0f); - e.z = -1.0f; e.w = 0.0f; - v4f d4 = cam.get_view().inverse() * e; - v3f d = v3f::normalised(v3f(d4.x, d4.y, d4.z)); - const v3f& o = cam.position; - float t = INFINITY; - Model_Instance* r1 = 0; - int r2 = -1; - for (i = 0; i < c; i++) { - Model_Instance& inst = instances[i]; - Model* m = inst.m; - int j; - for (j = 0; j < m->mesh_count; j++) { - AABB& b = inst.bounds[j]; - v3f id = 1.0f / d; - v3f t1 = (b.min - o) * id; - v3f t2 = (b.max - o) * id; - float tmin = std::max(std::max( - std::min(t1.x, t2.x), - std::min(t1.y, t2.y)), - std::min(t1.z, t2.z) - ); - float tmax = std::min(std::min( - std::max(t1.x, t2.x), - std::max(t1.y, t2.y)), - std::max(t1.z, t2.z) - ); - if (tmax < 0.0f || tmin > tmax) - continue; - if (tmin < t) { - t = tmin; - r1 = &inst; - r2 = j; - } - } - } - return { r1, r2 }; -} - -- cgit v1.2.3-54-g00ecf