POV-Ray : Newsgroups : povray.general : Status of Moray? : Re: Status of Moray? Server Time
15 Jul 2025 07:28:05 EDT (-0400)
  Re: Status of Moray?  
From: Nicolas Alvarez
Date: 28 Sep 2007 23:22:03
Message: <46fdc4db@news.povray.org>

> Nicolas Alvarez wrote:
>>
>>
>> Please don't let POV-Ray be written in "C plus classes". C++ is so 
>> much more
>> than that! :)
> 
> Well, since you were the first one to say it...
> 
> Yeah, C++ has more features than the classes, but the classes provide a 
> great deal of the advantage that C++ has over C, mainly because of the 
> way that classes lead to better organization of code.
> 
> The polymorphism helps a lot, too, but on a project as large as POV-Ray, 
> the ability to organize code in a consistent way will bring benefits 
> that will make the benefit from other features easy to overlook.
> 
> Regards,
> John

Of course classes are one big advantage over plain C. But (following 
your example) polymorphism helps a *big* lot to something like POV-Ray. 
You have an abstract Object class (in C++ that would mean it has pure 
virtual methods), and classes that extend it like Sphere, Cylinder, 
Isosurface, and probably CSG objects too (I don't know how CSG code is 
organized currently). You can also have a Camera class with the 
different projections inheriting from it, instead of the *big* switch 
block that is used now. Classes give "the ability to organize code in a 
consistent way". Polymorphism gives the ability to use those classes in 
a consistent (or should I say *identical*?) way.

Objects all have the same basic interface after all. Intersect ray, 
is-point-inside-object, etc. So do camera projections, they basically 
just have to convert a 2D point (pixel in final image) into a starting 
point and a direction.

I can imagine it would be a lot easier to add a new object / camera 
projection / pattern on an unofficial POV if it's all nice OOP. For 
example, the parser could be split that way too (ObjectParser where 
SphereParser etc extend from). Not much more than write two classes and 
add new keywords to the lexer and you're done...

What about exceptions? Probably not very useful for the renderer, but I 
think they could help for the parser, or the frontend-backend separation 
"thing".


Post a reply to this message

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