4 [
Attribute(defvalue:
"0 0 0", uiwidget: UIWidgets.Coords,
params:
"inf inf purpose=coords space=entity")]
5 protected vector m_vBoundingVolumeMins;
7 [
Attribute(defvalue:
"0 0 0", uiwidget: UIWidgets.Coords,
params:
"inf inf purpose=coords space=entity")]
8 protected vector m_vBoundingVolumeMaxs;
11 override void GetBoundingVolume(inout vector mins, inout vector maxs)
13 mins = m_vBoundingVolumeMins;
14 maxs = m_vBoundingVolumeMaxs;
17 override void GetAxisAlignedBoundingVolume(inout vector mins, inout vector maxs)
26 vector p1 = m_vBoundingVolumeMins;
27 vector p2 = m_vBoundingVolumeMaxs;
31 p3[2] = p3[2] + p2[2];
32 p4[2] = p4[2] + p1[2];
34 p1 = p1.Multiply3(mat);
35 p2 = p2.Multiply3(mat);
36 p3 = p3.Multiply3(mat);
37 p4 = p4.Multiply3(mat);
39 float minX = Math.Min(Math.Min(Math.Min(p1[0], p2[0]), p3[0]), p4[0]);
40 float maxX = Math.Max(Math.Max(Math.Max(p1[0], p2[0]), p3[0]), p4[0]);
41 float minZ = Math.Min(Math.Min(Math.Min(p1[2], p2[2]), p2[2]), p4[2]);
42 float maxZ = Math.Max(Math.Max(Math.Max(p1[2], p2[2]), p2[2]), p4[2]);
44 mins = Vector(minX, p1[1], minZ);
45 maxs = Vector(maxX, p2[1], maxZ);
51 super.CopyFromContainer(container);
55 m_vBoundingVolumeMins = containerCasted.m_vBoundingVolumeMins;
56 m_vBoundingVolumeMaxs = containerCasted.m_vBoundingVolumeMaxs;
60 override bool IsInRange(vector origin,
float range)
62 return Math3D.IntersectionSphereAABB(origin -
m_Owner.GetOrigin(), range, m_vBoundingVolumeMins, m_vBoundingVolumeMaxs);
66 override void DebugDraw(
bool shouldShowRange =
true)
68 super.DebugDraw(shouldShowRange);
75 vector containerMat[4];
77 m_Owner.GetWorldTransform(containerMat);
83 Shape.Create(ShapeType.BBOX, color1.PackToInt(), ShapeFlags.ONCE | ShapeFlags.DEPTH_DITHER | ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE, m_vBoundingVolumeMins, m_vBoundingVolumeMaxs).SetMatrix(containerMat);
84 containerMat[0] = containerMat[0] * 1.05;
85 containerMat[1] = containerMat[1] * 1.05;
86 containerMat[2] = containerMat[2] * 1.05;
87 Shape.Create(ShapeType.BBOX, color2.PackToInt(), ShapeFlags.ONCE | ShapeFlags.DEPTH_DITHER | ShapeFlags.WIREFRAME, m_vBoundingVolumeMins, m_vBoundingVolumeMaxs).SetMatrix(containerMat);