svn merge ^/trunk/blender -r40498:40511

This commit is contained in:
Campbell Barton
2011-09-24 11:03:52 +00:00
10 changed files with 799 additions and 772 deletions

View File

@@ -678,9 +678,9 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha
}
static void cdDM_drawFacesTex_common(DerivedMesh *dm,
int (*drawParams)(MTFace *tface, int has_vcol, int matnr),
int (*drawParamsMapped)(void *userData, int index),
void *userData)
int (*drawParams)(MTFace *tface, int has_mcol, int matnr),
int (*drawParamsMapped)(void *userData, int index),
void *userData)
{
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
MVert *mv = cddm->mvert;
@@ -704,7 +704,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
unsigned char *cp = NULL;
if(drawParams) {
flag = drawParams(tf? &tf[i]: NULL, mcol!=NULL, mf->mat_nr);
flag = drawParams(tf? &tf[i]: NULL, (mcol != NULL), mf->mat_nr);
}
else {
if(index) {
@@ -823,7 +823,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
int flag = 1;
if(drawParams) {
flag = drawParams(tf? &tf[actualFace]: NULL, mcol!=NULL, mf[actualFace].mat_nr);
flag = drawParams(tf? &tf[actualFace]: NULL, (mcol != NULL), mf[actualFace].mat_nr);
}
else {
if(index) {
@@ -866,7 +866,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
}
}
static void cdDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_vcol, int matnr))
static void cdDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr))
{
cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL);
}
@@ -1046,7 +1046,6 @@ static void cdDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawOptions)(void
cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, userData);
}
static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert, int smoothnormal)
{
int b;
@@ -1086,12 +1085,11 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int
/* vertex normal */
if(smoothnormal)
glNormal3sv(mvert[index].no);
/* vertex coordinate */
glVertex3fv(mvert[index].co);
}
static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *attribs), int (*setDrawOptions)(void *userData, int index), void *userData)
{
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
@@ -1166,11 +1164,11 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v1, 0, smoothnormal);
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v2, 1, smoothnormal);
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, smoothnormal);
if(mface->v4)
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v4, 3, smoothnormal);
else
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, smoothnormal);
}
glEnd();
}
@@ -1474,7 +1472,8 @@ static void cdDM_foreachMappedFaceCenter(
if (index) {
orig = *index++;
if(orig == ORIGINDEX_NONE) continue;
} else
}
else
orig = i;
ml = &cddm->mloop[mf->loopstart];
@@ -1489,8 +1488,7 @@ static void cdDM_foreachMappedFaceCenter(
normal_quad_v3(no, mv[ml->v].co, mv[(ml+1)->v].co,
mv[(ml+2)->v].co, mv[(ml+3)->v].co);
} else {
normal_tri_v3(no, mv[ml->v].co, mv[(ml+1)->v].co,
mv[(ml+2)->v].co);
normal_tri_v3(no, mv[ml->v].co, mv[(ml+1)->v].co, mv[(ml+2)->v].co);
}
func(userData, orig, cent, no);

View File

@@ -1803,7 +1803,7 @@ static void cgdm_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), unsi
}
static void cgdm_drawFacesTex_common(DerivedMesh *dm,
int (*drawParams)(MTFace *tface, int has_vcol, int matnr),
int (*drawParams)(MTFace *tface, int has_mcol, int matnr),
int (*drawParamsMapped)(void *userData, int index),
void *userData)
{
@@ -1839,7 +1839,7 @@ static void cgdm_drawFacesTex_common(DerivedMesh *dm,
}
if(drawParams)
flag = drawParams(tf, mcol!=NULL, mat_nr);
flag = drawParams(tf, (mcol != NULL), mat_nr);
else if (index != ORIGINDEX_NONE)
flag= (drawParamsMapped)? drawParamsMapped(userData, index): 1;
else
@@ -3088,8 +3088,8 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
result->freeSS = 1;
}
}
return (DerivedMesh *)result;
return (DerivedMesh*)result;
}
void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])

View File

