[Bf-committers] Object Oriented Render API

Aaron Moore two.a.ron at gmail.com
Wed Jun 20 04:17:26 CEST 2007

The render API must provide a way for a plugin to query blender. I
feel that the best way to organize this is through a hierarchical
scene description: a hierarchy of objects. Functions (methods) which
operate on these objects would provide all of the querying
functionality of the API.

I have found two styles which object oriented functionality can be
created in C. First, the use of prefixes to associate function methods
with the structs they work on. Second, (as observed in the DerivedMesh
structure by Artificer), a list of function pointers may be included
in a struct, and an initialization function assigns the appropriate
functions to these pointers.

First method syntax example:
    DMesh_copyVertArray(dm, mvert);

Second method syntax example:
    dm->copyVertArray(dm, mvert);

I like the second method because it seems to present a more clear
association of the method with the object. It would be harder for a
sane person to use that syntax incorrectly in my opinion.

I propose that the Render API be organized as a hierarchy of structs
which contain meta data and function pointers required to perform all
the necessary queries on blender. To get an idea here is an example:

   /* methods */
   get_reused_objects (for data that has multiple instances)
   get_changed_objects (for animations)
   set_coordinates (camera, world, local, etc.)
   /* data */
   object camera
   object_list lights
   object_list objects

object (a 3d instance of something)
   /* methods */
   /* data */
   type (is this a light, mesh, curve, camera, object_group...)
   data (pointer to light, mesh, curve, camera, object_group... data structure)


I am asserting that it is a good idea to store all of the API
meta-data and functions in a bundle like this. If no one disagrees, I
will proceed using the hierarchical object-oriented model with the
second syntax method above stated.


More information about the Bf-committers mailing list