POV-Ray : Newsgroups : povray.general : Sample source file from POV 3.7 Server Time
25 Dec 2024 14:39:34 EST (-0500)
  Sample source file from POV 3.7 (Message 1 to 9 of 9)  
From: Chris Cason
Subject: Sample source file from POV 3.7
Date: 9 Sep 2007 19:12:02
Message: <46e47dc2$1@news.povray.org>
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


Post a reply to this message


Attachments:
Download 'us-ascii' (11 KB)

From: nemesis
Subject: Re: Sample source file from POV 3.7
Date: 9 Sep 2007 20:55:00
Message: <web.46e495b96d9a658aa233c63e0@news.povray.org>
Chris Cason <del### [at] deletethistoopovrayorg> wrote:
> Attached is a sample source-code file from POV-Ray 3.7 - cones.cpp.

ah!  I see this has become a lot more C++ish since the 3.6 source.

> 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

same interface, new implementation.  And, of course, lots of new bugs. :)


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Sample source file from POV 3.7
Date: 9 Sep 2007 23:52:12
Message: <46e4bf6c$1@news.povray.org>
Chris Cason wrote:
> 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).

You should add that we now have vector and color classes as alternative as
well. No more macros needed for that :-)

	Thorsten, POV-Team


Post a reply to this message

From: Tim Attwood
Subject: Re: Sample source file from POV 3.7
Date: 11 Sep 2007 05:48:00
Message: <46e66450$1@news.povray.org>
> 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

From: Thorsten Froehlich
Subject: Re: Sample source file from POV 3.7
Date: 11 Sep 2007 06:02:12
Message: <46e667a4@news.povray.org>
Tim Attwood wrote:
> Hmm, so cone calculation consists of 16 functions,
> and some of the data is being passed globally.

Hmm, where do you see global data in the cone code?

	Thorsten


Post a reply to this message

From: Warp
Subject: Re: Sample source file from POV 3.7
Date: 11 Sep 2007 09:57:22
Message: <46e69ec2@news.povray.org>
Tim Attwood <tim### [at] comcastnet> wrote:
> and some of the data is being passed globally.

  I think those are member functions and variables of that class, not
globals.

-- 
                                                          - Warp


Post a reply to this message

From: John VanSickle
Subject: Re: Sample source file from POV 3.7
Date: 11 Sep 2007 18:33:28
Message: <46e717b8@news.povray.org>
Tim Attwood wrote:

> Hmm, so cone calculation consists of 16 functions,
> and some of the data is being passed globally.

There may have been globals in the vanilla-C days, but this source 
doesn't have globals.  I see no variable definitions outside of the 
functions, which is where the globals would be lurking.

Regards,
John


Post a reply to this message

From: Tim Attwood
Subject: Re: Sample source file from POV 3.7
Date: 12 Sep 2007 00:12:47
Message: <46e7673f$1@news.povray.org>
I think this might be a terminolgy thing,
this class is accessing data elements of
other classes.  If the implementation of
those other classes changed significantly,
then this class may malfunction, but more
important, it makes it hard to read or
to re-write.  All the things I marked as
global are at least non-local, they need
to be looked up by someone new to the
program.  Has anyone written any
documentation?


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Sample source file from POV 3.7
Date: 28 Sep 2007 18:59:24
Message: <46fd874c$1@news.povray.org>

> 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
> 
You really used proper OOP this time! :) That METHODS "thing" was ugly.

I can't wait to get my hands on the new code. I'm particularly very 
interested in the new state file; would give some *proper* checkpointing 
on my BOINC project (I did one hell of a hack to save to (uncompressed) 
file only when BOINC tells me to and create the PNG when the render is 
done).


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.