@@ -285,6 +285,8 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
void MESH_OT_primitive_circle_add(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Add Circle";
ot->description= "Construct a circle mesh";
@@ -300,7 +302,8 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot)
/* props */
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 3, 500);
RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
RNA_def_property_subtype(prop, PROP_DISTANCE);
RNA_def_enum(ot->srna, "fill_type", fill_type_items, 0, "Fill Type", "");
ED_object_add_generic_props(ot, TRUE);
@@ -339,6 +342,8 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Add Tube";
ot->description= "Construct a tube mesh";
@@ -354,8 +359,10 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
/* props */
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 2, 500);
RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00);
prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00);
RNA_def_property_subtype(prop, PROP_DISTANCE);
prop = RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00);
RNA_def_property_subtype(prop, PROP_DISTANCE);
RNA_def_enum(ot->srna, "end_fill_type", fill_type_items, 1, "Cap Fill Type", "");
ED_object_add_generic_props(ot, TRUE);
@@ -394,6 +401,8 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
void MESH_OT_primitive_cone_add(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Add Cone";
ot->description= "Construct a conic mesh (ends filled)";
@@ -411,7 +420,8 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot)
RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 2, 500);
RNA_def_float(ot->srna, "radius1", 1.0f, 0.0, FLT_MAX, "Radius 1", "", 0.001, 100.00);
RNA_def_float(ot->srna, "radius2", 0.0f, 0.0, FLT_MAX, "Radius 2", "", 0.001, 100.00);
RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00);
prop = RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00);
RNA_def_property_subtype(prop, PROP_DISTANCE);
RNA_def_enum(ot->srna, "end_fill_type", fill_type_items, 1, "Base Fill Type", "");
ED_object_add_generic_props(ot, TRUE);
@@ -449,6 +459,8 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
void MESH_OT_primitive_grid_add(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Add Grid";
ot->description= "Construct a grid mesh";
@@ -465,7 +477,8 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot)
/* props */
RNA_def_int(ot->srna, "x_subdivisions", 10, INT_MIN, INT_MAX, "X Subdivisions", "", 3, 1000);
RNA_def_int(ot->srna, "y_subdivisions", 10, INT_MIN, INT_MAX, "Y Subdivisions", "", 3, 1000);
RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, FLT_MAX);
prop = RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, FLT_MAX);
RNA_def_property_subtype(prop, PROP_DISTANCE);
ED_object_add_generic_props(ot, TRUE);
}
@@ -547,6 +560,8 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Add UV Sphere";
ot->description= "Construct a UV sphere mesh";
@@ -563,7 +578,8 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
/* props */
RNA_def_int(ot->srna, "segments", 32, INT_MIN, INT_MAX, "Segments", "", 3, 500);
RNA_def_int(ot->srna, "rings", 24, INT_MIN, INT_MAX, "Rings", "", 3, 500);
RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, 100.00);
prop = RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, FLT_MAX);
RNA_def_property_subtype(prop, PROP_DISTANCE);
ED_object_add_generic_props(ot, TRUE);
}
@@ -599,6 +615,8 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Add Ico Sphere";
ot->description= "Construct an Icosphere mesh";
@@ -614,7 +632,8 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot)
/* props */
RNA_def_int(ot->srna, "subdivisions", 2, 0, 6, "Subdivisions", "", 0, 8);
RNA_def_float(ot->srna, "size", 1.0f, 0.0f, FLT_MAX, "Size", "", 0.001f, 100.00);
prop = RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, FLT_MAX);
RNA_def_property_subtype(prop, PROP_DISTANCE);
ED_object_add_generic_props(ot, TRUE);
}

View File

