|
|
> Attached is a sample source-code file from POV-Ray 3.7 - cones.cpp. This
> is
> an example of what we'd need to convert for 4.0 - all the code would need
> to be stripped out and re-implemented with the same functionality (this
> does not mean that it has to do things the same way - e.g. someone might
> have ideas of how to do it more efficiently - but otherwise it's a matter
> of understanding how the original code works and making a new version).
>
> -- Chris
Hmm, so cone calculation consists of 16 functions,
and some of the data is being passed globally.
I'd guess to get a handle on re-writing this stuff
you need a good understanding of what the global
data structures are, and what data really gets
passed to and from each function.
Here's a guess at what these functions in cone.cpp do...
/*
// --------------------------------------------------------------------------
All_Intersections
Return a true value if this cone intersects this
ray in this thread; and if the cone has intersections
that are not on the global stack of intersections
for this thread, add them.
Input:
a ray, a stack of intersections, a thread
Output:
a boolean, a modified stack of intersections
-ALSO USES GLOBALLY-
VEvaluateRay, Clip.empty, Point_In_Clip
// --------------------------------------------------------------------------
Intersect
Try to find an intersection with a ray in a thread,
return 0 if none found, 1 for a base, 2 for a cap,
3 for a side; Don't intersect base and cap if open, and
add intersections distances, and type to the array.
Messages:
(always) Thread->Stats[Ray_Cone_Tests]++
(if an intersection found) Thread->Stats[Ray_Cone_Tests_Succeeded]++;
Input:
a ray, a thread, an intersection array
Output:
A modified intersection array, the number of intersections
-ALSO USES GLOBALLY-
MInvTransPoint, MInvTransDirection, VLength,
VInverseScaleEq, Test_Flag (CYLINDER_FLAG, CLOSED_FLAG),
fabs, MAX_DISTANCE, EPSILON, X, Y, Z
// --------------------------------------------------------------------------
Inside
Return true if point is inside a cone (or cylinder),
and inverts the result if the cone is inverted.
Input:
a vector point, a thread
Output:
a boolean
-ALSO USES GLOBALLY-
MInvTransPoint, Test_Flag, CYLINDER_FLAG, INVERTED_FLAG,
CLOSED_FLAG, EPSILON
// --------------------------------------------------------------------------
Normal
Return a normal based on the intersection type and location.
Input:
a result vector, an intersection, a thread
Output:
a result vector with the normal
-ALSO USES GLOBALLY-
MInvTransPoint, Z, Make_Vector, MTransNormal, VNormalize
// --------------------------------------------------------------------------
Translate
Translate a cone. This function is a minimal call to Transform.
Input:
a vector (unused?) and a transform
Output:
actions
-ALSO USES GLOBALLY-
Transform
// --------------------------------------------------------------------------
Rotate
Rotate a cone. This function is a minimal call to Transform.
Input:
a vector (unused?) and a transform
Output:
actions
-ALSO USES GLOBALLY-
Transform
// --------------------------------------------------------------------------
Scale
Scale a cone. This function is a minimal call to Transform.
Input:
a vector (unused?) and a transform
Output:
actions
-ALSO USES GLOBALLY-
Transform
// --------------------------------------------------------------------------
Transform
Transform a cone. This function is a minimal call to Transform
and a call to Compute_BBox.
Input:
a transform
Output:
actions
-ALSO USES GLOBALLY-
Transform, Compute_BBox
// --------------------------------------------------------------------------
Invert
Set the inverted flag for a cone.
Input:
none
Output:
an inverted flag
-ALSO USES GLOBALLY-
Invert_Flag, INVERTED_FLAG
// --------------------------------------------------------------------------
Cone
Initialize the default values for a cone in global space,
and do the same in local space.
Input:
none
Global Output:
calls INIT_OBJECT_FIELDS, Set_Flag, a bounding box
Local Output:
apex and base vectors, apex_radius, base_radius, dist, Trans
-ALSO USES GLOBALLY-
Make_Vector, Create_Transform, Make_BBox, CONE_OBJECT, CLOSED_FLAG
// --------------------------------------------------------------------------
Copy
Create a new cone object which is a copy of another cone.
Input:
none
Output:
a pointer to a new cone, and a new transform for the cone
-ALSO USES GLOBALLY-
Destroy_Transform, Copy_Transform
// --------------------------------------------------------------------------
Cylinder
Set apex_radius and base_radius, and set the cylinder flag.
Input:
none
Output:
A cylinder flag, a local apex_radius and base_radius
-ALSO USES GLOBALLY-
Set_Flag
// --------------------------------------------------------------------------
Compute_Cone_Data
If this cone is really a cylinder call Compute_Cylinder_Data
instead. Throw a degenerate exception if apex and base are
nearly equal. Swap base with apex if base is larger. Calculate
and perform a transform that will result in a standard cone.
Input:
none
Output:
dist, Trans, apex, base, apex_radius, base_radius, a bounding box
-ALSO USES GLOBALLY-
VSub, VLength, VInverseScaleEq, VScale, Compute_Coordinate_Transform,
POV_EXCEPTION_STRING
// --------------------------------------------------------------------------
Compute_Cylinder_Data
Throw a degenerate exception if apex and base are
nearly equal. Calculate and perform a transform that will
result in a standard cylinder.
Input:
none
Output:
dist, Trans, a new bounding box
-ALSO USES GLOBALLY-
VSub, VLength, VInverseScaleEq, Compute_Coordinate_Transform,
POV_EXCEPTION_STRING
// --------------------------------------------------------------------------
~Cone
Destroy a cone. This function is a minimal call to Destroy_Transform.
Input:
none
Output:
none
-ALSO USES GLOBALLY-
Destroy_Transform
// --------------------------------------------------------------------------
Compute_BBox
Make a new bounding box.
Input:
none
Output:
a new bounding box.
-ALSO USES GLOBALLY-
Make_BBox, Recompute_BBox
// --------------------------------------------------------------------------
Post a reply to this message
|
|