PATCH : 0001431: corrections to torus physical mesh for default hollow shape and taper orientation along path.

--------- From Dahlia!  Thanks Dahlia!!!
the attached patch reinstates the default hollow shape of the physics mesh of the torus prim type and corrects the orientation of the effects of taper on the profile along the path.
0.6.0-stable
Teravus Ovares 2008-06-02 08:31:34 +00:00
parent c0f631dbdb
commit 832d609b44
2 changed files with 38 additions and 19 deletions

View File

@ -260,8 +260,11 @@ namespace OpenSim.Region.Physics.Meshing
int steps = 24; int steps = 24;
float twistTotal = twistTop - twistBot; float twistTotal = twistTop - twistBot;
if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 1.5) steps *= 2; // if the profile has a lot of twist, add more layers otherwise the layers may overlap
if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 3.0) steps *= 2; // and the resulting mesh may be quite inaccurate. This method is arbitrary and doesnt
// accurately match the viewer
if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 1.5f) steps *= 2;
if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 3.0f) steps *= 2;
double percentOfPathMultiplier = 1.0 / steps; double percentOfPathMultiplier = 1.0 / steps;
double angleStepMultiplier = System.Math.PI * 2.0 / steps; double angleStepMultiplier = System.Math.PI * 2.0 / steps;
@ -271,10 +274,10 @@ namespace OpenSim.Region.Physics.Meshing
float totalSkew = skew * 2.0f * pathLength; float totalSkew = skew * 2.0f * pathLength;
float skewStart = (-skew) + pathCutBegin * 2.0f * skew; float skewStart = (-skew) + pathCutBegin * 2.0f * skew;
float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions); float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions);
float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions); float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions);
float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution
step = (int)(startAngle / stepSize); step = (int)(startAngle / stepSize);
float angle = startAngle; float angle = startAngle;
@ -291,11 +294,11 @@ namespace OpenSim.Region.Physics.Meshing
bool done = false; bool done = false;
do do // loop through the length of the path and add the layers
{ {
float percentOfPath = 1.0f; newLayer = m.Clone();
percentOfPath = (angle - startAngle) / (endAngle - startAngle); // endAngle should always be larger than startAngle float percentOfPath = (angle - startAngle) / (endAngle - startAngle); // endAngle should always be larger than startAngle
if (pathTaperX > 0.001f) // can't really compare to 0.0f as the value passed is never exactly zero if (pathTaperX > 0.001f) // can't really compare to 0.0f as the value passed is never exactly zero
xProfileScale = 1.0f - percentOfPath * pathTaperX; xProfileScale = 1.0f - percentOfPath * pathTaperX;
@ -309,6 +312,20 @@ namespace OpenSim.Region.Physics.Meshing
yProfileScale = 1.0f + (1.0f - percentOfPath) * pathTaperY; yProfileScale = 1.0f + (1.0f - percentOfPath) * pathTaperY;
else yProfileScale = 1.0f; else yProfileScale = 1.0f;
#if SPAM
//System.Console.WriteLine("xProfileScale: " + xProfileScale.ToString() + " yProfileScale: " + yProfileScale.ToString());
#endif
Vertex vTemp = new Vertex(0.0f, 0.0f, 0.0f);
// apply the taper to the profile before any rotations
if (xProfileScale != 1.0f || yProfileScale != 1.0f)
foreach (Vertex v in newLayer.vertices)
if ( v != null )
{
v.X *= xProfileScale;
v.Y *= yProfileScale;
}
float radiusScale; float radiusScale;
if (radius > 0.001f) if (radius > 0.001f)
@ -317,11 +334,11 @@ namespace OpenSim.Region.Physics.Meshing
radiusScale = 1.0f + radius * (1.0f - percentOfPath); radiusScale = 1.0f + radius * (1.0f - percentOfPath);
else radiusScale = 1.0f; else radiusScale = 1.0f;
//radiusScale = 1.0f;
#if SPAM #if SPAM
System.Console.WriteLine("Extruder: angle: " + angle.ToString() + " percentOfPath: " + percentOfPath.ToString() System.Console.WriteLine("Extruder: angle: " + angle.ToString() + " percentOfPath: " + percentOfPath.ToString()
+ " radius: " + radius.ToString() + " radiusScale: " + radiusScale.ToString()); + " radius: " + radius.ToString() + " radiusScale: " + radiusScale.ToString()
+ " xProfileScale: " + xProfileScale.ToString() + " yProfileScale: " + yProfileScale.ToString());
#endif #endif
float twist = twistBot + (twistTotal * (float)percentOfPath); float twist = twistBot + (twistTotal * (float)percentOfPath);
@ -330,10 +347,7 @@ namespace OpenSim.Region.Physics.Meshing
float yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale; float yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale;
float xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath); float xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath);
newLayer = m.Clone(); // next apply twist rotation to the profile
Vertex vTemp = new Vertex(0.0f, 0.0f, 0.0f);
if (twistTotal != 0.0f || twistBot != 0.0f) if (twistTotal != 0.0f || twistBot != 0.0f)
{ {
Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist); Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist);
@ -349,19 +363,22 @@ namespace OpenSim.Region.Physics.Meshing
} }
} }
// now orient the rotation of the profile relative to it's position on the path
Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle); Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle);
foreach (Vertex v in newLayer.vertices) foreach (Vertex v in newLayer.vertices)
{ {
if (v != null) if (v != null)
{ {
vTemp = v * layerRot; vTemp = v * layerRot;
v.X = xProfileScale * vTemp.X + xOffset; //v.X = xProfileScale * vTemp.X + xOffset;
v.Y = yProfileScale * vTemp.Y + yOffset; //v.Y = yProfileScale * vTemp.Y + yOffset;
v.X = vTemp.X + xOffset;
v.Y = vTemp.Y + yOffset;
v.Z = vTemp.Z + zOffset; v.Z = vTemp.Z + zOffset;
} }
} }
if (angle == startAngle) // last layer, invert normals if (angle == startAngle) // the first layer, invert normals
foreach (Triangle t in newLayer.triangles) foreach (Triangle t in newLayer.triangles)
{ {
t.invertNormal(); t.invertNormal();
@ -407,7 +424,7 @@ namespace OpenSim.Region.Physics.Meshing
angle = endAngle; angle = endAngle;
} }
} while (!done); } while (!done); // loop until all the layers in the path are completed
// scale the mesh to the desired size // scale the mesh to the desired size
float xScale = size.X; float xScale = size.X;