@@ -365,7 +365,7 @@ static void draw_textured_end(void)
glPopMatrix();
}
static int draw_tface__set_draw_legacy(MTFace *tface, int has_vcol, int matnr)
static int draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr)
{
Material *ma= give_current_material(Gtexdraw.ob, matnr+1);
int validtexture=0;
@@ -380,7 +380,7 @@ static int draw_tface__set_draw_legacy(MTFace *tface, int has_vcol, int matnr)
} else if (ma && ma->shade_flag&MA_OBCOLOR) {
glColor3ubv(Gtexdraw.obcol);
return 2; /* Don't set color */
} else if (!has_vcol) {
} else if (!has_mcol) {
if (tface) glColor3f(1.0, 1.0, 1.0);
else {
if(ma) {
@@ -397,7 +397,7 @@ static int draw_tface__set_draw_legacy(MTFace *tface, int has_vcol, int matnr)
return 1; /* Set color from mcol */
}
}
static int draw_tface__set_draw(MTFace *tface, int has_vcol, int matnr)
static int draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr)
{
Material *ma= give_current_material(Gtexdraw.ob, matnr+1);
@@ -407,7 +407,7 @@ static int draw_tface__set_draw(MTFace *tface, int has_vcol, int matnr)
return 2; /* Don't set color */
} else if (tface && tface->mode&TF_OBCOL) {
return 2; /* Don't set color */
} else if (!has_vcol) {
} else if (!has_mcol) {
return 1; /* Don't set color */
} else {
return 1; /* Set color from mcol */
@@ -495,7 +495,6 @@ static int draw_tface_mapped__set_draw(void *userData, int index)
MTexPoly *tpoly = (me->mtpoly)? &me->mtpoly[index]: NULL;
MPoly *mpoly = (me->mpoly)? &me->mpoly[index]: NULL;
MTFace mtf;
int has_vcol= (me->mcol != NULL);
int matnr = me->mpoly[index].mat_nr;
if (mpoly && mpoly->flag&ME_HIDE) return 0;
@@ -510,37 +509,35 @@ static int draw_tface_mapped__set_draw(void *userData, int index)
mtf.unwrap = tpoly->unwrap;
}
return draw_tface__set_draw(&mtf, has_vcol, matnr);
return draw_tface__set_draw(&mtf, (me->mcol != NULL), matnr);
}
static int draw_em_tf_mapped__set_draw(void *userData, int index)
{
BMEditMesh *em = userData;
struct {BMEditMesh *em; short has_mcol; short has_mtface;} *data = userData;
BMEditMesh *em = data->em;
BMFace *efa= EDBM_get_face_for_index(em, index);
MTexPoly *tpoly;
MTFace mtf;
int has_vcol;
int matnr;
if (efa==NULL || BM_TestHFlag(efa, BM_HIDDEN))
if (efa==NULL || BM_TestHFlag(efa, BM_HIDDEN)) {
return 0;
tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
has_vcol = CustomData_has_layer(&em->bm->ldata, CD_MLOOPCOL);
matnr = efa->mat_nr;
memset(&mtf, 0, sizeof(mtf));
if (tpoly) {
mtf.flag = tpoly->flag;
mtf.tpage = tpoly->tpage;
mtf.transp = tpoly->transp;
mtf.mode = tpoly->mode;
mtf.tile = tpoly->tile;
mtf.unwrap = tpoly->unwrap;
}
else {
MTFace mtf= {{{0}}};
int matnr = efa->mat_nr;
return draw_tface__set_draw_legacy(&mtf, has_vcol, matnr);
if (data->has_mtface) {
MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
mtf.flag = tpoly->flag;
mtf.tpage = tpoly->tpage;
mtf.transp = tpoly->transp;
mtf.mode = tpoly->mode;
mtf.tile = tpoly->tile;
mtf.unwrap = tpoly->unwrap;
}
return draw_tface__set_draw_legacy(&mtf, data->has_mcol, matnr);
}
}
static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmooth_r)
@@ -660,7 +657,13 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
glColor4f(1.0f,1.0f,1.0f,1.0f);
if(ob->mode & OB_MODE_EDIT) {
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_btmesh);
struct {BMEditMesh *em; short has_mcol; short has_mtface;} data;
data.em= me->edit_btmesh;
data.has_mcol= CustomData_has_layer(&me->edit_btmesh->bm->ldata, CD_MLOOPCOL);
data.has_mtface= CustomData_has_layer(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY);
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, &data);
}
else if(faceselect) {
if(ob->mode & OB_MODE_WEIGHT_PAINT)

View File

@@ -139,7 +139,7 @@ static void drawNavMeshColored(DerivedMesh *dm)
glEnable(GL_LIGHTING);
}
static void navDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, MCol *mcol, int matnr))
static void navDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr))
{
(void) setDrawOptions;

View File

@@ -829,7 +829,7 @@ static int CheckTexfaceDM(void *mcol, int index)
}
*/
static int CheckTexDM(MTFace *tface, int has_vcol, int matnr)
static int CheckTexDM(MTFace *tface, int has_mcol, int matnr)
{
// index is the original face index, retrieve the polygon
@@ -844,7 +844,7 @@ static int CheckTexDM(MTFace *tface, int has_vcol, int matnr)
// don't use mcol
return 2;
}
if (!has_vcol) {
if (!has_mcol) {
// we have to set the color from the material
unsigned char rgba[4];
current_polymat->GetMaterialRGBAColor(rgba);