POV-Ray : Newsgroups : povray.programming : POV-Ray C++? Server Time
29 Feb 2024 04:11:30 EST (-0500)
  POV-Ray C++? (Message 11 to 13 of 13)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: MiB
Subject: Re: POV-Ray C++?
Date: 4 Jan 2012 19:45:01
Message: <web.4f04f1d8c9ae25fcb154c30@news.povray.org>
Thank you a lot for the clarification.

kind regards,

   MiB.


Post a reply to this message

From: clipka
Subject: Re: POV-Ray C++?
Date: 13 Jan 2012 19:11:31
Message: <4f10c833@news.povray.org>
Am 05.01.2012 01:34, schrieb MiB:

> Pretty much the first file I touched was
> povwin-src-3.7-RC3\source\backend\scene\objects.h
>
> Here, object types and properties are defined by flag values, operations on
> flags are preprocessor macros, operations on objects (including
> copy-construction and destructors!) are global functions instead of members of
> the Object class.

Yup. The core code to handle geometric primitives, patterns, textures 
and such didn't need any significant changes to run on multiprocessor 
systems (with the crackle pattern being the only notable exception I'm 
currently aware of), so it just hasn't been "objectified" - yet.

I'm pretty itchy to work on those parts, too, but of course it won't 
happen in 3.7.


Post a reply to this message

From: David Buck
Subject: Re: POV-Ray C++?
Date: 12 Feb 2012 11:50:47
Message: <4f37ede7$1@news.povray.org>
MiB wrote:
> Warp <war### [at] tagpovrayorg> wrote:
>> MiB <nomail@nomail> wrote:
>>> However, a quick survey reveals POV-Ray itself is not written in a contemporary
>>> object-oriented style; a lot of pointers to structs are handed around, functions
>>> manipulating data structures are on a global level and not members of classes.
>>   Could you give some clarifying examples of this, as well as a suggestion
>> of how it should be done better?
> 
> Pretty much the first file I touched was
> povwin-src-3.7-RC3\source\backend\scene\objects.h
> 
> Here, object types and properties are defined by flag values, operations on
> flags are preprocessor macros, operations on objects (including
> copy-construction and destructors!) are global functions instead of members of
> the Object class.

When I wrote DKBTrace originally, I had already been doing Smalltalk 
programming for a few years and was quite familiar with object oriented 
concepts.  Smalltalk obviously wasn't a good candidate language for 
implementing DKBTrace (sadly) and C was the only real alternative.

As such, you'll find that parts of the code do have an object oriented 
spin to them.  Take cones, for example.  In cones.cpp you'll find:

METHODS Cone_Methods =
{
   All_Cone_Intersections,
   Inside_Cone, Cone_Normal, Default_UVCoord,
   (COPY_METHOD)Copy_Cone, Translate_Cone, Rotate_Cone, Scale_Cone, 
Transform_Cone,
   Invert_Cone, Destroy_Cone
};

This is a virtual table of functions that allows call points to 
polymorphically call methods on objects without knowing the types of the 
objects.

This approach is difficult to maintain and wasn't used for other parts 
of the rendering system like vectors and textures.

Re-writing POVRay in C++ would probably be a good idea but obviously a 
lot of work. I would suggest staying away from some of the more 
difficult C++ concepts like multiple inheritance and operator 
overloading if you can.  I would agree to operator overloading for 
vectors and matrices since they make the syntax much nicer.  I'm not a 
fan of templates, but that's just my opinion.

David Buck


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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