From bf6182daa8b4d7cea79310547f71d7a3155e17b0 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 29 Mar 2013 07:50:08 -0700 Subject: Update Mac and Windows breakpad builds to latest --- indra/llmath/CMakeLists.txt | 0 indra/llmath/camera.h | 0 indra/llmath/coordframe.h | 0 indra/llmath/llbbox.cpp | 0 indra/llmath/llbbox.h | 0 indra/llmath/llbboxlocal.cpp | 0 indra/llmath/llbboxlocal.h | 0 indra/llmath/llcalc.cpp | 0 indra/llmath/llcalc.h | 0 indra/llmath/llcalcparser.cpp | 0 indra/llmath/llcalcparser.h | 0 indra/llmath/llcamera.cpp | 0 indra/llmath/llcamera.h | 0 indra/llmath/llcoord.h | 0 indra/llmath/llcoordframe.cpp | 0 indra/llmath/llcoordframe.h | 0 indra/llmath/llinterp.h | 0 indra/llmath/llline.cpp | 0 indra/llmath/llline.h | 0 indra/llmath/llmath.h | 0 indra/llmath/llmatrix3a.cpp | 0 indra/llmath/llmatrix3a.h | 0 indra/llmath/llmatrix3a.inl | 0 indra/llmath/llmatrix4a.h | 0 indra/llmath/llmodularmath.cpp | 0 indra/llmath/llmodularmath.h | 0 indra/llmath/lloctree.h | 0 indra/llmath/llperlin.cpp | 0 indra/llmath/llperlin.h | 0 indra/llmath/llplane.h | 0 indra/llmath/llquantize.h | 0 indra/llmath/llquaternion.cpp | 0 indra/llmath/llquaternion.h | 0 indra/llmath/llquaternion2.h | 0 indra/llmath/llquaternion2.inl | 0 indra/llmath/llrect.cpp | 0 indra/llmath/llrect.h | 0 indra/llmath/llsdutil_math.cpp | 0 indra/llmath/llsdutil_math.h | 0 indra/llmath/llsimdmath.h | 0 indra/llmath/llsimdtypes.h | 0 indra/llmath/llsimdtypes.inl | 0 indra/llmath/llsphere.cpp | 0 indra/llmath/llsphere.h | 0 indra/llmath/lltreenode.h | 0 indra/llmath/llvector4a.cpp | 0 indra/llmath/llvector4a.h | 0 indra/llmath/llvector4a.inl | 0 indra/llmath/llvector4logical.h | 0 indra/llmath/llvolume.cpp | 0 indra/llmath/llvolume.h | 0 indra/llmath/llvolumemgr.cpp | 0 indra/llmath/llvolumemgr.h | 0 indra/llmath/llvolumeoctree.cpp | 0 indra/llmath/llvolumeoctree.h | 0 indra/llmath/m3math.cpp | 0 indra/llmath/m3math.h | 0 indra/llmath/m4math.cpp | 0 indra/llmath/m4math.h | 0 indra/llmath/raytrace.cpp | 0 indra/llmath/raytrace.h | 0 indra/llmath/tests/alignment_test.cpp | 0 indra/llmath/tests/llbbox_test.cpp | 0 indra/llmath/tests/llbboxlocal_test.cpp | 0 indra/llmath/tests/llmodularmath_test.cpp | 0 indra/llmath/tests/llquaternion_test.cpp | 0 indra/llmath/tests/llrect_test.cpp | 0 indra/llmath/tests/m3math_test.cpp | 0 indra/llmath/tests/mathmisc_test.cpp | 0 indra/llmath/tests/v2math_test.cpp | 0 indra/llmath/tests/v3color_test.cpp | 0 indra/llmath/tests/v3dmath_test.cpp | 0 indra/llmath/tests/v3math_test.cpp | 0 indra/llmath/tests/v4color_test.cpp | 0 indra/llmath/tests/v4coloru_test.cpp | 0 indra/llmath/tests/v4math_test.cpp | 0 indra/llmath/tests/xform_test.cpp | 0 indra/llmath/v2math.cpp | 0 indra/llmath/v2math.h | 0 indra/llmath/v3color.cpp | 0 indra/llmath/v3color.h | 0 indra/llmath/v3dmath.cpp | 0 indra/llmath/v3dmath.h | 0 indra/llmath/v3math.cpp | 0 indra/llmath/v3math.h | 0 indra/llmath/v4color.cpp | 0 indra/llmath/v4color.h | 0 indra/llmath/v4coloru.cpp | 0 indra/llmath/v4coloru.h | 0 indra/llmath/v4math.cpp | 0 indra/llmath/v4math.h | 0 indra/llmath/xform.cpp | 0 indra/llmath/xform.h | 0 93 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 indra/llmath/CMakeLists.txt mode change 100644 => 100755 indra/llmath/camera.h mode change 100644 => 100755 indra/llmath/coordframe.h mode change 100644 => 100755 indra/llmath/llbbox.cpp mode change 100644 => 100755 indra/llmath/llbbox.h mode change 100644 => 100755 indra/llmath/llbboxlocal.cpp mode change 100644 => 100755 indra/llmath/llbboxlocal.h mode change 100644 => 100755 indra/llmath/llcalc.cpp mode change 100644 => 100755 indra/llmath/llcalc.h mode change 100644 => 100755 indra/llmath/llcalcparser.cpp mode change 100644 => 100755 indra/llmath/llcalcparser.h mode change 100644 => 100755 indra/llmath/llcamera.cpp mode change 100644 => 100755 indra/llmath/llcamera.h mode change 100644 => 100755 indra/llmath/llcoord.h mode change 100644 => 100755 indra/llmath/llcoordframe.cpp mode change 100644 => 100755 indra/llmath/llcoordframe.h mode change 100644 => 100755 indra/llmath/llinterp.h mode change 100644 => 100755 indra/llmath/llline.cpp mode change 100644 => 100755 indra/llmath/llline.h mode change 100644 => 100755 indra/llmath/llmath.h mode change 100644 => 100755 indra/llmath/llmatrix3a.cpp mode change 100644 => 100755 indra/llmath/llmatrix3a.h mode change 100644 => 100755 indra/llmath/llmatrix3a.inl mode change 100644 => 100755 indra/llmath/llmatrix4a.h mode change 100644 => 100755 indra/llmath/llmodularmath.cpp mode change 100644 => 100755 indra/llmath/llmodularmath.h mode change 100644 => 100755 indra/llmath/lloctree.h mode change 100644 => 100755 indra/llmath/llperlin.cpp mode change 100644 => 100755 indra/llmath/llperlin.h mode change 100644 => 100755 indra/llmath/llplane.h mode change 100644 => 100755 indra/llmath/llquantize.h mode change 100644 => 100755 indra/llmath/llquaternion.cpp mode change 100644 => 100755 indra/llmath/llquaternion.h mode change 100644 => 100755 indra/llmath/llquaternion2.h mode change 100644 => 100755 indra/llmath/llquaternion2.inl mode change 100644 => 100755 indra/llmath/llrect.cpp mode change 100644 => 100755 indra/llmath/llrect.h mode change 100644 => 100755 indra/llmath/llsdutil_math.cpp mode change 100644 => 100755 indra/llmath/llsdutil_math.h mode change 100644 => 100755 indra/llmath/llsimdmath.h mode change 100644 => 100755 indra/llmath/llsimdtypes.h mode change 100644 => 100755 indra/llmath/llsimdtypes.inl mode change 100644 => 100755 indra/llmath/llsphere.cpp mode change 100644 => 100755 indra/llmath/llsphere.h mode change 100644 => 100755 indra/llmath/lltreenode.h mode change 100644 => 100755 indra/llmath/llvector4a.cpp mode change 100644 => 100755 indra/llmath/llvector4a.h mode change 100644 => 100755 indra/llmath/llvector4a.inl mode change 100644 => 100755 indra/llmath/llvector4logical.h mode change 100644 => 100755 indra/llmath/llvolume.cpp mode change 100644 => 100755 indra/llmath/llvolume.h mode change 100644 => 100755 indra/llmath/llvolumemgr.cpp mode change 100644 => 100755 indra/llmath/llvolumemgr.h mode change 100644 => 100755 indra/llmath/llvolumeoctree.cpp mode change 100644 => 100755 indra/llmath/llvolumeoctree.h mode change 100644 => 100755 indra/llmath/m3math.cpp mode change 100644 => 100755 indra/llmath/m3math.h mode change 100644 => 100755 indra/llmath/m4math.cpp mode change 100644 => 100755 indra/llmath/m4math.h mode change 100644 => 100755 indra/llmath/raytrace.cpp mode change 100644 => 100755 indra/llmath/raytrace.h mode change 100644 => 100755 indra/llmath/tests/alignment_test.cpp mode change 100644 => 100755 indra/llmath/tests/llbbox_test.cpp mode change 100644 => 100755 indra/llmath/tests/llbboxlocal_test.cpp mode change 100644 => 100755 indra/llmath/tests/llmodularmath_test.cpp mode change 100644 => 100755 indra/llmath/tests/llquaternion_test.cpp mode change 100644 => 100755 indra/llmath/tests/llrect_test.cpp mode change 100644 => 100755 indra/llmath/tests/m3math_test.cpp mode change 100644 => 100755 indra/llmath/tests/mathmisc_test.cpp mode change 100644 => 100755 indra/llmath/tests/v2math_test.cpp mode change 100644 => 100755 indra/llmath/tests/v3color_test.cpp mode change 100644 => 100755 indra/llmath/tests/v3dmath_test.cpp mode change 100644 => 100755 indra/llmath/tests/v3math_test.cpp mode change 100644 => 100755 indra/llmath/tests/v4color_test.cpp mode change 100644 => 100755 indra/llmath/tests/v4coloru_test.cpp mode change 100644 => 100755 indra/llmath/tests/v4math_test.cpp mode change 100644 => 100755 indra/llmath/tests/xform_test.cpp mode change 100644 => 100755 indra/llmath/v2math.cpp mode change 100644 => 100755 indra/llmath/v2math.h mode change 100644 => 100755 indra/llmath/v3color.cpp mode change 100644 => 100755 indra/llmath/v3color.h mode change 100644 => 100755 indra/llmath/v3dmath.cpp mode change 100644 => 100755 indra/llmath/v3dmath.h mode change 100644 => 100755 indra/llmath/v3math.cpp mode change 100644 => 100755 indra/llmath/v3math.h mode change 100644 => 100755 indra/llmath/v4color.cpp mode change 100644 => 100755 indra/llmath/v4color.h mode change 100644 => 100755 indra/llmath/v4coloru.cpp mode change 100644 => 100755 indra/llmath/v4coloru.h mode change 100644 => 100755 indra/llmath/v4math.cpp mode change 100644 => 100755 indra/llmath/v4math.h mode change 100644 => 100755 indra/llmath/xform.cpp mode change 100644 => 100755 indra/llmath/xform.h (limited to 'indra/llmath') diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/indra/llmath/camera.h b/indra/llmath/camera.h old mode 100644 new mode 100755 diff --git a/indra/llmath/coordframe.h b/indra/llmath/coordframe.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llbbox.cpp b/indra/llmath/llbbox.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llbbox.h b/indra/llmath/llbbox.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llbboxlocal.cpp b/indra/llmath/llbboxlocal.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llbboxlocal.h b/indra/llmath/llbboxlocal.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llcalc.cpp b/indra/llmath/llcalc.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llcalc.h b/indra/llmath/llcalc.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llcalcparser.cpp b/indra/llmath/llcalcparser.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llcalcparser.h b/indra/llmath/llcalcparser.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llcoordframe.cpp b/indra/llmath/llcoordframe.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llcoordframe.h b/indra/llmath/llcoordframe.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llinterp.h b/indra/llmath/llinterp.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llline.cpp b/indra/llmath/llline.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llline.h b/indra/llmath/llline.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llmatrix3a.cpp b/indra/llmath/llmatrix3a.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llmatrix3a.h b/indra/llmath/llmatrix3a.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llmatrix3a.inl b/indra/llmath/llmatrix3a.inl old mode 100644 new mode 100755 diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llmodularmath.cpp b/indra/llmath/llmodularmath.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llmodularmath.h b/indra/llmath/llmodularmath.h old mode 100644 new mode 100755 diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llperlin.cpp b/indra/llmath/llperlin.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llperlin.h b/indra/llmath/llperlin.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llplane.h b/indra/llmath/llplane.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llquantize.h b/indra/llmath/llquantize.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llquaternion2.h b/indra/llmath/llquaternion2.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llquaternion2.inl b/indra/llmath/llquaternion2.inl old mode 100644 new mode 100755 diff --git a/indra/llmath/llrect.cpp b/indra/llmath/llrect.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llrect.h b/indra/llmath/llrect.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llsdutil_math.cpp b/indra/llmath/llsdutil_math.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llsdutil_math.h b/indra/llmath/llsdutil_math.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llsimdmath.h b/indra/llmath/llsimdmath.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llsimdtypes.h b/indra/llmath/llsimdtypes.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llsimdtypes.inl b/indra/llmath/llsimdtypes.inl old mode 100644 new mode 100755 diff --git a/indra/llmath/llsphere.cpp b/indra/llmath/llsphere.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llsphere.h b/indra/llmath/llsphere.h old mode 100644 new mode 100755 diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llvector4a.cpp b/indra/llmath/llvector4a.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl old mode 100644 new mode 100755 diff --git a/indra/llmath/llvector4logical.h b/indra/llmath/llvector4logical.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llvolumemgr.h b/indra/llmath/llvolumemgr.h old mode 100644 new mode 100755 diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h old mode 100644 new mode 100755 diff --git a/indra/llmath/m3math.cpp b/indra/llmath/m3math.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/m3math.h b/indra/llmath/m3math.h old mode 100644 new mode 100755 diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h old mode 100644 new mode 100755 diff --git a/indra/llmath/raytrace.cpp b/indra/llmath/raytrace.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/raytrace.h b/indra/llmath/raytrace.h old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/alignment_test.cpp b/indra/llmath/tests/alignment_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/llbbox_test.cpp b/indra/llmath/tests/llbbox_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/llbboxlocal_test.cpp b/indra/llmath/tests/llbboxlocal_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/llmodularmath_test.cpp b/indra/llmath/tests/llmodularmath_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/llquaternion_test.cpp b/indra/llmath/tests/llquaternion_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/llrect_test.cpp b/indra/llmath/tests/llrect_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/m3math_test.cpp b/indra/llmath/tests/m3math_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/mathmisc_test.cpp b/indra/llmath/tests/mathmisc_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/v2math_test.cpp b/indra/llmath/tests/v2math_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/v3color_test.cpp b/indra/llmath/tests/v3color_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/v3dmath_test.cpp b/indra/llmath/tests/v3dmath_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/v3math_test.cpp b/indra/llmath/tests/v3math_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/v4color_test.cpp b/indra/llmath/tests/v4color_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/v4coloru_test.cpp b/indra/llmath/tests/v4coloru_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/v4math_test.cpp b/indra/llmath/tests/v4math_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/tests/xform_test.cpp b/indra/llmath/tests/xform_test.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/v2math.cpp b/indra/llmath/v2math.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h old mode 100644 new mode 100755 diff --git a/indra/llmath/v3color.cpp b/indra/llmath/v3color.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h old mode 100644 new mode 100755 diff --git a/indra/llmath/v3dmath.cpp b/indra/llmath/v3dmath.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h old mode 100644 new mode 100755 diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h old mode 100644 new mode 100755 diff --git a/indra/llmath/v4color.cpp b/indra/llmath/v4color.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h old mode 100644 new mode 100755 diff --git a/indra/llmath/v4coloru.cpp b/indra/llmath/v4coloru.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h old mode 100644 new mode 100755 diff --git a/indra/llmath/v4math.cpp b/indra/llmath/v4math.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h old mode 100644 new mode 100755 diff --git a/indra/llmath/xform.cpp b/indra/llmath/xform.cpp old mode 100644 new mode 100755 diff --git a/indra/llmath/xform.h b/indra/llmath/xform.h old mode 100644 new mode 100755 -- cgit v1.2.3 From c3f14b915c38a4978745f12f1f816572cce4b5a0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 3 Jun 2013 12:50:48 -0500 Subject: NORSPEC-229 Fix for bad binormals on mirrored surfaces (use tangent calculator instead of binormal calculator, convert binormal centric code to tangent centric) --- indra/llmath/llvolume.cpp | 327 ++++++++++++++++++++++------------------ indra/llmath/llvolume.h | 36 ++--- indra/llmath/llvolumeoctree.cpp | 66 +++++--- indra/llmath/llvolumeoctree.h | 8 +- 4 files changed, 234 insertions(+), 203 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 3f06e6b99e..bf03c971cd 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -2079,9 +2079,9 @@ void LLVolume::regen() createVolumeFaces(); } -void LLVolume::genBinormals(S32 face) +void LLVolume::genTangents(S32 face) { - mVolumeFaces[face].createBinormals(); + mVolumeFaces[face].createTangents(); } LLVolume::~LLVolume() @@ -4392,7 +4392,7 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, segments.push_back(vertices.size()); #if DEBUG_SILHOUETTE_BINORMALS vertices.push_back(face.mVertices[j].getPosition()); - vertices.push_back(face.mVertices[j].getPosition() + face.mVertices[j].mBinormal*0.1f); + vertices.push_back(face.mVertices[j].getPosition() + face.mVertices[j].mTangent*0.1f); normals.push_back(LLVector3(0,0,1)); normals.push_back(LLVector3(0,0,1)); segments.push_back(vertices.size()); @@ -4508,22 +4508,9 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, } } -S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, - S32 face, - LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) -{ - LLVector4a starta, enda; - starta.load3(start.mV); - enda.load3(end.mV); - - return lineSegmentIntersect(starta, enda, face, intersection, tex_coord, normal, bi_normal); - -} - - S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, - LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal) + LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent_out) { S32 hit_face = -1; @@ -4561,9 +4548,9 @@ S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& en if (LLLineSegmentBoxIntersect(start, end, box_center, box_size)) { - if (bi_normal != NULL) // if the caller wants binormals, we may need to generate them + if (tangent_out != NULL) // if the caller wants tangents, we may need to generate them { - genBinormals(i); + genTangents(i); } if (isUnique()) @@ -4597,7 +4584,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& en LLVector4a intersect = dir; intersect.mul(closest_t); intersect.add(start); - intersection->set(intersect.getF32ptr()); + *intersection = intersect; } @@ -4612,19 +4599,42 @@ S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& en if (normal!= NULL) { - LLVector4* norm = (LLVector4*) face.mNormals; - - *normal = ((1.f - a - b) * LLVector3(norm[idx0]) + - a * LLVector3(norm[idx1]) + - b * LLVector3(norm[idx2])); + LLVector4a* norm = face.mNormals; + + LLVector4a n1,n2,n3; + n1 = norm[idx0]; + n1.mul(1.f-a-b); + + n2 = norm[idx1]; + n2.mul(a); + + n3 = norm[idx2]; + n3.mul(b); + + n1.add(n2); + n1.add(n3); + + *normal = n1; } - if (bi_normal != NULL) + if (tangent_out != NULL) { - LLVector4* binormal = (LLVector4*) face.mBinormals; - *bi_normal = ((1.f - a - b) * LLVector3(binormal[idx0]) + - a * LLVector3(binormal[idx1]) + - b * LLVector3(binormal[idx2])); + LLVector4a* tangents = face.mTangents; + + LLVector4a t1,t2,t3; + t1 = tangents[idx0]; + t1.mul(1.f-a-b); + + t2 = tangents[idx1]; + t2.mul(a); + + t3 = tangents[idx2]; + t3.mul(b); + + t1.add(t2); + t1.add(t3); + + *tangent_out = t1; } } } @@ -4637,7 +4647,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& en face.createOctree(); } - LLOctreeTriangleRayIntersect intersect(start, dir, &face, &closest_t, intersection, tex_coord, normal, bi_normal); + LLOctreeTriangleRayIntersect intersect(start, dir, &face, &closest_t, intersection, tex_coord, normal, tangent_out); intersect.traverse(face.mOctree); if (intersect.mHitFace) { @@ -5183,7 +5193,7 @@ LLVolumeFace::LLVolumeFace() : mNumIndices(0), mPositions(NULL), mNormals(NULL), - mBinormals(NULL), + mTangents(NULL), mTexCoords(NULL), mIndices(NULL), mWeights(NULL), @@ -5206,7 +5216,7 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src) mNumIndices(0), mPositions(NULL), mNormals(NULL), - mBinormals(NULL), + mTangents(NULL), mTexCoords(NULL), mIndices(NULL), mWeights(NULL), @@ -5264,15 +5274,15 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) } - if (src.mBinormals) + if (src.mTangents) { - allocateBinormals(src.mNumVertices); - LLVector4a::memcpyNonAliased16((F32*) mBinormals, (F32*) src.mBinormals, vert_size); + allocateTangents(src.mNumVertices); + LLVector4a::memcpyNonAliased16((F32*) mTangents, (F32*) src.mTangents, vert_size); } else { - ll_aligned_free_16(mBinormals); - mBinormals = NULL; + ll_aligned_free_16(mTangents); + mTangents = NULL; } if (src.mWeights) @@ -5316,8 +5326,8 @@ void LLVolumeFace::freeData() mTexCoords = NULL; ll_aligned_free_16(mIndices); mIndices = NULL; - ll_aligned_free_16(mBinormals); - mBinormals = NULL; + ll_aligned_free_16(mTangents); + mTangents = NULL; ll_aligned_free_16(mWeights); mWeights = NULL; @@ -5897,7 +5907,7 @@ void LLVolumeFace::cacheOptimize() } LLVector4a* binorm = NULL; - if (mBinormals) + if (mTangents) { binorm = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); } @@ -5922,9 +5932,9 @@ void LLVolumeFace::cacheOptimize() { wght[cur_idx] = mWeights[idx]; } - if (mBinormals) + if (mTangents) { - binorm[cur_idx] = mBinormals[idx]; + binorm[cur_idx] = mTangents[idx]; } cur_idx++; @@ -5940,13 +5950,13 @@ void LLVolumeFace::cacheOptimize() ll_aligned_free_16(mNormals); ll_aligned_free_16(mTexCoords); ll_aligned_free_16(mWeights); - ll_aligned_free_16(mBinormals); + ll_aligned_free_16(mTangents); mPositions = pos; mNormals = norm; mTexCoords = tc; mWeights = wght; - mBinormals = binorm; + mTangents = binorm; //std::string result = llformat("ACMR pre/post: %.3f/%.3f -- %d triangles %d breaks", pre_acmr, post_acmr, mNumIndices/3, breaks); //llinfos << result << llendl; @@ -6027,7 +6037,7 @@ void LLVolumeFace::swapData(LLVolumeFace& rhs) { llswap(rhs.mPositions, mPositions); llswap(rhs.mNormals, mNormals); - llswap(rhs.mBinormals, mBinormals); + llswap(rhs.mTangents, mTangents); llswap(rhs.mTexCoords, mTexCoords); llswap(rhs.mIndices,mIndices); llswap(rhs.mNumVertices, mNumVertices); @@ -6116,22 +6126,11 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) corners[2].mTexCoord=swap; } - LLVector4a binormal; - - calc_binormal_from_triangle( binormal, - corners[0].getPosition(), corners[0].mTexCoord, - corners[1].getPosition(), corners[1].mTexCoord, - corners[2].getPosition(), corners[2].mTexCoord); - - binormal.normalize3fast(); - S32 size = (grid_size+1)*(grid_size+1); resizeVertices(size); - allocateBinormals(size); - + LLVector4a* pos = (LLVector4a*) mPositions; LLVector4a* norm = (LLVector4a*) mNormals; - LLVector4a* binorm = (LLVector4a*) mBinormals; LLVector2* tc = (LLVector2*) mTexCoords; for(int gx = 0;gx& v, std::vector& idx); @@ -916,7 +916,7 @@ public: LLVector4a* mPositions; LLVector4a* mNormals; - LLVector4a* mBinormals; + LLVector4a* mTangents; LLVector2* mTexCoords; U16* mIndices; @@ -980,7 +980,7 @@ public: void setDirty() { mPathp->setDirty(); mProfilep->setDirty(); } void regen(); - void genBinormals(S32 face); + void genTangents(S32 face); BOOL isConvex() const; BOOL isCap(S32 face); @@ -1008,21 +1008,14 @@ public: //get the face index of the face that intersects with the given line segment at the point //closest to start. Moves end to the point of intersection. Returns -1 if no intersection. //Line segment must be in volume space. - S32 lineSegmentIntersect(const LLVector3& start, const LLVector3& end, + S32 lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face = -1, // which face to check, -1 = ALL_SIDES - LLVector3* intersection = NULL, // return the intersection point + LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point - LLVector3* normal = NULL, // return the surface normal at the intersection point - LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point + LLVector4a* normal = NULL, // return the surface normal at the intersection point + LLVector4a* tangent = NULL // return the surface tangent at the intersection point ); - S32 lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, - S32 face = 1, - LLVector3* intersection = NULL, - LLVector2* tex_coord = NULL, - LLVector3* normal = NULL, - LLVector3* bi_normal = NULL); - LLFaceID generateFaceMask(); BOOL isFaceMaskValid(LLFaceID face_mask); @@ -1081,21 +1074,12 @@ public: std::ostream& operator<<(std::ostream &s, const LLVolumeParams &volume_params); -void calc_binormal_from_triangle( - LLVector4a& binormal, - const LLVector4a& pos0, - const LLVector2& tex0, - const LLVector4a& pos1, - const LLVector2& tex1, - const LLVector4a& pos2, - const LLVector2& tex2); - BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size); BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size); BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size); -BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir, - F32& intersection_a, F32& intersection_b, F32& intersection_t, BOOL two_sided); +//BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir, +// F32& intersection_a, F32& intersection_b, F32& intersection_t, BOOL two_sided); BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, F32& intersection_a, F32& intersection_b, F32& intersection_t); diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp index cc83cb7235..0728b49c1f 100755 --- a/indra/llmath/llvolumeoctree.cpp +++ b/indra/llmath/llvolumeoctree.cpp @@ -94,14 +94,14 @@ void LLVolumeOctreeListener::handleChildAddition(const LLOctreeNode { LLVolumeOctreeListener* vl = (LLVolumeOctreeListener*) node->getListener(0); - /*const F32* start = mStart.getF32(); - const F32* end = mEnd.getF32(); - const F32* center = vl->mBounds[0].getF32(); - const F32* size = vl->mBounds[1].getF32();*/ - - //if (LLLineSegmentBoxIntersect(mStart, mEnd, vl->mBounds[0], vl->mBounds[1])) - if (LLLineSegmentBoxIntersect(mStart.getF32ptr(), mEnd.getF32ptr(), vl->mBounds[0].getF32ptr(), vl->mBounds[1].getF32ptr())) + if (LLLineSegmentBoxIntersect(mStart, mEnd, vl->mBounds[0], vl->mBounds[1])) { node->accept(this); for (S32 i = 0; i < node->getChildCount(); ++i) @@ -152,34 +146,60 @@ void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode* n LLVector4a intersect = mDir; intersect.mul(*mClosestT); intersect.add(mStart); - mIntersection->set(intersect.getF32ptr()); + *mIntersection = intersect; } + U32 idx0 = tri->mIndex[0]; + U32 idx1 = tri->mIndex[1]; + U32 idx2 = tri->mIndex[2]; if (mTexCoord != NULL) { LLVector2* tc = (LLVector2*) mFace->mTexCoords; - *mTexCoord = ((1.f - a - b) * tc[tri->mIndex[0]] + - a * tc[tri->mIndex[1]] + - b * tc[tri->mIndex[2]]); + *mTexCoord = ((1.f - a - b) * tc[idx0] + + a * tc[idx1] + + b * tc[idx2]); } if (mNormal != NULL) { - LLVector4* norm = (LLVector4*) mFace->mNormals; - - *mNormal = ((1.f - a - b) * LLVector3(norm[tri->mIndex[0]]) + - a * LLVector3(norm[tri->mIndex[1]]) + - b * LLVector3(norm[tri->mIndex[2]])); + LLVector4a* norm = mFace->mNormals; + + LLVector4a n1,n2,n3; + n1 = norm[idx0]; + n1.mul(1.f-a-b); + + n2 = norm[idx1]; + n2.mul(a); + + n3 = norm[idx2]; + n3.mul(b); + + n1.add(n2); + n1.add(n3); + + *mNormal = n1; } - if (mBinormal != NULL) + if (mTangent != NULL) { - LLVector4* binormal = (LLVector4*) mFace->mBinormals; - *mBinormal = ((1.f - a - b) * LLVector3(binormal[tri->mIndex[0]]) + - a * LLVector3(binormal[tri->mIndex[1]]) + - b * LLVector3(binormal[tri->mIndex[2]])); + LLVector4a* tangents = mFace->mTangents; + + LLVector4a t1,t2,t3; + t1 = tangents[idx0]; + t1.mul(1.f-a-b); + + t2 = tangents[idx1]; + t2.mul(a); + + t3 = tangents[idx2]; + t3.mul(b); + + t1.add(t2); + t1.add(t3); + + *mTangent = t1; } } } diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h index 9ae34a0c4e..80d6ced36d 100755 --- a/indra/llmath/llvolumeoctree.h +++ b/indra/llmath/llvolumeoctree.h @@ -137,16 +137,16 @@ public: LLVector4a mStart; LLVector4a mDir; LLVector4a mEnd; - LLVector3* mIntersection; + LLVector4a* mIntersection; LLVector2* mTexCoord; - LLVector3* mNormal; - LLVector3* mBinormal; + LLVector4a* mNormal; + LLVector4a* mTangent; F32* mClosestT; bool mHitFace; LLOctreeTriangleRayIntersect(const LLVector4a& start, const LLVector4a& dir, const LLVolumeFace* face, F32* closest_t, - LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal); + LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent); void traverse(const LLOctreeNode* node); -- cgit v1.2.3 From ddf15867e4dd1e3506f0cfd975d9e7aa8f7aab66 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Jun 2013 16:18:37 -0500 Subject: NORSPEC-242 Fix for infinity and NaN showing up in tangents and texture coordinates sometimes. --- indra/llmath/llvolume.cpp | 135 ++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 77 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index bf03c971cd..c3528349eb 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -1392,7 +1392,7 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en pt->mScale.mV[VX] = hole_x * lerp(taper_x_begin, taper_x_end, t); pt->mScale.mV[VY] = hole_y * lerp(taper_y_begin, taper_y_end, t); pt->mTexT = t; - + // Twist rotates the path along the x,y plane (I think) - DJS 04/05/02 twist.setQuat (lerp(twist_begin,twist_end,t) * 2.f * F_PI - F_PI,0,0,1); // Rotate the point around the circle's center. @@ -1446,7 +1446,7 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en pt->mScale.mV[VX] = hole_x * lerp(taper_x_begin, taper_x_end, t); pt->mScale.mV[VY] = hole_y * lerp(taper_y_begin, taper_y_end, t); pt->mTexT = t; - + // Twist rotates the path along the x,y plane (I think) - DJS 04/05/02 twist.setQuat (lerp(twist_begin,twist_end,t) * 2.f * F_PI - F_PI,0,0,1); // Rotate the point around the circle's center. @@ -1594,7 +1594,7 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, S32 sides = (S32)llfloor(llfloor((MIN_DETAIL_FACES * detail + twist_mag * 3.5f * (detail-0.5f))) * params.getRevolutions()); if (is_sculpted) - sides = sculpt_size; + sides = llmax(sculpt_size, 1); genNGon(params, sides); } @@ -1644,6 +1644,7 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, mPath[i].mScale.mV[0] = lerp(1,params.getScale().mV[0],t); mPath[i].mScale.mV[1] = lerp(1,params.getScale().mV[1],t); mPath[i].mTexT = t; + mPath[i].mRot.setQuat(F_PI * params.getTwist() * t,1,0,0); } @@ -2442,6 +2443,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) LLVector4a pos_range; pos_range.setSub(max_pos, min_pos); LLVector2 tc_range2 = max_tc - min_tc; + LLVector4a tc_range; tc_range.set(tc_range2[0], tc_range2[1], tc_range2[0], tc_range2[1]); LLVector4a min_tc4(min_tc[0], min_tc[1], min_tc[0], min_tc[1]); @@ -6304,24 +6306,6 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) cuv = (min_uv + max_uv)*0.5f; - LLVector4a normal; - LLVector4a d0, d1; - - - d0.setSub(*mCenter, pos[0]); - d1.setSub(*mCenter, pos[1]); - - if (mTypeMask & TOP_MASK) - { - normal.setCross3(d0, d1); - } - else - { - normal.setCross3(d1, d0); - } - - normal.normalize3fast(); - VertexData vd; vd.setPosition(*mCenter); vd.mTexCoord = cuv; @@ -6330,14 +6314,10 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) { pos[num_vertices] = *mCenter; tc[num_vertices] = cuv; + num_vertices++; } - for (S32 i = 0; i < num_vertices; i++) - { - norm[i].load4a(normal.getF32ptr()); - } - if (partial_build) { return TRUE; @@ -6572,7 +6552,22 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) } - + + LLVector4a d0,d1; + + d0.setSub(mPositions[mIndices[1]], mPositions[mIndices[0]]); + d1.setSub(mPositions[mIndices[2]], mPositions[mIndices[0]]); + + LLVector4a normal; + normal.setCross3(d0,d1); + + normal.normalize3fast(); + + for (S32 i = 0; i < num_vertices; i++) + { + norm[i].load4a(normal.getF32ptr()); + } + return TRUE; } @@ -6600,37 +6595,6 @@ void LLVolumeFace::createTangents() CalculateTangentArray(mNumVertices, mPositions, mNormals, mTexCoords, mNumIndices/3, mIndices, mTangents); - /*for (U32 i = 0; i < mNumIndices/3; i++) - { //for each triangle - const U16& i0 = mIndices[i*3+0]; - const U16& i1 = mIndices[i*3+1]; - const U16& i2 = mIndices[i*3+2]; - - //calculate tangent - LLVector4a tangent; - calc_tangent_from_triangle(tangent, - pos[i0], tc[i0], - pos[i1], tc[i1], - pos[i2], tc[i2]); - - - //add triangle normal to vertices - binorm[i0].add(tangent); - binorm[i1].add(tangent); - binorm[i2].add(tangent); - - //even out quad contributions - if (i % 2 == 0) - { - binorm[i2].add(tangent); - } - else - { - binorm[i1].add(tangent); - } - }*/ - - //normalize tangents for (U32 i = 0; i < mNumVertices; i++) { @@ -6949,7 +6913,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) if ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2 && s > 0) { - pos[cur_vertex].load3(mesh[i].mPos.mV); tc[cur_vertex] = LLVector2(ss,tt); @@ -6980,7 +6943,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } } - //get bounding box for this side LLVector4a& face_min = mExtents[0]; LLVector4a& face_max = mExtents[1]; @@ -7265,26 +7227,36 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe float t1 = w2.mV[1] - w1.mV[1]; float t2 = w3.mV[1] - w1.mV[1]; - float r = 1.0F / (s1 * t2 - s2 * t1); - LLVector4a sdir((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, - (t2 * z1 - t1 * z2) * r); - LLVector4a tdir((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, - (s1 * z2 - s2 * z1) * r); + F32 rd = s1*t2-s2*t1; + + float r = rd*rd > 0.f ? 1.0F / rd : 1024.f; //some made up large ratio for division by zero + + llassert(llfinite(r)); + llassert(!llisnan(r)); + + LLVector4a sdir((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, + (t2 * z1 - t1 * z2) * r); + LLVector4a tdir((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, + (s1 * z2 - s2 * z1) * r); - tan1[i1].add(sdir); - tan1[i2].add(sdir); - tan1[i3].add(sdir); + tan1[i1].add(sdir); + tan1[i2].add(sdir); + tan1[i3].add(sdir); - tan2[i1].add(tdir); - tan2[i2].add(tdir); - tan2[i3].add(tdir); + tan2[i1].add(tdir); + tan2[i2].add(tdir); + tan2[i3].add(tdir); } for (U32 a = 0; a < vertexCount; a++) { LLVector4a n = normal[a]; - const LLVector4a& t = tan1[a]; + + const LLVector4a& t = tan1[a]; + llassert(tan1[a].getLength3().getF32() >= 0.f); + llassert(tan2[a].getLength3().getF32() >= 0.f); + LLVector4a ncrosst; ncrosst.setCross3(n,t); @@ -7294,14 +7266,23 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe LLVector4a tsubn; tsubn.setSub(t,n); - tsubn.normalize3fast(); + if (tsubn.dot3(tsubn).getF32() > F_APPROXIMATELY_ZERO) + { + tsubn.normalize3fast(); - // Calculate handedness - F32 handedness = ncrosst.dot3(tan2[a]).getF32() < 0.f ? -1.f : 1.f; + // Calculate handedness + F32 handedness = ncrosst.dot3(tan2[a]).getF32() < 0.f ? -1.f : 1.f; - tsubn.getF32ptr()[3] = handedness; + tsubn.getF32ptr()[3] = handedness; + + tangent[a] = tsubn; - tangent[a] = tsubn; + llassert(tangent[a].getLength3().getF32() > 0.f); + } + else + { //degenerate, make up a value + tangent[a].set(0,0,1,1); + } } ll_aligned_free_16(tan1); -- cgit v1.2.3 From d09f1e71176f32a23be73b53559979727c242b4a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 10 Jun 2013 16:01:53 -0500 Subject: NORSPEC-242 Followup, fix a couple more sources of NaN and infinity. --- indra/llmath/llvolume.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index c3528349eb..f9dd843b92 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -6561,8 +6561,23 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) LLVector4a normal; normal.setCross3(d0,d1); - normal.normalize3fast(); + if (normal.dot3(normal).getF32() > F_APPROXIMATELY_ZERO) + { + normal.normalize3fast(); + } + else + { //degenerate, make up a value + normal.set(0,0,1); + } + + llassert(llfinite(normal.getF32ptr()[0])); + llassert(llfinite(normal.getF32ptr()[1])); + llassert(llfinite(normal.getF32ptr()[2])); + llassert(!llisnan(normal.getF32ptr()[0])); + llassert(!llisnan(normal.getF32ptr()[1])); + llassert(!llisnan(normal.getF32ptr()[2])); + for (S32 i = 0; i < num_vertices; i++) { norm[i].load4a(normal.getF32ptr()); @@ -7048,6 +7063,14 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) n[1]->add(c); n[2]->add(c); + llassert(llfinite(c.getF32ptr()[0])); + llassert(llfinite(c.getF32ptr()[1])); + llassert(llfinite(c.getF32ptr()[2])); + + llassert(!llisnan(c.getF32ptr()[0])); + llassert(!llisnan(c.getF32ptr()[1])); + llassert(!llisnan(c.getF32ptr()[2])); + //even out quad contributions n[i%2+1]->add(c); } @@ -7277,7 +7300,13 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe tangent[a] = tsubn; - llassert(tangent[a].getLength3().getF32() > 0.f); + llassert(llfinite(tangent[a].getF32ptr()[0])); + llassert(llfinite(tangent[a].getF32ptr()[1])); + llassert(llfinite(tangent[a].getF32ptr()[2])); + + llassert(!llisnan(tangent[a].getF32ptr()[0])); + llassert(!llisnan(tangent[a].getF32ptr()[1])); + llassert(!llisnan(tangent[a].getF32ptr()[2])); } else { //degenerate, make up a value -- cgit v1.2.3 From 01f595d8716f7b80ab0088d93434fa77cc812c16 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 11 Jun 2013 12:02:54 -0700 Subject: Speculative fix for tangent calc asserts on Mac --- indra/llmath/llvolume.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index f9dd843b92..1932272afb 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -7252,7 +7252,7 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe F32 rd = s1*t2-s2*t1; - float r = rd*rd > 0.f ? 1.0F / rd : 1024.f; //some made up large ratio for division by zero + float r = ((rd*rd) > FLT_EPSILON) ? 1.0F / rd : 1024.f; //some made up large ratio for division by zero llassert(llfinite(r)); llassert(!llisnan(r)); @@ -7276,7 +7276,7 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe LLVector4a n = normal[a]; const LLVector4a& t = tan1[a]; - + llassert(tan1[a].getLength3().getF32() >= 0.f); llassert(tan2[a].getLength3().getF32() >= 0.f); -- cgit v1.2.3 From 48324a93833cee8aca7559588ee5f2b4afa250fa Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 08:09:29 -0700 Subject: Fix issues with NaNs in tangent data from using normalize3fast on zero-length vectors and other data conditioning; also added assert to normalize3fast to make finding these problems easier in the future --- indra/llmath/llvector4a.inl | 9 ++++ indra/llmath/llvolume.cpp | 128 +++++++++++++++++++++++++++++++++----------- 2 files changed, 106 insertions(+), 31 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 7c52ffef21..4589bac9fb 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -331,6 +331,9 @@ inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const // Note that this does not consider zero length vectors! inline void LLVector4a::normalize3() { + // find out about bad math before it takes two man-days to track down + llassert(isFinite3() && !equals3(getZero())); + // lenSqrd = a dot a LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); // rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 } @@ -379,6 +382,9 @@ inline void LLVector4a::normalize4() // Note that this does not consider zero length vectors! inline LLSimdScalar LLVector4a::normalize3withLength() { + // find out about bad math before it takes two man-days to track down + llassert(isFinite3() && !equals3(getZero())); + // lenSqrd = a dot a LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); // rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 } @@ -404,6 +410,9 @@ inline LLSimdScalar LLVector4a::normalize3withLength() // Note that this does not consider zero length vectors! inline void LLVector4a::normalize3fast() { + // find out about bad math before it takes two man-days to track down + llassert(isFinite3() && !equals3(getZero())); + LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ); mQ = _mm_mul_ps( mQ, approxRsqrt ); diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 1932272afb..bc2572375a 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -7209,46 +7209,53 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) return TRUE; } +#define TANGENTIAL_PARANOIA_ASSERTS 1 + +#if TANGENTIAL_PARANOIA_ASSERTS + #define tangential_paranoia(a) llassert(a) +#else + #define tangential_paranoia(a) +#endif + //adapted from Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”. Terathon Software 3D Graphics Library, 2001. http://www.terathon.com/code/tangent.html void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal, const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent) { - //LLVector4a *tan1 = new LLVector4a[vertexCount * 2]; LLVector4a* tan1 = (LLVector4a*) ll_aligned_malloc_16(vertexCount*2*sizeof(LLVector4a)); - LLVector4a* tan2 = tan1 + vertexCount; + LLVector4a* tan2 = tan1 + vertexCount; memset(tan1, 0, vertexCount*2*sizeof(LLVector4a)); - for (U32 a = 0; a < triangleCount; a++) - { - U32 i1 = *index_array++; - U32 i2 = *index_array++; - U32 i3 = *index_array++; + for (U32 a = 0; a < triangleCount; a++) + { + U32 i1 = *index_array++; + U32 i2 = *index_array++; + U32 i3 = *index_array++; - const LLVector4a& v1 = vertex[i1]; - const LLVector4a& v2 = vertex[i2]; - const LLVector4a& v3 = vertex[i3]; + const LLVector4a& v1 = vertex[i1]; + const LLVector4a& v2 = vertex[i2]; + const LLVector4a& v3 = vertex[i3]; - const LLVector2& w1 = texcoord[i1]; - const LLVector2& w2 = texcoord[i2]; - const LLVector2& w3 = texcoord[i3]; + const LLVector2& w1 = texcoord[i1]; + const LLVector2& w2 = texcoord[i2]; + const LLVector2& w3 = texcoord[i3]; const F32* v1ptr = v1.getF32ptr(); const F32* v2ptr = v2.getF32ptr(); const F32* v3ptr = v3.getF32ptr(); - float x1 = v2ptr[0] - v1ptr[0]; - float x2 = v3ptr[0] - v1ptr[0]; - float y1 = v2ptr[1] - v1ptr[1]; - float y2 = v3ptr[1] - v1ptr[1]; - float z1 = v2ptr[2] - v1ptr[2]; - float z2 = v3ptr[2] - v1ptr[2]; + float x1 = v2ptr[0] - v1ptr[0]; + float x2 = v3ptr[0] - v1ptr[0]; + float y1 = v2ptr[1] - v1ptr[1]; + float y2 = v3ptr[1] - v1ptr[1]; + float z1 = v2ptr[2] - v1ptr[2]; + float z2 = v3ptr[2] - v1ptr[2]; - float s1 = w2.mV[0] - w1.mV[0]; - float s2 = w3.mV[0] - w1.mV[0]; - float t1 = w2.mV[1] - w1.mV[1]; - float t2 = w3.mV[1] - w1.mV[1]; + float s1 = w2.mV[0] - w1.mV[0]; + float s2 = w3.mV[0] - w1.mV[0]; + float t1 = w2.mV[1] - w1.mV[1]; + float t2 = w3.mV[1] - w1.mV[1]; F32 rd = s1*t2-s2*t1; @@ -7262,18 +7269,67 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe LLVector4a tdir((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r); + tan1[i1].add(sdir); tan1[i2].add(sdir); tan1[i3].add(sdir); - + + tangential_paranoia(tan1[i1].isFinite3()); + tangential_paranoia(tan1[i2].isFinite3()); + tangential_paranoia(tan1[i3].isFinite3()); + tan2[i1].add(tdir); tan2[i2].add(tdir); tan2[i3].add(tdir); - } - - for (U32 a = 0; a < vertexCount; a++) - { - LLVector4a n = normal[a]; + + tangential_paranoia(tan2[i1].isFinite3()); + tangential_paranoia(tan2[i2].isFinite3()); + tangential_paranoia(tan2[i3].isFinite3()); + } + + // These appear to come out of the summing above distinctly non-unit-length + // + for (U32 a = 0; a < vertexCount; a++) + { + // Conditioning required by assets which don't necessarily reference every vert index + // (i.e. some of the tangents can end up uninitialized and therefore indeterminate/INF) + // and protection against zero length vectors which are not handled by normalize3fast. + // + if (!tan1[a].isFinite3() || tan1[a].equals3(LLVector4a::getZero())) + { + tan1[a].set(0,0,1,1); + } + else + { + tan1[a].normalize3fast(); + } + + if (!tan2[a].isFinite3() || tan2[a].equals3(LLVector4a::getZero())) + { + tan2[a].set(0,0,1,1); + } + else + { + tan2[a].normalize3fast(); + } + + const F32 cefgw = 0.03f; + tangential_paranoia(tan1[a].isFinite3()); + tangential_paranoia(tan2[a].isFinite3()); + tangential_paranoia(tan1[a].isNormalized3(cefgw)); + tangential_paranoia(tan2[a].isNormalized3(cefgw)); + } + + for (U32 a = 0; a < vertexCount; a++) + { + LLVector4a n = normal[a]; + + if (!n.isFinite3() || n.equals3(LLVector4a::getZero())) + { + n.set(0,1,0,1); + } + + n.normalize3fast(); const LLVector4a& t = tan1[a]; @@ -7283,12 +7339,20 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe LLVector4a ncrosst; ncrosst.setCross3(n,t); - // Gram-Schmidt orthogonalize - n.mul(n.dot3(t).getF32()); + F32 n_dot_t = n.dot3(t).getF32(); + + tangential_paranoia(llfinite(n_dot_t) && !llisnan(n_dot_t)); + + // Gram-Schmidt orthogonalize + n.mul(n_dot_t); + + tangential_paranoia(n.isFinite3()); LLVector4a tsubn; tsubn.setSub(t,n); + tangential_paranoia(tsubn.isFinite3()); + if (tsubn.dot3(tsubn).getF32() > F_APPROXIMATELY_ZERO) { tsubn.normalize3fast(); @@ -7300,6 +7364,8 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe tangent[a] = tsubn; + tangential_paranoia(tangent[a].isNormalized3(0.1f)); + llassert(llfinite(tangent[a].getF32ptr()[0])); llassert(llfinite(tangent[a].getF32ptr()[1])); llassert(llfinite(tangent[a].getF32ptr()[2])); -- cgit v1.2.3 From d2b253f1f6072beead770519849ad3b18a1a4359 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 09:16:19 -0700 Subject: Changes to protect against use of normalize3fast on degenerate vectors --- indra/llmath/llvector4a.h | 5 ++ indra/llmath/llvector4a.inl | 22 ++++++++- indra/llmath/llvolume.cpp | 116 ++++++++++++++++++-------------------------- 3 files changed, 73 insertions(+), 70 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h index 0526793d3a..94a61f2b1d 100755 --- a/indra/llmath/llvector4a.h +++ b/indra/llmath/llvector4a.h @@ -236,6 +236,11 @@ public: // Note that this does not consider zero length vectors! inline void normalize3fast(); + // Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed + // Same as above except substitutes default vector contents if the vector is non-finite or degenerate due to zero length. + // + inline void normalize3fast_checked(LLVector4a* default = NULL); + // Return true if this vector is normalized with respect to x,y,z up to tolerance inline LLBool32 isNormalized3( F32 tolerance = 1e-3 ) const; diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 4589bac9fb..6860252a75 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -410,8 +410,26 @@ inline LLSimdScalar LLVector4a::normalize3withLength() // Note that this does not consider zero length vectors! inline void LLVector4a::normalize3fast() { - // find out about bad math before it takes two man-days to track down - llassert(isFinite3() && !equals3(getZero())); + LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); + const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ); + mQ = _mm_mul_ps( mQ, approxRsqrt ); +} + +// Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed +// Note that this does not consider zero length vectors! +inline void LLVector4a::normalize3fast_checked(LLVector4a* default) +{ + // handle bogus inputs before NaNs are generated below + // + if (!isFinite3() || (dot3(*this).getF32() < F_APPROXIMATELY_ZERO)) + { + if (default) + *this = *default; + else + set(0,1,0,1); + + return; + } LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ); diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index bc2572375a..15621c2625 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4472,6 +4472,9 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, continue; //skip degenerate face } + LLVector4a default_norm; + default_norm.set(0,1,0,1); + //for each edge for (S32 k = 0; k < 3; k++) { S32 index = face.mEdge[j*3+k]; @@ -4493,14 +4496,14 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, norm_mat.rotate(n[v1], t); - t.normalize3fast(); + t.normalize3fast_checked(&default_norm); normals.push_back(LLVector3(t[0], t[1], t[2])); mat.affineTransform(v[v2], t); vertices.push_back(LLVector3(t[0], t[1], t[2])); norm_mat.rotate(n[v2], t); - t.normalize3fast(); + t.normalize3fast_checked(&default_norm); normals.push_back(LLVector3(t[0], t[1], t[2])); } } @@ -6096,6 +6099,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) { VertexData corners[4]; VertexData baseVert; + LLVector4a default_norm; + default_norm.set(0,1,0,1); + for(S32 t = 0; t < 4; t++) { corners[t].getPosition().load3( mesh[offset + (grid_size*t)].mPos.mV); @@ -6108,8 +6114,8 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) lhs.setSub(corners[1].getPosition(), corners[0].getPosition()); LLVector4a rhs; rhs.setSub(corners[2].getPosition(), corners[1].getPosition()); - baseVert.getNormal().setCross3(lhs, rhs); - baseVert.getNormal().normalize3fast(); + baseVert.getNormal().setCross3(lhs, rhs); + baseVert.getNormal().normalize3fast_checked(&default_norm); } if(!(mTypeMask & TOP_MASK)) @@ -6559,17 +6565,12 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) d1.setSub(mPositions[mIndices[2]], mPositions[mIndices[0]]); LLVector4a normal; - normal.setCross3(d0,d1); - - if (normal.dot3(normal).getF32() > F_APPROXIMATELY_ZERO) - { - normal.normalize3fast(); - } - else - { //degenerate, make up a value - normal.set(0,0,1); - } + LLVector4a default_norm; + default_norm.set(0,1,0,1); + normal.setCross3(d0,d1); + normal.normalize3fast_checked(&default_norm); + llassert(llfinite(normal.getF32ptr()[0])); llassert(llfinite(normal.getF32ptr()[1])); llassert(llfinite(normal.getF32ptr()[2])); @@ -6611,11 +6612,13 @@ void LLVolumeFace::createTangents() CalculateTangentArray(mNumVertices, mPositions, mNormals, mTexCoords, mNumIndices/3, mIndices, mTangents); //normalize tangents + LLVector4a default_norm; + default_norm.set(0,1,0,1); for (U32 i = 0; i < mNumVertices; i++) { //binorm[i].normalize3fast(); //bump map/planar projection code requires normals to be normalized - mNormals[i].normalize3fast(); + mNormals[i].normalize3fast_checked(&default_norm); } } } @@ -6793,6 +6796,9 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat mat.loadu(mat_in); norm_mat.loadu(norm_mat_in); + LLVector4a default_norm; + default_norm.set(0,1,0,1); + for (U32 i = 0; i < face.mNumVertices; ++i) { //transform appended face position and store @@ -6800,7 +6806,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat //transform appended face normal and store norm_mat.rotate(src_norm[i], dst_norm[i]); - dst_norm[i].normalize3fast(); + dst_norm[i].normalize3fast_checked(&default_norm); //copy appended face texture coordinate dst_tc[i] = src_tc[i]; @@ -7209,7 +7215,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) return TRUE; } -#define TANGENTIAL_PARANOIA_ASSERTS 1 +#define TANGENTIAL_PARANOIA_ASSERTS 0 #if TANGENTIAL_PARANOIA_ASSERTS #define tangential_paranoia(a) llassert(a) @@ -7289,47 +7295,28 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe // These appear to come out of the summing above distinctly non-unit-length // + LLVector4a default_norm; + default_norm.set(0,1,0,1); + for (U32 a = 0; a < vertexCount; a++) { - // Conditioning required by assets which don't necessarily reference every vert index - // (i.e. some of the tangents can end up uninitialized and therefore indeterminate/INF) - // and protection against zero length vectors which are not handled by normalize3fast. - // - if (!tan1[a].isFinite3() || tan1[a].equals3(LLVector4a::getZero())) - { - tan1[a].set(0,0,1,1); - } - else - { - tan1[a].normalize3fast(); - } + tan1[a].normalize3fast_checked(&default_norm); + tan2[a].normalize3fast_checked(&default_norm); - if (!tan2[a].isFinite3() || tan2[a].equals3(LLVector4a::getZero())) - { - tan2[a].set(0,0,1,1); - } - else - { - tan2[a].normalize3fast(); - } - - const F32 cefgw = 0.03f; tangential_paranoia(tan1[a].isFinite3()); tangential_paranoia(tan2[a].isFinite3()); - tangential_paranoia(tan1[a].isNormalized3(cefgw)); - tangential_paranoia(tan2[a].isNormalized3(cefgw)); + tangential_paranoia(tan1[a].isNormalized3(0.03f)); + tangential_paranoia(tan2[a].isNormalized3(0.03f)); } + LLVector4a default_tangent; + default_tangent.set(0,0,1,1); + for (U32 a = 0; a < vertexCount; a++) { LLVector4a n = normal[a]; - - if (!n.isFinite3() || n.equals3(LLVector4a::getZero())) - { - n.set(0,1,0,1); - } - - n.normalize3fast(); + + n.normalize3fast_checked(&default_norm); const LLVector4a& t = tan1[a]; @@ -7353,34 +7340,27 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe tangential_paranoia(tsubn.isFinite3()); - if (tsubn.dot3(tsubn).getF32() > F_APPROXIMATELY_ZERO) - { - tsubn.normalize3fast(); + tsubn.normalize3fast_checked(&default_tangent); - // Calculate handedness - F32 handedness = ncrosst.dot3(tan2[a]).getF32() < 0.f ? -1.f : 1.f; + // Calculate handedness + F32 handedness = ncrosst.dot3(tan2[a]).getF32() < 0.f ? -1.f : 1.f; - tsubn.getF32ptr()[3] = handedness; + tsubn.getF32ptr()[3] = handedness; - tangent[a] = tsubn; + tangent[a] = tsubn; - tangential_paranoia(tangent[a].isNormalized3(0.1f)); + tangential_paranoia(tangent[a].isNormalized3(0.1f)); - llassert(llfinite(tangent[a].getF32ptr()[0])); - llassert(llfinite(tangent[a].getF32ptr()[1])); - llassert(llfinite(tangent[a].getF32ptr()[2])); + llassert(llfinite(tangent[a].getF32ptr()[0])); + llassert(llfinite(tangent[a].getF32ptr()[1])); + llassert(llfinite(tangent[a].getF32ptr()[2])); - llassert(!llisnan(tangent[a].getF32ptr()[0])); - llassert(!llisnan(tangent[a].getF32ptr()[1])); - llassert(!llisnan(tangent[a].getF32ptr()[2])); - } - else - { //degenerate, make up a value - tangent[a].set(0,0,1,1); - } + llassert(!llisnan(tangent[a].getF32ptr()[0])); + llassert(!llisnan(tangent[a].getF32ptr()[1])); + llassert(!llisnan(tangent[a].getF32ptr()[2])); } - ll_aligned_free_16(tan1); + ll_aligned_free_16(tan1); } -- cgit v1.2.3 From 1a37ea367159b1ba6c5284add8dd338f96b64e84 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 09:38:04 -0700 Subject: Pedantic adj overly concerned with minute details or formalisms --- indra/llmath/llvector4a.h | 3 ++- indra/llmath/llvector4a.inl | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h index 94a61f2b1d..79d0a44551 100755 --- a/indra/llmath/llvector4a.h +++ b/indra/llmath/llvector4a.h @@ -46,6 +46,7 @@ class LLRotation; // of this writing, July 08, 2010) about getting it implemented before you resort to // LLVector3/LLVector4. ///////////////////////////////// +class LLVector4a; LL_ALIGN_PREFIX(16) class LLVector4a @@ -239,7 +240,7 @@ public: // Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed // Same as above except substitutes default vector contents if the vector is non-finite or degenerate due to zero length. // - inline void normalize3fast_checked(LLVector4a* default = NULL); + inline void normalize3fast_checked(LLVector4a* d = 0); // Return true if this vector is normalized with respect to x,y,z up to tolerance inline LLBool32 isNormalized3( F32 tolerance = 1e-3 ) const; diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 6860252a75..d3e8a1c933 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -417,14 +417,14 @@ inline void LLVector4a::normalize3fast() // Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed // Note that this does not consider zero length vectors! -inline void LLVector4a::normalize3fast_checked(LLVector4a* default) +inline void LLVector4a::normalize3fast_checked(LLVector4a* d) { // handle bogus inputs before NaNs are generated below // if (!isFinite3() || (dot3(*this).getF32() < F_APPROXIMATELY_ZERO)) { - if (default) - *this = *default; + if (d) + *this = *d; else set(0,1,0,1); -- cgit v1.2.3 From 9726f3774d58e5d9d78648bb5185f694a9f70954 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 10:26:06 -0700 Subject: Backout tangent assert experiment --- indra/llmath/llvector4a.inl | 27 ------- indra/llmath/llvolume.cpp | 178 ++++++++++++++++---------------------------- 2 files changed, 66 insertions(+), 139 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 6860252a75..7c52ffef21 100755 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -331,9 +331,6 @@ inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const // Note that this does not consider zero length vectors! inline void LLVector4a::normalize3() { - // find out about bad math before it takes two man-days to track down - llassert(isFinite3() && !equals3(getZero())); - // lenSqrd = a dot a LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); // rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 } @@ -382,9 +379,6 @@ inline void LLVector4a::normalize4() // Note that this does not consider zero length vectors! inline LLSimdScalar LLVector4a::normalize3withLength() { - // find out about bad math before it takes two man-days to track down - llassert(isFinite3() && !equals3(getZero())); - // lenSqrd = a dot a LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); // rsqrt = approximate reciprocal square (i.e., { ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2, ~1/len(a)^2 } @@ -415,27 +409,6 @@ inline void LLVector4a::normalize3fast() mQ = _mm_mul_ps( mQ, approxRsqrt ); } -// Normalize this vector with respect to the x, y, and z components only. Accurate only to 10-12 bits of precision. W component is destroyed -// Note that this does not consider zero length vectors! -inline void LLVector4a::normalize3fast_checked(LLVector4a* default) -{ - // handle bogus inputs before NaNs are generated below - // - if (!isFinite3() || (dot3(*this).getF32() < F_APPROXIMATELY_ZERO)) - { - if (default) - *this = *default; - else - set(0,1,0,1); - - return; - } - - LLVector4a lenSqrd; lenSqrd.setAllDot3( *this, *this ); - const LLQuad approxRsqrt = _mm_rsqrt_ps(lenSqrd.mQ); - mQ = _mm_mul_ps( mQ, approxRsqrt ); -} - // Return true if this vector is normalized with respect to x,y,z up to tolerance inline LLBool32 LLVector4a::isNormalized3( F32 tolerance ) const { diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 15621c2625..1932272afb 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4472,9 +4472,6 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, continue; //skip degenerate face } - LLVector4a default_norm; - default_norm.set(0,1,0,1); - //for each edge for (S32 k = 0; k < 3; k++) { S32 index = face.mEdge[j*3+k]; @@ -4496,14 +4493,14 @@ void LLVolume::generateSilhouetteVertices(std::vector &vertices, norm_mat.rotate(n[v1], t); - t.normalize3fast_checked(&default_norm); + t.normalize3fast(); normals.push_back(LLVector3(t[0], t[1], t[2])); mat.affineTransform(v[v2], t); vertices.push_back(LLVector3(t[0], t[1], t[2])); norm_mat.rotate(n[v2], t); - t.normalize3fast_checked(&default_norm); + t.normalize3fast(); normals.push_back(LLVector3(t[0], t[1], t[2])); } } @@ -6099,9 +6096,6 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) { VertexData corners[4]; VertexData baseVert; - LLVector4a default_norm; - default_norm.set(0,1,0,1); - for(S32 t = 0; t < 4; t++) { corners[t].getPosition().load3( mesh[offset + (grid_size*t)].mPos.mV); @@ -6114,8 +6108,8 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) lhs.setSub(corners[1].getPosition(), corners[0].getPosition()); LLVector4a rhs; rhs.setSub(corners[2].getPosition(), corners[1].getPosition()); - baseVert.getNormal().setCross3(lhs, rhs); - baseVert.getNormal().normalize3fast_checked(&default_norm); + baseVert.getNormal().setCross3(lhs, rhs); + baseVert.getNormal().normalize3fast(); } if(!(mTypeMask & TOP_MASK)) @@ -6565,12 +6559,17 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) d1.setSub(mPositions[mIndices[2]], mPositions[mIndices[0]]); LLVector4a normal; - LLVector4a default_norm; - default_norm.set(0,1,0,1); - normal.setCross3(d0,d1); - normal.normalize3fast_checked(&default_norm); - + + if (normal.dot3(normal).getF32() > F_APPROXIMATELY_ZERO) + { + normal.normalize3fast(); + } + else + { //degenerate, make up a value + normal.set(0,0,1); + } + llassert(llfinite(normal.getF32ptr()[0])); llassert(llfinite(normal.getF32ptr()[1])); llassert(llfinite(normal.getF32ptr()[2])); @@ -6612,13 +6611,11 @@ void LLVolumeFace::createTangents() CalculateTangentArray(mNumVertices, mPositions, mNormals, mTexCoords, mNumIndices/3, mIndices, mTangents); //normalize tangents - LLVector4a default_norm; - default_norm.set(0,1,0,1); for (U32 i = 0; i < mNumVertices; i++) { //binorm[i].normalize3fast(); //bump map/planar projection code requires normals to be normalized - mNormals[i].normalize3fast_checked(&default_norm); + mNormals[i].normalize3fast(); } } } @@ -6796,9 +6793,6 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat mat.loadu(mat_in); norm_mat.loadu(norm_mat_in); - LLVector4a default_norm; - default_norm.set(0,1,0,1); - for (U32 i = 0; i < face.mNumVertices; ++i) { //transform appended face position and store @@ -6806,7 +6800,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat //transform appended face normal and store norm_mat.rotate(src_norm[i], dst_norm[i]); - dst_norm[i].normalize3fast_checked(&default_norm); + dst_norm[i].normalize3fast(); //copy appended face texture coordinate dst_tc[i] = src_tc[i]; @@ -7215,53 +7209,46 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) return TRUE; } -#define TANGENTIAL_PARANOIA_ASSERTS 0 - -#if TANGENTIAL_PARANOIA_ASSERTS - #define tangential_paranoia(a) llassert(a) -#else - #define tangential_paranoia(a) -#endif - //adapted from Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”. Terathon Software 3D Graphics Library, 2001. http://www.terathon.com/code/tangent.html void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal, const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent) { + //LLVector4a *tan1 = new LLVector4a[vertexCount * 2]; LLVector4a* tan1 = (LLVector4a*) ll_aligned_malloc_16(vertexCount*2*sizeof(LLVector4a)); - LLVector4a* tan2 = tan1 + vertexCount; + LLVector4a* tan2 = tan1 + vertexCount; memset(tan1, 0, vertexCount*2*sizeof(LLVector4a)); - for (U32 a = 0; a < triangleCount; a++) - { - U32 i1 = *index_array++; - U32 i2 = *index_array++; - U32 i3 = *index_array++; + for (U32 a = 0; a < triangleCount; a++) + { + U32 i1 = *index_array++; + U32 i2 = *index_array++; + U32 i3 = *index_array++; - const LLVector4a& v1 = vertex[i1]; - const LLVector4a& v2 = vertex[i2]; - const LLVector4a& v3 = vertex[i3]; + const LLVector4a& v1 = vertex[i1]; + const LLVector4a& v2 = vertex[i2]; + const LLVector4a& v3 = vertex[i3]; - const LLVector2& w1 = texcoord[i1]; - const LLVector2& w2 = texcoord[i2]; - const LLVector2& w3 = texcoord[i3]; + const LLVector2& w1 = texcoord[i1]; + const LLVector2& w2 = texcoord[i2]; + const LLVector2& w3 = texcoord[i3]; const F32* v1ptr = v1.getF32ptr(); const F32* v2ptr = v2.getF32ptr(); const F32* v3ptr = v3.getF32ptr(); - float x1 = v2ptr[0] - v1ptr[0]; - float x2 = v3ptr[0] - v1ptr[0]; - float y1 = v2ptr[1] - v1ptr[1]; - float y2 = v3ptr[1] - v1ptr[1]; - float z1 = v2ptr[2] - v1ptr[2]; - float z2 = v3ptr[2] - v1ptr[2]; + float x1 = v2ptr[0] - v1ptr[0]; + float x2 = v3ptr[0] - v1ptr[0]; + float y1 = v2ptr[1] - v1ptr[1]; + float y2 = v3ptr[1] - v1ptr[1]; + float z1 = v2ptr[2] - v1ptr[2]; + float z2 = v3ptr[2] - v1ptr[2]; - float s1 = w2.mV[0] - w1.mV[0]; - float s2 = w3.mV[0] - w1.mV[0]; - float t1 = w2.mV[1] - w1.mV[1]; - float t2 = w3.mV[1] - w1.mV[1]; + float s1 = w2.mV[0] - w1.mV[0]; + float s2 = w3.mV[0] - w1.mV[0]; + float t1 = w2.mV[1] - w1.mV[1]; + float t2 = w3.mV[1] - w1.mV[1]; F32 rd = s1*t2-s2*t1; @@ -7275,48 +7262,18 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe LLVector4a tdir((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r); - tan1[i1].add(sdir); tan1[i2].add(sdir); tan1[i3].add(sdir); - - tangential_paranoia(tan1[i1].isFinite3()); - tangential_paranoia(tan1[i2].isFinite3()); - tangential_paranoia(tan1[i3].isFinite3()); - + tan2[i1].add(tdir); tan2[i2].add(tdir); tan2[i3].add(tdir); - - tangential_paranoia(tan2[i1].isFinite3()); - tangential_paranoia(tan2[i2].isFinite3()); - tangential_paranoia(tan2[i3].isFinite3()); - } - - // These appear to come out of the summing above distinctly non-unit-length - // - LLVector4a default_norm; - default_norm.set(0,1,0,1); - - for (U32 a = 0; a < vertexCount; a++) - { - tan1[a].normalize3fast_checked(&default_norm); - tan2[a].normalize3fast_checked(&default_norm); - - tangential_paranoia(tan1[a].isFinite3()); - tangential_paranoia(tan2[a].isFinite3()); - tangential_paranoia(tan1[a].isNormalized3(0.03f)); - tangential_paranoia(tan2[a].isNormalized3(0.03f)); - } - - LLVector4a default_tangent; - default_tangent.set(0,0,1,1); - - for (U32 a = 0; a < vertexCount; a++) - { - LLVector4a n = normal[a]; - - n.normalize3fast_checked(&default_norm); + } + + for (U32 a = 0; a < vertexCount; a++) + { + LLVector4a n = normal[a]; const LLVector4a& t = tan1[a]; @@ -7326,41 +7283,38 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe LLVector4a ncrosst; ncrosst.setCross3(n,t); - F32 n_dot_t = n.dot3(t).getF32(); - - tangential_paranoia(llfinite(n_dot_t) && !llisnan(n_dot_t)); - - // Gram-Schmidt orthogonalize - n.mul(n_dot_t); - - tangential_paranoia(n.isFinite3()); + // Gram-Schmidt orthogonalize + n.mul(n.dot3(t).getF32()); LLVector4a tsubn; tsubn.setSub(t,n); - tangential_paranoia(tsubn.isFinite3()); - - tsubn.normalize3fast_checked(&default_tangent); + if (tsubn.dot3(tsubn).getF32() > F_APPROXIMATELY_ZERO) + { + tsubn.normalize3fast(); - // Calculate handedness - F32 handedness = ncrosst.dot3(tan2[a]).getF32() < 0.f ? -1.f : 1.f; + // Calculate handedness + F32 handedness = ncrosst.dot3(tan2[a]).getF32() < 0.f ? -1.f : 1.f; - tsubn.getF32ptr()[3] = handedness; + tsubn.getF32ptr()[3] = handedness; - tangent[a] = tsubn; + tangent[a] = tsubn; - tangential_paranoia(tangent[a].isNormalized3(0.1f)); + llassert(llfinite(tangent[a].getF32ptr()[0])); + llassert(llfinite(tangent[a].getF32ptr()[1])); + llassert(llfinite(tangent[a].getF32ptr()[2])); - llassert(llfinite(tangent[a].getF32ptr()[0])); - llassert(llfinite(tangent[a].getF32ptr()[1])); - llassert(llfinite(tangent[a].getF32ptr()[2])); - - llassert(!llisnan(tangent[a].getF32ptr()[0])); - llassert(!llisnan(tangent[a].getF32ptr()[1])); - llassert(!llisnan(tangent[a].getF32ptr()[2])); + llassert(!llisnan(tangent[a].getF32ptr()[0])); + llassert(!llisnan(tangent[a].getF32ptr()[1])); + llassert(!llisnan(tangent[a].getF32ptr()[2])); + } + else + { //degenerate, make up a value + tangent[a].set(0,0,1,1); + } } - ll_aligned_free_16(tan1); + ll_aligned_free_16(tan1); } -- cgit v1.2.3 From 7b28a9a541464ece86e6d09fe7a85f307a710ddb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 13 Jun 2013 14:38:51 -0500 Subject: Remove some now useless assertions. --- indra/llmath/llvolume.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 1932272afb..a8f4c52c5c 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -7299,14 +7299,6 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe tsubn.getF32ptr()[3] = handedness; tangent[a] = tsubn; - - llassert(llfinite(tangent[a].getF32ptr()[0])); - llassert(llfinite(tangent[a].getF32ptr()[1])); - llassert(llfinite(tangent[a].getF32ptr()[2])); - - llassert(!llisnan(tangent[a].getF32ptr()[0])); - llassert(!llisnan(tangent[a].getF32ptr()[1])); - llassert(!llisnan(tangent[a].getF32ptr()[2])); } else { //degenerate, make up a value -- cgit v1.2.3 From fec6ab591ef644ee8058742f16849ca9ff53c6a6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 14 Jun 2013 09:32:23 -0700 Subject: Disable asserts in CalculateTangentArray (discussed with davep) to avoid debugging interruptions from bad assets --- indra/llmath/llvolume.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 1932272afb..c4e1f0c84c 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -7300,13 +7300,15 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe tangent[a] = tsubn; + /* + These are going off on invalid input and hindering other debugging. llassert(llfinite(tangent[a].getF32ptr()[0])); llassert(llfinite(tangent[a].getF32ptr()[1])); llassert(llfinite(tangent[a].getF32ptr()[2])); llassert(!llisnan(tangent[a].getF32ptr()[0])); llassert(!llisnan(tangent[a].getF32ptr()[1])); - llassert(!llisnan(tangent[a].getF32ptr()[2])); + llassert(!llisnan(tangent[a].getF32ptr()[2]));*/ } else { //degenerate, make up a value -- cgit v1.2.3 From ccd04cd66c0a550694fefe41042ef47466780a92 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 18 Jun 2013 17:24:21 -0500 Subject: Occlusion culling overhaul. --- indra/llmath/llvolume.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index a8f4c52c5c..14cebfe5aa 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -7277,9 +7277,6 @@ void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVe const LLVector4a& t = tan1[a]; - llassert(tan1[a].getLength3().getF32() >= 0.f); - llassert(tan2[a].getLength3().getF32() >= 0.f); - LLVector4a ncrosst; ncrosst.setCross3(n,t); -- cgit v1.2.3