Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2011 by Bastien Montagne. 00019 * All rights reserved. 00020 * 00021 * Contributor(s): None yet. 00022 * 00023 * ***** END GPL LICENSE BLOCK ***** 00024 * 00025 */ 00026 00032 #ifndef MOD_WEIGHTVG_UTIL_H 00033 #define MOD_WEIGHTVG_UTIL_H 00034 00035 /* so modifier types match their defines */ 00036 #include "MOD_modifiertypes.h" 00037 00038 struct CurveMapping; 00039 struct DerivedMesh; 00040 struct Object; 00041 struct Tex; 00042 00043 /* 00044 * XXX I'd like to make modified weights visible in WeightPaint mode, 00045 * but couldn't figure a way to do this... 00046 * Maybe this will need changes in mesh_calc_modifiers (DerivedMesh.c)? 00047 * Or the WeightPaint mode code itself? 00048 */ 00049 00050 /************************************** 00051 * Util functions. * 00052 **************************************/ 00053 00054 /* We cannot divide by zero (what a surprise...). 00055 * So if -MOD_WEIGHTVGROUP_DIVMODE_ZEROFLOOR < weightf < MOD_WEIGHTVGROUP_DIVMODE_ZEROFLOOR, 00056 * we clamp weightf to this value (or its negative version). 00057 * Also used to avoid null power factor. 00058 */ 00059 #define MOD_WVG_ZEROFLOOR 1.0e-32f 00060 00061 /* Maps new_w weights in place, using either one of the predifined functions, or a custom curve. 00062 * Return values are in new_w. 00063 * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real 00064 * vertex index (in case the weight tables do not cover the whole vertices...). 00065 * cmap might be NULL, in which case curve mapping mode will return unmodified data. 00066 */ 00067 void weightvg_do_map(int num, float *new_w, short mode, struct CurveMapping *cmap); 00068 00069 /* Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor. 00070 * Return values are in org_w. 00071 * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real 00072 * vertex index (in case the weight tables do not cover the whole vertices...). 00073 * XXX The standard “factor” value is assumed in [0.0, 1.0] range. Else, weird results might appear. 00074 */ 00075 void weightvg_do_mask(int num, const int *indices, float *org_w, const float *new_w, Object *ob, 00076 DerivedMesh *dm, float fact, const char defgrp_name[MAX_VGROUP_NAME], Tex *texture, 00077 int tex_use_channel, int tex_mapping, Object *tex_map_object, 00078 const char *tex_uvlayer_name); 00079 00080 /* Applies weights to given vgroup (defgroup), and optionnaly add/remove vertices from the group. 00081 * If indices is not NULL, it must be a table of same length as weights, mapping to the real 00082 * vertex index (in case the weight table does not cover the whole vertices...). 00083 */ 00084 void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws, int num, 00085 const int *indices, const float *weights, int do_add, 00086 float add_thresh, int do_rem, float rem_thresh); 00087 00088 #endif /* MOD_WEIGHTVG_UTIL_H */