diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_customdata.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/BME_conversions.c | 136 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 3 | ||||
-rw-r--r-- | source/blender/radiosity/intern/source/radrender.c | 15 | ||||
-rw-r--r-- | source/blender/src/editnla.c | 35 | ||||
-rw-r--r-- | source/blender/src/transform_conversions.c | 9 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 2 |
11 files changed, 194 insertions, 33 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 12f68c771e0..e84c7d30956 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -266,7 +266,8 @@ void CustomData_set_layer_unique_name(struct CustomData *data, int index); only after this test passes, layer->data should be assigned */ int CustomData_verify_versions(struct CustomData *data, int index); +/*BMesh specific customdata stuff*/ void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata); -void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata); +void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata, int total); void CustomData_bmesh_init_pool(struct CustomData *data, int allocsize); #endif diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index f375ca62726..daf0de5b748 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -56,6 +56,102 @@ #include "BSE_edit.h" +/*merge these functions*/ +static void BME_DMcorners_to_loops(BME_Mesh *bm, CustomData *facedata, int index, BME_Poly *f, int numCol, int numTex){ + int i, j; + BME_Loop *l; + MTFace *texface; + MTexPoly *texpoly; + MCol *mcol; + MLoopCol *mloopcol; + MLoopUV *mloopuv; + + for(i=0; i< numTex; i++){ + texface = CustomData_get_layer_n(facedata, CD_MTFACE, i); + texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i); + + texpoly->tpage = texface[index].tpage; + texpoly->flag = texface[index].flag; + texpoly->transp = texface[index].transp; + texpoly->mode = texface[index].mode; + texpoly->tile = texface[index].tile; + texpoly->unwrap = texface[index].unwrap; + + j = 0; + l = f->loopbase; + do{ + mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i); + mloopuv->uv[0] = texface[index].uv[j][0]; + mloopuv->uv[1] = texface[index].uv[j][1]; + j++; + l = l->next; + }while(l!=f->loopbase); + } + + for(i=0; i < numCol; i++){ + mcol = CustomData_get_layer_n(facedata, CD_MCOL, i); + j = 0; + l = f->loopbase; + do{ + mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i); + mloopcol->r = mcol[(index*4)+j].r; + mloopcol->g = mcol[(index*4)+j].g; + mloopcol->b = mcol[(index*4)+j].b; + mloopcol->a = mcol[(index*4)+j].a; + j++; + l = l->next; + }while(l!=f->loopbase); + } +} + +static void BME_DMloops_to_corners(BME_Mesh *bm, CustomData *facedata, int index, BME_Poly *f,int numCol, int numTex){ + int i, j; + BME_Loop *l; + MTFace *texface; + MTexPoly *texpoly; + MCol *mcol; + MLoopCol *mloopcol; + MLoopUV *mloopuv; + + for(i=0; i < numTex; i++){ + texface = CustomData_get_layer_n(facedata, CD_MTFACE, i); + texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i); + + texface[index].tpage = texpoly->tpage; + texface[index].flag = texpoly->flag; + texface[index].transp = texpoly->transp; + texface[index].mode = texpoly->mode; + texface[index].tile = texpoly->tile; + texface[index].unwrap = texpoly->unwrap; + + j = 0; + l = f->loopbase; + do{ + mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i); + texface[index].uv[j][0] = mloopuv->uv[0]; + texface[index].uv[j][1] = mloopuv->uv[1]; + j++; + l = l->next; + }while(l!=f->loopbase); + + } + for(i=0; i < numCol; i++){ + mcol = CustomData_get_layer_n(facedata,CD_MCOL, i); + j = 0; + l = f->loopbase; + do{ + mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i); + mcol[(index*4) + j].r = mloopcol->r; + mcol[(index*4) + j].g = mloopcol->g; + mcol[(index*4) + j].b = mloopcol->b; + mcol[(index*4) + j].a = mloopcol->a; + j++; + l = l->next; + }while(l!=f->loopbase); + } +} + + static void BME_corners_to_loops(BME_Mesh *bm, CustomData *facedata, void *face_block, BME_Poly *f,int numCol, int numTex){ int i, j; BME_Loop *l; @@ -271,7 +367,7 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) { CustomData_copy(&bm->vdata, &em->vdata, CD_MASK_BMESH, CD_CALLOC, 0); CustomData_copy(&bm->edata, &em->edata, CD_MASK_BMESH, CD_CALLOC, 0); CustomData_copy(&bm->pdata, &em->fdata, CD_MASK_BMESH, CD_CALLOC, 0); - CustomData_from_bmeshpoly(&em->fdata, &bm->pdata, &bm->ldata); + CustomData_from_bmeshpoly(&em->fdata, &bm->pdata, &bm->ldata,0); numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY); numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL); @@ -357,7 +453,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm) MVert *mvert, *mv; MEdge *medge, *me; MFace *mface, *mf; - int totface,totedge,totvert,i,len; + int totface,totedge,totvert,i,len, numTex, numCol; BME_Vert *v1=NULL,*v2=NULL, **vert_array; BME_Edge *e=NULL; BME_Poly *f=NULL; @@ -365,6 +461,22 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm) EdgeHash *edge_hash = BLI_edgehash_new(); bm = BME_make_mesh(allocsize); + /*copy custom data layout*/ + CustomData_copy(&dm->vertData, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0); + CustomData_copy(&dm->edgeData, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0); + CustomData_copy(&dm->faceData, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0); + + /*copy face corner data*/ + CustomData_to_bmeshpoly(&dm->faceData, &bm->pdata, &bm->ldata); + /*initialize memory pools*/ + CustomData_bmesh_init_pool(&bm->vdata, allocsize[0]); + CustomData_bmesh_init_pool(&bm->edata, allocsize[1]); + CustomData_bmesh_init_pool(&bm->ldata, allocsize[2]); + CustomData_bmesh_init_pool(&bm->pdata, allocsize[3]); + /*needed later*/ + numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY); + numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL); + totvert = dm->getNumVerts(dm); totedge = dm->getNumEdges(dm); totface = dm->getNumFaces(dm); @@ -381,6 +493,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm) vert_array[i] = v1; v1->flag = mv->flag; v1->bweight = mv->bweight/255.0f; + CustomData_to_bmesh_block(&dm->vertData, &bm->vdata, i, &v1->data); } /*add edges*/ for(i=0,me = medge; i < totedge;i++,me++){ @@ -391,6 +504,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm) e->bweight = me->bweight/255.0f; e->flag = (unsigned char)me->flag; BLI_edgehash_insert(edge_hash,me->v1,me->v2,e); + CustomData_to_bmesh_block(&dm->edgeData, &bm->edata, i, &e->data); } /*add faces.*/ for(i=0,mf = mface; i < totface;i++,mf++){ @@ -414,6 +528,8 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm) f = BME_MF(bm,v1,v2,edar,len); f->mat_nr = mf->mat_nr; f->flag = mf->flag; + CustomData_to_bmesh_block(&dm->faceData,&bm->pdata,i,&f->data); + BME_DMcorners_to_loops(bm, &dm->faceData,i,f, numCol,numTex); } BME_model_end(bm); @@ -427,7 +543,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) MFace *mface, *mf; MEdge *medge, *me; MVert *mvert, *mv; - int totface,totedge,totvert,i,bmeshok,len; + int totface,totedge,totvert,i,bmeshok,len, numTex, numCol; BME_Vert *v1=NULL; BME_Edge *e=NULL, *oe=NULL; @@ -463,12 +579,21 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) /*convert back to mesh*/ result = CDDM_from_template(dm,totvert,totedge,totface); + CustomData_merge(&bm->vdata, &result->vertData, CD_MASK_BMESH, CD_CALLOC, totvert); + CustomData_merge(&bm->edata, &result->edgeData, CD_MASK_BMESH, CD_CALLOC, totedge); + CustomData_merge(&bm->pdata, &result->faceData, CD_MASK_BMESH, CD_CALLOC, totface); + CustomData_from_bmeshpoly(&result->faceData, &bm->pdata, &bm->ldata,totface); + numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY); + numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL); + + /*Make Verts*/ mvert = CDDM_get_verts(result); for(i=0,v1=bm->verts.first,mv=mvert;v1;v1=v1->next,i++,mv++){ VECCOPY(mv->co,v1->co); mv->flag = (unsigned char)v1->flag; mv->bweight = (char)(255.0*v1->bweight); + CustomData_from_bmesh_block(&bm->vdata, &result->vertData, &v1->data, i); } medge = CDDM_get_edges(result); i=0; @@ -486,6 +611,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) me->crease = (char)(255.0*e->crease); me->bweight = (char)(255.0*e->bweight); me->flag = e->flag; + CustomData_from_bmesh_block(&bm->edata, &result->edgeData, &e->data, i); me++; i++; } @@ -507,9 +633,11 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) if(mf->v3 == 0 || (len == 4 && mf->v4 == 0)){ test_index_face(mf, NULL, i, len); } - i++; mf->mat_nr = (unsigned char)f->mat_nr; mf->flag = (unsigned char)f->flag; + CustomData_from_bmesh_block(&bm->pdata, &result->faceData, &f->data, i); + BME_DMloops_to_corners(bm, &result->faceData, i, f,numCol,numTex); + i++; } } } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index ab573b7edd6..9012adb09b7 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1535,7 +1535,7 @@ void CustomData_from_em_block(const CustomData *source, CustomData *dest, } /*Bmesh functions*/ - +/*needed to convert to/from different face reps*/ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata) { int i; @@ -1548,15 +1548,15 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l CustomData_add_layer(ldata, CD_MLOOPCOL, CD_CALLOC, &(fdata->layers[i].name), 0); } } -void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata){ +void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total){ int i; for(i=0; i < pdata->totlayer; i++){ if(pdata->layers[i].type == CD_MTEXPOLY) - CustomData_add_layer(fdata, CD_MTFACE, CD_CALLOC, &(pdata->layers[i].name), 0); + CustomData_add_layer(fdata, CD_MTFACE, CD_CALLOC, &(pdata->layers[i].name), total); } for(i=0; i < ldata->totlayer; i++){ if(ldata->layers[i].type == CD_MLOOPCOL) - CustomData_add_layer(fdata, CD_MCOL, CD_CALLOC, &(ldata->layers[i].name), 0); + CustomData_add_layer(fdata, CD_MCOL, CD_CALLOC, &(ldata->layers[i].name), total); } } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index a0841bb9f03..f13f8ef0298 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -4920,7 +4920,7 @@ static void waveModifier_deformVertsEM( if(!wmd->texture && !wmd->defgrp_name[0] && !(wmd->flag & MOD_WAVE_NORM)) dm = derivedData; - else if(derivedData) dm = derivedData; + else if(derivedData) dm = CDDM_copy(derivedData); else dm = CDDM_from_editmesh(editData, ob->data); if(wmd->flag & MOD_WAVE_NORM) { diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 0a05047ac85..cac8275b689 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -80,7 +80,7 @@ struct GPUGlobal { } limits; int minimumsupport; -} GG = {1, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0}, 0}; +} GG = {1, 0, 0, {0, 0, 0, 0, 0, 0, 0}, 0}; void GPU_extensions_init() { diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 7dee9891ce5..fe352610a40 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -865,8 +865,7 @@ static const char *exr_rgba_channelname(InputFile *file, const char *chan) const char *str= i.name(); int len= strlen(str); if(len) { - if(strcasecmp(chan, str+len-1)==0) { - printf("name %s\n", str); + if(BLI_strcasecmp(chan, str+len-1)==0) { return str; } } diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c index e5ef1e9a4a2..68b5fa81f43 100644 --- a/source/blender/radiosity/intern/source/radrender.c +++ b/source/blender/radiosity/intern/source/radrender.c @@ -369,9 +369,18 @@ printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch); if(vlr->mat->mode & MA_RADIO) { /* during render, vlr->n gets flipped/corrected, we cannot have that */ - if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm); - else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm); - + if (obr->ob->transflag & OB_NEG_SCALE){ + /* The object has negative scale that will cause the normals to flip. + To counter this unwanted normal flip, swap vertex 2 and 4 for a quad + or vertex 2 and 3 (see flip_face) for a triangle in the call to CalcNormFloat4 + in order to flip the normals back to the way they were in the original mesh. */ + if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v4->co, vlr->v3->co, vlr->v2->co, rf->norm); + else CalcNormFloat(vlr->v1->co, vlr->v3->co, vlr->v2->co, rf->norm); + }else{ + if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm); + else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm); + } + rf->totrad[0]= vlr->mat->emit*vlr->mat->r; rf->totrad[1]= vlr->mat->emit*vlr->mat->g; rf->totrad[2]= vlr->mat->emit*vlr->mat->b; diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c index d758f34949a..dbc0deecb2c 100644 --- a/source/blender/src/editnla.c +++ b/source/blender/src/editnla.c @@ -501,26 +501,47 @@ static void set_active_strip(Object *ob, bActionStrip *act) { bActionStrip *strip; + /* make sure all other strips are not active */ for (strip = ob->nlastrips.first; strip; strip=strip->next) strip->flag &= ~ACTSTRIP_ACTIVE; - if(act) { + /* act is new active strip */ + if (act) { + /* set active flag for this strip */ act->flag |= ACTSTRIP_ACTIVE; - - if(ob->action!=act->act) { - if(ob->action) ob->action->id.us--; - if(act->act->id.lib) { + + /* check if active action will still be the same one */ + if (ob->action != act->act) { + /* clear object's links with its current action (if present) */ + if (ob->action) { + ob->action->id.us--; + } + + /* only set object's action to active strip's action if possible */ + if (act->act->id.lib) { ob->action= NULL; } else { ob->action= act->act; id_us_plus(&ob->action->id); - } + } + + /* request redrawing in relevant spaces */ allqueue(REDRAWIPO, 0); allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWACTION, 0); allqueue(REDRAWNLA, 0); - ob->ctime= -1234567.0f; // eveil! + + /* when only showing action (i.e. nla-override off), + * reset pose to restpose for armatures + */ + if ((ob->nlaflag & OB_NLA_OVERRIDE)==0) { + if (ob->type == OB_ARMATURE) + rest_pose(ob->pose); + } + + /* flush depsgraph */ + ob->ctime= -1234567.0f; // evil! DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA); } } diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index 72fbf16676f..a9cdd95a699 100644 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -3870,6 +3870,7 @@ void special_aftertrans_update(TransInfo *t) Base *base; short redrawipo=0, resetslowpar=1; int cancelled= (t->state == TRANS_CANCEL); + short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0; if (t->spacetype==SPACE_VIEW3D) { if (G.obedit) { @@ -3886,7 +3887,7 @@ void special_aftertrans_update(TransInfo *t) } } } - if (t->spacetype == SPACE_ACTION) { + else if (t->spacetype == SPACE_ACTION) { void *data; short datatype; @@ -3908,7 +3909,7 @@ void special_aftertrans_update(TransInfo *t) /* Do curve cleanups? */ if ( (G.saction->flag & SACTION_NOTRANSKEYCULL)==0 && - (cancelled == 0) ) + ((cancelled == 0) || (duplicate)) ) { posttrans_action_clean((bAction *)data); } @@ -3923,7 +3924,7 @@ void special_aftertrans_update(TransInfo *t) IpoCurve *icu; if ( (G.saction->flag & SACTION_NOTRANSKEYCULL)==0 && - (cancelled == 0) ) + ((cancelled == 0) || (duplicate)) ) { posttrans_ipo_clean(key->ipo); } @@ -3949,7 +3950,7 @@ void special_aftertrans_update(TransInfo *t) /* after transform, remove duplicate keyframes on a frame that resulted from transform */ if ( (G.snla->flag & SNLA_NOTRANSKEYCULL)==0 && - (cancelled == 0) ) + ((cancelled == 0) || (duplicate)) ) { posttrans_nla_clean(t); } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 385dc25f6a2..2ac4f909077 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1608,14 +1608,18 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, other = static_cast<KX_GameObject*>(pyfrom); fromPoint = other->NodeGetWorldPosition(); } - - if (dist != 0.0f) - { + + if (dist != 0.0f) { MT_Vector3 toDir = toPoint-fromPoint; + if (MT_fuzzyZero(toDir.length2())) { + return Py_BuildValue("OOO", Py_None, Py_None, Py_None); + } toDir.normalize(); toPoint = fromPoint + (dist) * toDir; + } else if (MT_fuzzyZero((toPoint-fromPoint).length2())) { + return Py_BuildValue("OOO", Py_None, Py_None, Py_None); } - + MT_Point3 resultPoint; MT_Vector3 resultNormal; PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 68798d6133f..20187a193ba 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -74,8 +74,6 @@ #include "RAS_FramingManager.h" #include "stdio.h" -#include "GPU_material.h" - // If define: little test for Nzc: guarded drawing. If the canvas is // not valid, skip rendering this frame. //#define NZC_GUARDED_OUTPUT |