 			const auto* s = &ctxt->shapes[(int)attrib.x];
 
 			if (attrib.z >= 0) {	// exid
-				aten::ray transformedRay;
-
-				if (s->mtxid >= 0) {
-					auto mtxW2L = ctxt->matrices[s->mtxid * 2 + 1];
-					transformedRay.dir = mtxW2L.applyXYZ(r.dir);
-					transformedRay.dir = normalize(transformedRay.dir);
-					transformedRay.org = mtxW2L.apply(r.org) + AT_MATH_EPSILON * transformedRay.dir;
+				if (aten::aabb::hit(r, boxmin, boxmax, t_min, t_max, &t)) {
+					aten::ray transformedRay;
+
+					if (s->mtxid >= 0) {
+						auto mtxW2L = ctxt->matrices[s->mtxid * 2 + 1];
+						transformedRay.dir = mtxW2L.applyXYZ(r.dir);
+						transformedRay.dir = normalize(transformedRay.dir);
+						transformedRay.org = mtxW2L.apply(r.org) + AT_MATH_EPSILON * transformedRay.dir;
+					}
+					else {
+						transformedRay = r;
+					}
+
+					isHit = intersectBVHCloserTriangles(ctxt->nodes[(int)attrib.z], ctxt, transformedRay, t_min, t_max, &isectTmp);
 				}
-				else {
-					transformedRay = r;
-				}
-
-				isHit = intersectBVHCloserTriangles(ctxt->nodes[(int)attrib.z], ctxt, transformedRay, t_min, t_max, &isectTmp);
 			}
 			else {
 				// TODO

			const auto* s = &ctxt->shapes[(int)attrib.x];

			if (attrib.z >= 0) {	// exid
				aten::ray transformedRay;

				if (s->mtxid >= 0) {
					auto mtxW2L = ctxt->matrices[s->mtxid * 2 + 1];
					transformedRay.dir = mtxW2L.applyXYZ(r.dir);
					transformedRay.dir = normalize(transformedRay.dir);
					transformedRay.org = mtxW2L.apply(r.org) + AT_MATH_EPSILON * transformedRay.dir;
				}
				else {
					transformedRay = r;
				}

				isHit = intersectBVHClosestTriangles(ctxt->nodes[(int)attrib.z], ctxt, transformedRay, t_min, t_max, &isectTmp);
			}
			else {
				// TODO

			const auto* s = &ctxt->shapes[(int)attrib.x];

			if (attrib.z >= 0) {	// exid
				if (aten::aabb::hit(r, boxmin, boxmax, t_min, t_max, &t)) {
					aten::ray transformedRay;

					if (s->mtxid >= 0) {
						auto mtxW2L = ctxt->matrices[s->mtxid * 2 + 1];
						transformedRay.dir = mtxW2L.applyXYZ(r.dir);
						transformedRay.dir = normalize(transformedRay.dir);
						transformedRay.org = mtxW2L.apply(r.org) + AT_MATH_EPSILON * transformedRay.dir;
					}
					else {
						transformedRay = r;
					}

					isHit = intersectBVHCloserTriangles(ctxt->nodes[(int)attrib.z], ctxt, transformedRay, t_min, t_max, &isectTmp);
				}
			}
			else {
				// TODO
