[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37281] branches/soc-2011-onion: Revision: 30696
Jason Wilkins
Jason.A.Wilkins at gmail.com
Tue Jun 7 01:28:08 CEST 2011
Revision: 37281
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37281
Author: jwilkins
Date: 2011-06-06 23:28:08 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
Revision: 30696
Author: nicholasbishop
Date: 3:33:35 PM, Saturday, July 24, 2010
Message:
== Multires/VPaint ==
Enable multires painting.
* Added operator/RNA/UI to toggle multires for vertex colors. (UI is not great right now, just a button in mesh data properties.)
* Added layer names to GridKey. These are used (in combination with CD type) to identify the source layer from CustomData.
* Changed default mcol to white with alpha=0
* Renamed CD_FACEGRID to CD_GRIDS, removed CD_DISP
* Added a new CustomDataMultires type (CD_GRIDS), which stores layered data like CustomData. However, it only stores float types, and is very simplified.
* Reworked PaintMask to use the new CD multires stuff, also used for vertex colors.
* Started changing vpaint to internally use floats.
* Layering support for multires vpaint. Layer alpha is used to combine the output.
TODO:
* Doesn't handle layer renaming yet (so if you rename your mcol layer, it'll disassociate from the multires data)
* Layers for non-multires vpaint
* Default mcol layer in the startup blend has full alpha, so for testing layers you have to delete the default mcol layer and add new ones.
* Multires level in vpaint is controlled by the Preview level
Modified Paths:
--------------
branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_data_mesh.py
branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h
branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h
branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.c
branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c
branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
branches/soc-2011-onion/source/blender/blenloader/intern/readfile.c
branches/soc-2011-onion/source/blender/blenloader/intern/writefile.c
branches/soc-2011-onion/source/blender/editors/mesh/mesh_data.c
branches/soc-2011-onion/source/blender/editors/mesh/mesh_intern.h
branches/soc-2011-onion/source/blender/editors/mesh/mesh_ops.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c
branches/soc-2011-onion/source/blender/makesdna/DNA_customdata_types.h
branches/soc-2011-onion/source/blender/makesrna/intern/rna_mesh.c
Property Changed:
----------------
branches/soc-2011-onion/
Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30676,30692-30693
/trunk/blender:36833-37206
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30676,30692-30693,30696
/trunk/blender:36833-37206
Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_data_mesh.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_data_mesh.py 2011-06-06 23:19:25 UTC (rev 37280)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_data_mesh.py 2011-06-06 23:28:08 UTC (rev 37281)
@@ -350,7 +350,12 @@
if lay:
layout.prop(lay, "name")
+ if lay.multiresolution:
+ layout.operator("mesh.vertex_color_multiresolution_toggle", text="Remove Multires")
+ else:
+ layout.operator("mesh.vertex_color_multiresolution_toggle", text="Add Multires")
+
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object.data"
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h 2011-06-06 23:19:25 UTC (rev 37280)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h 2011-06-06 23:28:08 UTC (rev 37281)
@@ -43,6 +43,7 @@
struct ID;
struct CustomData;
struct CustomDataLayer;
+struct CustomDataMultires;
typedef unsigned int CustomDataMask;
extern const CustomDataMask CD_MASK_BAREMESH;
@@ -243,6 +244,8 @@
int CustomData_get_clone_layer(const struct CustomData *data, int type);
int CustomData_get_stencil_layer(const struct CustomData *data, int type);
+char *CustomData_get_layer_name_at_offset(const struct CustomData *data, int type, int offset);
+
/* copies the data from source to the data element at index in the first
* layer of type
* no effect if there is no layer of type
@@ -280,6 +283,7 @@
/* adds flag to the layer flags */
void CustomData_set_layer_flag(struct CustomData *data, int type, int flag);
+void CustomData_set_layer_offset_flag(struct CustomData *data, int type, int offset, int flag);
/* alloc/free a block of custom data attached to one element in editmode */
void CustomData_em_set_default(struct CustomData *data, void **block);
@@ -320,8 +324,39 @@
void CustomData_bmesh_init_pool(struct CustomData *data, int allocsize);
/* Subsurf grids */
-void CustomData_set_num_grid_elements(struct CustomData *data, int grid_elems);
+/* return the number of layers of type that have multires data */
+int CustomData_get_multires_count(struct CustomData *cd, int type);
+
+/* allocates a list of names of layers that have multires data */
+void *CustomData_get_multires_names(struct CustomData *cd, int type);
+
+/* number of floats used per-element for the multires of a customdata type */
+int CustomData_multires_type_totfloat(int type);
+
+/* returns the multires data for a layer matching name and type,
+ or NULL if no such layer found */
+float *CustomData_multires_get_data(struct CustomDataMultires *cdm, int type,
+ char *name);
+
+/* if layer matching type and name exists, free and replace its griddata
+ otherwise create the layer and set its griddata */
+void CustomData_multires_assign_data(struct CustomDataMultires *cdm, int type,
+ char *name, float *data);
+
+/* insert a multires layer of the specified type */
+void CustomData_multires_add_layer(struct CustomDataMultires *cdm, int type,
+ char *name, float *data);
+
+/* remove the multires layer with matching source name
+ returns 1 if succesful, 0 otherwise */
+int CustomData_multires_remove_layer(struct CustomDataMultires *cdm, int type,
+ char *name);
+
+/* rename a layer matching type and old_name */
+void CustomData_multires_rename(struct CustomDataMultires *cdm, int type,
+ char *old_name, char *name);
+
/* External file storage */
void CustomData_external_add(struct CustomData *data,
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h 2011-06-06 23:19:25 UTC (rev 37280)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h 2011-06-06 23:28:08 UTC (rev 37281)
@@ -4,37 +4,45 @@
/* Each grid element can contain zero or more layers of coordinates,
paint masks, and normals; these numbers are stored in the GridKey
- For now, co and no can have only zero or one layers, only mask is
- really variable.
+ The name arrays are the unique names of the source customdata layer
*/
typedef struct GridKey {
int co;
int color;
int mask;
int no;
+
+ /* key to identify the source layer */
+ char (*color_names)[32];
+ char (*mask_names)[32];
} GridKey;
-#define GRIDELEM_KEY_INIT(_gridkey, _totco, _totcolor, _totmask, _totno) \
- ((_gridkey)->co = _totco, (_gridkey)->color = _totcolor, (_gridkey)->mask = _totmask, (_gridkey)->no = _totno)
+#define GRIDELEM_KEY_INIT(_key, _totco, _totcolor, _totmask, _totno) \
+ ((_key)->co = _totco, (_key)->color = _totcolor, \
+ (_key)->mask = _totmask, (_key)->no = _totno, \
+ (_key)->color_names = NULL, (_key)->mask_names = NULL)
-#define GRIDELEM_SIZE(_key) ((3*(_key)->co + 3*(_key)->color + (_key)->mask + 3*(_key)->no) * sizeof(float))
-#define GRIDELEM_INTERP_COUNT(_key) (3*(_key)->co + 3*(_key)->color + (_key)->mask)
+#define GRIDELEM_SIZE(_key) ((3*(_key)->co + 4*(_key)->color + (_key)->mask + 3*(_key)->no) * sizeof(float))
+#define GRIDELEM_INTERP_COUNT(_key) (3*(_key)->co + 4*(_key)->color + (_key)->mask)
#define GRIDELEM_COLOR_OFFSET(_key) (3*(_key)->co*sizeof(float))
-#define GRIDELEM_MASK_OFFSET(_key) (GRIDELEM_COLOR_OFFSET(_key) + 3*(_key)->color*sizeof(float))
+#define GRIDELEM_MASK_OFFSET(_key) (GRIDELEM_COLOR_OFFSET(_key) + 4*(_key)->color*sizeof(float))
#define GRIDELEM_NO_OFFSET(_key) (GRIDELEM_MASK_OFFSET(_key) + (_key)->mask*sizeof(float))
#define GRIDELEM_AT(_grid, _elem, _key) ((struct DMGridData*)(((char*)(_grid)) + (_elem) * GRIDELEM_SIZE(_key)))
#define GRIDELEM_INC(_grid, _inc, _key) ((_grid) = GRIDELEM_AT(_grid, _inc, _key))
+ /* I can't figure out how to cast this type without a typedef,
+ having the array length is useful to directly index layers */
+typedef float (*gridelem_f4)[4];
#define GRIDELEM_CO(_grid, _key) ((float*)(_grid))
-#define GRIDELEM_COLOR(_grid, _key) ((float*)((char*)(_grid) + GRIDELEM_COLOR_OFFSET(_key)))
+#define GRIDELEM_COLOR(_grid, _key) ((gridelem_f4)((char*)(_grid) + GRIDELEM_COLOR_OFFSET(_key)))
+#define GRIDELEM_MASK(_grid, _key) ((float*)((char*)(_grid) + GRIDELEM_MASK_OFFSET(_key)))
#define GRIDELEM_NO(_grid, _key) ((float*)((char*)(_grid) + GRIDELEM_NO_OFFSET(_key)))
-#define GRIDELEM_MASK(_grid, _key) ((float*)((char*)(_grid) + GRIDELEM_MASK_OFFSET(_key)))
#define GRIDELEM_CO_AT(_grid, _elem, _key) GRIDELEM_CO(GRIDELEM_AT(_grid, _elem, _key), _key)
#define GRIDELEM_COLOR_AT(_grid, _elem, _key) GRIDELEM_COLOR(GRIDELEM_AT(_grid, _elem, _key), _key)
+#define GRIDELEM_MASK_AT(_grid, _elem, _key) GRIDELEM_MASK(GRIDELEM_AT(_grid, _elem, _key), _key)
#define GRIDELEM_NO_AT(_grid, _elem, _key) GRIDELEM_NO(GRIDELEM_AT(_grid, _elem, _key), _key)
-#define GRIDELEM_MASK_AT(_grid, _elem, _key) GRIDELEM_MASK(GRIDELEM_AT(_grid, _elem, _key), _key)
#endif
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.c 2011-06-06 23:19:25 UTC (rev 37280)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.c 2011-06-06 23:28:08 UTC (rev 37281)
@@ -759,6 +759,15 @@
_ehash_free(ss->eMap, (EHEntryFreeFP) _edge_free, ss);
_ehash_free(ss->vMap, (EHEntryFreeFP) _vert_free, ss);
+ /* free gridkey */
+ if(ss->meshIFC.gridkey.color_names)
+ MEM_freeN(ss->meshIFC.gridkey.color_names);
+ if(ss->meshIFC.gridkey.mask_names)
+ MEM_freeN(ss->meshIFC.gridkey.mask_names);
+
+ ss->meshIFC.gridkey.color_names = NULL;
+ ss->meshIFC.gridkey.mask_names = NULL;
+
CCGSUBSURF_free(ss, ss);
if (allocatorIFC.release) {
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c 2011-06-06 23:19:25 UTC (rev 37280)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c 2011-06-06 23:28:08 UTC (rev 37281)
@@ -798,7 +798,7 @@
static void layerDefault_mcol(void *data, int count)
{
- static MCol default_mcol = {255, 255, 255, 255};
+ static MCol default_mcol = {0, 255, 255, 255}; /* abgr */
MCol *mcol = (MCol*)data;
int i;
@@ -808,26 +808,41 @@
/* Grid */
-void layerCopy_grid(const void *source_v, void *dest_v, int count)
+static void layerCopy_grid(const void *source_v, void *dest_v, int count)
{
- const CustomData *source = source_v;
- CustomData *dest = dest_v;
- int i;
+ const CustomDataMultires *source = source_v;
+ CustomDataMultires *dest = dest_v;
+ int i, j;
for(i = 0; i < count; ++i) {
- CustomData_copy(source + i, dest + i, ~0, CD_DUPLICATE,
- source[i].grid_elems);
- dest[i].grid_elems = source[i].grid_elems;
+ dest[i].totlayer = source[i].totlayer;
+ dest[i].layers = MEM_callocN(sizeof(CustomDataMultiresLayer) *
+ dest[i].totlayer,
+ "CustomDataMultiresLayers");
+
+ for(j = 0; j < source[i].totlayer; ++j) {
+ CustomDataMultiresLayer *dl = dest[i].layers + j;
+ CustomDataMultiresLayer *sl = source[i].layers + j;
+
+ dl->type = sl->type;
+ dl->griddata = MEM_dupallocN(sl->griddata);
+ BLI_strncpy(dl->name, sl->name, sizeof(dl->name));
+ }
}
}
-void layerFree_grid(void *data, int count, int size)
+static void layerFree_grid(void *data_v, int count, int size)
{
- CustomData *cd = data;
- int i;
+ CustomDataMultires *data = data_v;
+ int i, j;
for(i = 0; i < count; ++i) {
- CustomData_free(cd + i, cd[i].grid_elems);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list