Failed hack for collision detection with a sphere.
[hair] / src / object.cc
diff --git a/src/object.cc b/src/object.cc
new file mode 100644 (file)
index 0000000..ae33bb1
--- /dev/null
@@ -0,0 +1,16 @@
+#include "object.h"
+
+CollSphere::CollSphere()
+{
+       radius = 1.0;
+}
+
+bool CollSphere::contains(const Vec3 &v) const
+{
+       return length_sq(v - center) <= radius * radius;
+}
+
+Vec3 CollSphere::project_surf(const Vec3 &v) const
+{
+       return center + normalize(v - center) * radius;
+}