Browse Source

Fixed ray-torus intersection so it properly handles all quadrants

Marko Pintera 11 years ago
parent
commit
9b7e69903c
3 changed files with 5 additions and 10 deletions
  1. 0 1
      BansheeEditor/Source/BsHandleSliderDisc.cpp
  2. 3 6
      BansheeUtility/Source/BsTorus.cpp
  3. 2 3
      TODO.txt

+ 0 - 1
BansheeEditor/Source/BsHandleSliderDisc.cpp

@@ -34,7 +34,6 @@ namespace BansheeEngine
 		localRay.transform(getTransformInv());
 
 		auto intersect = mCollider.intersects(localRay);
-
 		if (intersect.first)
 		{
 			t = intersect.second;

+ 3 - 6
BansheeUtility/Source/BsTorus.cpp

@@ -42,15 +42,12 @@ namespace BansheeEngine
 			for (UINT32 i = 0; i < numRoots; i++)
 			{
 				float t = roots[i];
-				float x = org.x + t*dir.x;
-				float y = org.y + t*dir.y;
-				float l = outerRadius*(Math::PI / 2 - Math::atan2(y, x).valueRadians());
-
-				if (l >= 0 && t < nearestT)
+				if (t > 0 && t < nearestT)
 					nearestT = t;
 			}
 
-			return std::make_pair(true, nearestT);
+			if (nearestT > std::numeric_limits<float>::epsilon())
+				return std::make_pair(true, nearestT);
 		}
 
 		return std::make_pair(false, 0.0f); 

+ 2 - 3
TODO.txt

@@ -11,15 +11,14 @@ Possibly set up automatic refresh in debug mode after initialization? As an ad-h
 
 <<<<<<Handles>>>>>>>>
 
-Add free rotate handle
 Add free scale handle
 
 Rotate handle:
- - Transparent angle start is at the wrong position
  - Selecting the top right quadrant of the blue disc doesn't seem to work
  - Missing two free rotate arcs
  - How to handle local/global with rotate handle?
-
+ - Backside of handle disc sliders shouldn't be interactable
+   - Add an "cutoffPlane" parameter to block intersection with backside if enabled
 
 Cursor wrap only works when cursor moves really slowly over the border, and even then it's spotty
 When changing handle types they do not refresh until you click on the scene view