Page MenuHome

Cycles API: encapsulate publicly accessible classes
Needs ReviewPublic

Authored by Kévin Dietrich (kevindietrich) on Jan 11 2021, 7:26 PM.

Details

Reviewers
Brecht Van Lommel (brecht)
Group Reviewers
Cycles
Maniphest Tasks
T79131: Cycles/Blender API redesign
Summary

This encapsulates members of publicly accessible classes behind sets of
getters and setters. To determine what is public or not, the Blender
scene exporter was used as a reference.

The getters and setters are defined via macros, located in util_api.h.
Either the property is supposed to be read only (e.g. Scene::geometry),
and only a getter is defined (through the GET macro), or the property
can also be written to publicly, and a setter is defined as well (though
the GET_SET macro).

Now that method calls are used to access data, the code can be a bit
lengthy, or its redundancy might have become noticeable, so some
cleanups could be done. I did deduplicate some logic (mostly for
RenderTileNeighbors), some more could be done, but this patch is big
enough already, and I don't want to risk creating issues or bugs.

The following classes/structures were not encapsulated although they are
accessible from the Blender exporter, as they are either simple
parametric structures (e.g. DeviceDrawParams) or will be made into nodes
(e.g. Image).

  • DeviceDrawParams
  • Image
  • Particle
  • ParticleCurveData
  • SceneParams
  • DenoiseImageLayer

Particle could perhaps also be encapsulated, and maybe also made into a
Node, but that would require a revision of the ParticleSystem Node API
so it would be nicer to work with.

The properties of the following structures were encapsulated.

  • Attribute
  • AttributeRequest
  • AttributeRequestSet
  • AttributeSet
  • BufferParams
  • Camera
  • Denoiser
  • DisplayBuffer
  • Geometry
  • Hair
  • Hair::Curve
  • ImageMerger
  • Mesh
  • Node
  • NodeType
  • OSLNode
  • ParticlesSystem
  • PointDensityTextureNode
  • Pass
  • RenderBuffer
  • RenderTile
  • RenderTileNeighbors
  • Scene
  • Session
  • SessionParams
  • Shader
  • ShaderGraph
  • ShaderInput
  • ShaderNode
  • ShaderOutput
  • SkyTextureNode
  • SocketType
  • Stats
  • TileManager

Diff Detail

Repository
rB Blender
Branch
cycles_api_encapsulation (branched from master)
Build Status
Buildable 12402
Build 12402: arc lint + arc unit