View File

@ -1541,7 +1541,7 @@ namespace OpenSim.Region.Physics.Meshing
} }
else else
{ {
holeHull = BuildHoleHull(primShape, primShape.ProfileShape, primShape.HollowShape, hollowFactor); holeHull = BuildHoleHull(primShape, primShape.ProfileShape, hollowShape, hollowFactor);
} }
if (holeHull != null) if (holeHull != null)
@ -1900,6 +1900,8 @@ namespace OpenSim.Region.Physics.Meshing
private static void reportPrimParams(string name, PrimitiveBaseShape primShape) private static void reportPrimParams(string name, PrimitiveBaseShape primShape)
{ {
#if SPAM #if SPAM
float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f;
float pathShearY = primShape.PathShearY < 128 ? (float)primShape.PathShearY * 0.01f : (float)(primShape.PathShearY - 256) * 0.01f;
Console.WriteLine("********************* PrimitiveBaseShape Parameters *******************\n" Console.WriteLine("********************* PrimitiveBaseShape Parameters *******************\n"
+ "Name.............: " + name.ToString() + "\n" + "Name.............: " + name.ToString() + "\n"
@ -1911,8 +1913,8 @@ namespace OpenSim.Region.Physics.Meshing
+ "PathRevolutions..: " + primShape.PathRevolutions.ToString() + "\n" + "PathRevolutions..: " + primShape.PathRevolutions.ToString() + "\n"
+ "PathScaleX.......: " + primShape.PathScaleX.ToString() + "\n" + "PathScaleX.......: " + primShape.PathScaleX.ToString() + "\n"
+ "PathScaleY.......: " + primShape.PathScaleY.ToString() + "\n" + "PathScaleY.......: " + primShape.PathScaleY.ToString() + "\n"
+ "PathShearX.......: " + primShape.PathShearX.ToString() + "\n" + "PathShearX.......: " + primShape.PathShearX.ToString() + " (" + pathShearX.ToString() + ")\n"
+ "PathShearY.......: " + primShape.PathShearY.ToString() + "\n" + "PathShearY.......: " + primShape.PathShearY.ToString() + " (" + pathShearY.ToString() + ")\n"
+ "PathSkew.........: " + primShape.PathSkew.ToString() + "\n" + "PathSkew.........: " + primShape.PathSkew.ToString() + "\n"
+ "PathTaperX.......: " + primShape.PathTaperX.ToString() + "\n" + "PathTaperX.......: " + primShape.PathTaperX.ToString() + "\n"
+ "PathTaperY.......: " + primShape.PathTaperY.ToString() + "\n" + "PathTaperY.......: " + primShape.PathTaperY.ToString() + "\n"