forked from bartvdbraak/blender
Fixed bug #5235, "deleting edges, verts, or faces in multires does bizarre things to mesh"
Added a simple check to a number of editing operations. If multires is enabled, an error is displayed and the operation is cancelled. This includes adding and deleting verts/edges/faces, and anything that would reorder elements.
This commit is contained in:
parent
a84f60a3bd
commit
c25c249eb0
@ -94,6 +94,8 @@ extern EditVert *findnearestvert(int *dist, short sel);
|
||||
|
||||
/* ******************* editmesh_tools.c */
|
||||
|
||||
/* multires.c */
|
||||
int multires_test();
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -70,6 +70,7 @@
|
||||
#include "BIF_graphics.h"
|
||||
#include "BIF_interface.h"
|
||||
#include "BIF_mywindow.h"
|
||||
#include "BIF_retopo.h"
|
||||
#include "BIF_screen.h"
|
||||
#include "BIF_space.h"
|
||||
#include "BIF_toolbox.h"
|
||||
@ -649,6 +650,7 @@ void addedgeface_mesh(void)
|
||||
short amount=0;
|
||||
|
||||
if( (G.vd->lay & G.obedit->lay)==0 ) return;
|
||||
if(multires_test()) return;
|
||||
|
||||
/* how many selected ? */
|
||||
if(G.scene->selectmode & SCE_SELECT_EDGE) {
|
||||
|
@ -155,6 +155,8 @@ void convert_to_triface(int direction)
|
||||
EditFace *efa, *efan, *next;
|
||||
float fac;
|
||||
|
||||
if(multires_test()) return;
|
||||
|
||||
efa= em->faces.last;
|
||||
while(efa) {
|
||||
next= efa->prev;
|
||||
@ -204,6 +206,8 @@ int removedoublesflag(short flag, float limit) /* return amount */
|
||||
struct facesort *vlsortblock, *vsb, *vsb1;
|
||||
float dist;
|
||||
int a, b, test, amount;
|
||||
|
||||
if(multires_test()) return 0;
|
||||
|
||||
/* flag 128 is cleared, count */
|
||||
eve= em->verts.first;
|
||||
@ -477,6 +481,8 @@ void xsortvert_flag(int flag)
|
||||
ListBase tbase;
|
||||
int i, amount = BLI_countlist(&em->verts);
|
||||
|
||||
if(multires_test()) return;
|
||||
|
||||
sortblock = MEM_callocN(sizeof(xvertsort)*amount,"xsort");
|
||||
for (i=0,eve=em->verts.first; eve; i++,eve=eve->next)
|
||||
if(eve->f & flag)
|
||||
@ -518,6 +524,8 @@ void hashvert_flag(int flag)
|
||||
ListBase tbase;
|
||||
int amount, a, b;
|
||||
|
||||
if(multires_test()) return;
|
||||
|
||||
/* count */
|
||||
eve= em->verts.first;
|
||||
amount= 0;
|
||||
@ -579,6 +587,7 @@ void extrude_mesh(void)
|
||||
short nr, transmode= 0;
|
||||
|
||||
TEST_EDITMESH
|
||||
if(multires_test()) return;
|
||||
|
||||
if(G.scene->selectmode & SCE_SELECT_VERTEX) {
|
||||
if(G.totvertsel==0) nr= 0;
|
||||
@ -653,6 +662,7 @@ void split_mesh(void)
|
||||
{
|
||||
|
||||
TEST_EDITMESH
|
||||
if(multires_test()) return;
|
||||
|
||||
if(okee(" Split ")==0) return;
|
||||
|
||||
@ -685,6 +695,7 @@ void extrude_repeat_mesh(int steps, float offs)
|
||||
short a;
|
||||
|
||||
TEST_EDITMESH
|
||||
if(multires_test()) return;
|
||||
|
||||
/* dvec */
|
||||
dvec[0]= G.vd->persinv[2][0];
|
||||
@ -727,6 +738,7 @@ void spin_mesh(int steps, float degr, float *dvec, int mode)
|
||||
short a,ok;
|
||||
|
||||
TEST_EDITMESH
|
||||
if(multires_test()) return;
|
||||
|
||||
/* imat and centre and size */
|
||||
Mat3CpyMat4(bmat, G.obedit->obmat);
|
||||
@ -810,6 +822,7 @@ void screw_mesh(int steps, int turns)
|
||||
float dvec[3], nor[3],deg=(-360);
|
||||
|
||||
TEST_EDITMESH
|
||||
if(multires_test()) return;
|
||||
|
||||
/* first condition: we need frontview! */
|
||||
if(G.vd->view!=1) {
|
||||
@ -930,6 +943,7 @@ void delete_mesh(void)
|
||||
char *str="Erase";
|
||||
|
||||
TEST_EDITMESH
|
||||
if(multires_test()) return;
|
||||
|
||||
event= pupmenu("Erase %t|Vertices%x10|Edges%x1|Faces%x2|All%x3|Edges & Faces%x4|Only Faces%x5|Edge Loop%x6");
|
||||
if(event<1) return;
|
||||
@ -1076,6 +1090,7 @@ void fill_mesh(void)
|
||||
short ok;
|
||||
|
||||
if(G.obedit==0 || (G.obedit->type!=OB_MESH)) return;
|
||||
if(multires_test()) return;
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
@ -2394,6 +2409,8 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
|
||||
float length[4], v1mat[3], v2mat[3], v3mat[3], v4mat[3];
|
||||
int i, j, edgecount, touchcount, facetype,hold;
|
||||
|
||||
if(multires_test()) return;
|
||||
|
||||
//Set faces f1 to 0 cause we need it later
|
||||
for(ef=em->faces.first;ef;ef = ef->next) {
|
||||
ef->f1 = 0;
|
||||
@ -2899,6 +2916,8 @@ void beauty_fill(void)
|
||||
EVPtr *efaa;
|
||||
float len1, len2, len3, len4, len5, len6, opp1, opp2, fac1, fac2;
|
||||
int totedge, ok, notbeauty=8, onedone, vindex[4];
|
||||
|
||||
if(multires_test()) return;
|
||||
|
||||
/* - all selected edges with two faces
|
||||
* - find the faces: store them in edges (using datablock)
|
||||
@ -3342,6 +3361,8 @@ void join_triangles(void)
|
||||
int i, paircount, joincount, totFacePairLs, respectvcol = 1, respectuv = 1, match, matchar[3];
|
||||
FacePairL *fpl1;
|
||||
|
||||
if(multires_test()) return;
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
for(efa=em->faces.first; efa; efa=efa->next){
|
||||
@ -4174,6 +4195,8 @@ static void bevel_mesh(float bsize, int allfaces)
|
||||
float cent[3], min[3], max[3];
|
||||
int a, b, c;
|
||||
float limit= 0.001f;
|
||||
|
||||
if(multires_test()) return;
|
||||
|
||||
waitcursor(1);
|
||||
|
||||
@ -6158,6 +6181,8 @@ int collapseEdges(void)
|
||||
|
||||
mergecount = 0;
|
||||
|
||||
if(multires_test()) return 0;
|
||||
|
||||
build_edgecollection(&allcollections);
|
||||
groupcount = BLI_countlist(&allcollections);
|
||||
|
||||
@ -6214,6 +6239,9 @@ int merge_firstlast(int first, int uvmerge)
|
||||
{
|
||||
EditVert *eve,*mergevert;
|
||||
EditSelection *ese;
|
||||
|
||||
if(multires_test()) return 0;
|
||||
|
||||
/* do sanity check in mergemenu in edit.c ?*/
|
||||
if(first == 0){
|
||||
ese = G.editMesh->selected.last;
|
||||
@ -6249,6 +6277,8 @@ int merge_target(int target, int uvmerge)
|
||||
{
|
||||
EditVert *eve;
|
||||
|
||||
if(multires_test()) return 0;
|
||||
|
||||
if(target) snap_sel_to_curs();
|
||||
else snap_to_center();
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
#include "BKE_depsgraph.h"
|
||||
@ -48,15 +49,20 @@
|
||||
|
||||
#include "BIF_screen.h"
|
||||
#include "BIF_space.h"
|
||||
#include "BIF_toolbox.h"
|
||||
|
||||
#include "BDR_editobject.h"
|
||||
#include "BDR_sculptmode.h"
|
||||
|
||||
#include "BLI_editVert.h"
|
||||
|
||||
#include "BSE_edit.h"
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "blendef.h"
|
||||
#include "editmesh.h"
|
||||
#include "multires.h"
|
||||
#include "mydevice.h"
|
||||
#include "parametrizer.h"
|
||||
@ -64,6 +70,19 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
/* editmesh.h */
|
||||
int multires_test()
|
||||
{
|
||||
Mesh *me= get_mesh(
|
||||
OBACT);
|
||||
if(me && me->mr) {
|
||||
error("Unable to complete action with multires enabled.");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Vec3fAvg3(float *out, float *v1, float *v2, float *v3)
|
||||
{
|
||||
out[0]= (v1[0]+v2[0]+v3[0])/3;
|
||||
|
Loading…
Reference in New Issue
Block a user