[Bf-committers] Per-Vertex properties implementation

Gregor Mückl bf-committers@blender.org
Tue, 15 Jul 2003 15:40:26 +0200


--Boundary-00=_KRAF/NO3PV2ALuf
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Description: clearsigned data
Content-Disposition: inline

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

I'm currently writing down notes on the changes that are required to get=20
per-vertex properties running. I have appended a first version of these not=
es=20
which are (naturally) full of holes.

I'll have to ask for help on a lot of areas. My main concern is currently t=
he=20
GUI because I do not know where to place the extra buttons I need. I am ope=
n=20
to ideas :-)

Regards,
Gregor
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/FARNTN1O8kLyTwsRAk7SAJ9ZJ0DveSDVT6Fed2D1aexlon6bHACglcx3
Oe1TkqsEg3uyL/Td6V1/a80=3D
=3Dj2l+
=2D----END PGP SIGNATURE-----

--Boundary-00=_KRAF/NO3PV2ALuf
Content-Type: text/plain;
  charset="us-ascii";
  name="pvpdesign.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="pvpdesign.txt"

PER-VERTEX PROPERTIES
*********************

This document discusses some of the design ideas and implementation issues with
this feature.

GENERAL IDEA
------------

The idea is to extend the current property mechanism in a way that allows the
assignment of properties to single vertices in a mesh.

Because assigning properties to large numbers of vertices some convenience
features should be provided. For this purpose I suggest the creation of
"property sets" which group individual properties. Property sets can be shared
between vertices. Each vertex can be assigned a couple of property sets
simultaneously. The idea is to manage the property sets in stack so that
properties can be overridden.

EXAMPLE
-------

[Note that this is a completely arbitrary example :-)]

Create a property set named "basicarmour"
Add a property named "armour", type integer, value 1000
Add a property named "shiny", type integer, value 0

Create a propety set named "shinyarmour"
Add a property named "shiny", type integer, value 1
Add a property named "reflective", type integer, value 1

Create a sphere and select a vertex.

Assign the property set "basicarmour" to the vertex

This means that the vertex will in effect have the following properties and
values:

- "armour", type integer, value 1000
- "shiny", type integer, value 0

Add a property named "armour", type integer, value 10 to the vertex

Then the visible property values for the vertex look like this:
- "armour", type integer, value 10
- "shiny", type integer, value 0

Note that the property set "basicarmour" is unchanged

Assign the property set "shinyarmour" to the top of the stack for this
vertex.

Then the visible property values would look like this:
- "armour", type integer, value 10
- "shiny", type integer, value 1
- "reflective", type integer, value 1

USER INTERFACE CHANGES
----------------------

Adopt that stack-like management for object properties from the real time tab
for property sets and per-vertex properties. But there's no space left among
these buttons.

TODO: So Where should I put it?

TODO: Add a detailed description of the required changes. I will need a lot of
assistance here.

NEW DNA STRUCTS
---------------

struct bPropertySet {
  char name[32];
  struct bProperty *prop; /* properties are stored in a linked list */
};

struct bPropSetLink {
  struct bPropertySet *pset;
  struct bPropSetLink *next;
};

struct bVertexProperties {
  struct MVert *vert; /* Vertex this struct is assigned to */
  struct bProperty *local; /* properties that are assigned only to this vertex*/
  struct bPropSetLink *propsets; /* a linked list pointing to all the property
                                    sets that are assigned to this vertex */
};

NOTE: Is it a good idea to refer to a vertex like that? How else could it be
done? Adding a pointer to the MVert struct seems a bit too heavy to me.

NEW DNA STRUCT MEMBERS
----------------------

in the Mesh struct:
  void *vertexprop; /* pointer to an array of bVertexProperties */
  struct bPropSetLink *allpsets; /* a linked list of all property sets in this
                                    mesh */

REQUIRED FUNCTIONS
------------------

[NOTE: I use C++ syntax on purpose to keep the primitves short]

/* Functions for manipulating property sets */
bPropertySet *PSetCreate(Mesh *mesh);
void PSetDestroy(Mesh *mesh, bPropertySet *pset);
void PSetAddProp(bPropertySet *pset, bProperty *prop);
void PSetRemoveProp(bPropertySet *pset, bPropertySet *prop);

bProperty *PSetFind(bPropertySet *pset, char *name);

/* Functions for manipulating vertex properties */
bVertexProperties *VPropCreate(Mesh *mesh, MVert *mvert);
void VPropDestroy(Mesh *mesh, bVertexProperties *props);
void VPropAddSet(bVertexProperties *vertexprops, bPropertySet *pset);
void VPropRemoveSet(bVertexProperties *vertexprops, bPropertySet *pset);
void VPropAddProp(bVertexProperties *vertexprops, bProperty *prop);
void VPropRemoveProp(bVertexProperties *vertexprops, bProperty *prop);

bProperty *VPropFind(bVertexProperties *vertexprops, char *name);

A couple of additional functions could be needed. But this list should cover the
basic functionality.

TODO: Where to put these functions

TODO: What about Python interface?

--Boundary-00=_KRAF/NO3PV2ALuf--