Skip to content

Instantly share code, notes, and snippets.

@mjn33
Created May 19, 2015 20:29
Show Gist options
  • Save mjn33/50800f05643f062a72a2 to your computer and use it in GitHub Desktop.
Save mjn33/50800f05643f062a72a2 to your computer and use it in GitHub Desktop.
FAR patch
diff --git a/FerramAerospaceResearch/FARAeroComponents/VehicleAerodynamics.cs b/FerramAerospaceResearch/FARAeroComponents/VehicleAerodynamics.cs
index e37cc1e..7a38ad2 100644
--- a/FerramAerospaceResearch/FARAeroComponents/VehicleAerodynamics.cs
+++ b/FerramAerospaceResearch/FARAeroComponents/VehicleAerodynamics.cs
@@ -365,9 +365,10 @@ namespace FerramAerospaceResearch.FARAeroComponents
private Vector3 CalculateVehicleMainAxis()
{
Vector3 axis = Vector3.zero;
- //Vector3 notAxis = Vector3.zero;
+ Vector3 notAxis = Vector3.zero;
HashSet<Part> hitParts = new HashSet<Part>();
+
for (int i = 0; i < _vehiclePartList.Count; i++)
{
Part p = _vehiclePartList[i];
@@ -387,12 +388,11 @@ namespace FerramAerospaceResearch.FARAeroComponents
}
else if (p.Modules.Contains("FARWingAerodynamicModel") || p.Modules.Contains("FARControllableSurface")) //aggregate wings for later calc...
{
- continue;
- /* Vector3 notCandVector = _worldToLocalMatrix.MultiplyVector(p.partTransform.forward);
+ Vector3 notCandVector = _worldToLocalMatrix.MultiplyVector(p.partTransform.forward);
notCandVector.x = Math.Abs(notCandVector.x);
notCandVector.y = Math.Abs(notCandVector.y);
notCandVector.z = Math.Abs(notCandVector.z);
- notAxis += notCandVector;*/
+ notAxis += notCandVector;
}
for (int j = 0; j < p.symmetryCounterparts.Count; j++)
{
@@ -410,14 +410,14 @@ namespace FerramAerospaceResearch.FARAeroComponents
if ((object)intakeTrans != null)
candVector += intakeTrans.forward;
}
- /*else if (q.Modules.Contains("FARWingAerodynamicModel") || q.Modules.Contains("FARControllableSurface")) //aggregate wings for later calc...
+ else if (q.Modules.Contains("FARWingAerodynamicModel") || q.Modules.Contains("FARControllableSurface")) //aggregate wings for later calc...
{
Vector3 notCandVector = _worldToLocalMatrix.MultiplyVector(p.partTransform.forward);
notCandVector.x = Math.Abs(notCandVector.x);
notCandVector.y = Math.Abs(notCandVector.y);
notCandVector.z = Math.Abs(notCandVector.z);
notAxis += notCandVector;
- }*/
+ }
else
candVector += q.partTransform.up;
}
@@ -429,14 +429,14 @@ namespace FerramAerospaceResearch.FARAeroComponents
axis += candVector * p.mass * (1 + p.symmetryCounterparts.Count); //scale part influence by approximate size
}
- /*float perpTest = Math.Abs(Vector3.Dot(axis, notAxis));
+ float perpTest = Math.Abs(Vector3.Dot(axis, notAxis));
if (perpTest > 0.3)
{
axis = Vector3.Cross(axis, notAxis);
axis = Vector3.Cross(axis, notAxis); //this shoudl result in an axis perpendicular to notAxis
//axis.Normalize();
- }*/
+ }
float dotProdX, dotProdY, dotProdZ;
@@ -457,7 +457,7 @@ namespace FerramAerospaceResearch.FARAeroComponents
//Otherwise, now we need to use axis, since it's obviously not close to anything else
- return axis;
+ return axis.normalized;
}
//Smooths out area and area 2nd deriv distributions to deal with noise in the representation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment