forked from bartvdbraak/blender
animation_trajectory - was printing deprecation warnings. cleaned up some of its code too.
Mesh - removing UV or Color layers didnt check if the active object was in vpaint of uv mode, removing the last layer could crash blender - now switch to object mode if its the last layer like the UI.
This commit is contained in:
parent
00cdff156f
commit
b3e6a6a9c1
@ -2,7 +2,7 @@
|
||||
|
||||
""" Registration info for Blender menus: <- these words are ignored
|
||||
Name: 'Trajectory'
|
||||
Blender: 242
|
||||
Blender: 243
|
||||
Group: 'Animation'
|
||||
Tip: 'See Trajectory of selected object'
|
||||
"""
|
||||
@ -91,7 +91,8 @@ def write_script(name, script):
|
||||
scripting= None
|
||||
for text in Blender.Text.Get():
|
||||
if text.name==name and text.asLines()[1] != "#"+str(__version__):
|
||||
scripting= Blender.Text.Get(name)
|
||||
scripting = text
|
||||
scripting.clear()
|
||||
scripting.write(script)
|
||||
break
|
||||
|
||||
@ -99,13 +100,10 @@ def write_script(name, script):
|
||||
scripting= Blender.Text.New(name)
|
||||
scripting.write(script)
|
||||
|
||||
|
||||
#Linking
|
||||
def link_script(name, type):
|
||||
global scene
|
||||
try:
|
||||
scene.getScriptLinks(type).index(name) # Does nothing. just fails of the script isnt there.
|
||||
except:
|
||||
scriptlinks = scene.getScriptLinks(type) # none or list
|
||||
if not scriptlinks or name not in scriptlinks:
|
||||
scene.addScriptLink(name, type)
|
||||
|
||||
|
||||
@ -145,8 +143,8 @@ if ask_modif==0:
|
||||
width= Blender.Draw.Create(2)
|
||||
|
||||
block= []
|
||||
block.append(("Use Space Handlers", handle_mode, "You have to activate for each area by View>>SpaceHandler")) #You can delete this option...
|
||||
block.append(("Always draw for sel.", selection_mode, "Selected object will have their trajectory always shown"))
|
||||
block.append(("Space Handlers", handle_mode, "You have to activate for each area by View>>SpaceHandler")) #You can delete this option...
|
||||
block.append(("Always Draw", selection_mode, "Selected object will have their trajectory always shown"))
|
||||
block.append(("Past :", past, 1, 900))
|
||||
block.append(("Futur:", future, 1, 900))
|
||||
block.append(("Width:", width, 1,5))
|
||||
@ -163,7 +161,7 @@ if ask_modif==0:
|
||||
|
||||
#put names of selected objects in objects_select if option choosen by user
|
||||
if selection_mode==1:
|
||||
objects_select= [ob.name for ob in Blender.Object.GetSelected()]
|
||||
objects_select= [ob.name for ob in scene.objects.context]
|
||||
else:
|
||||
objects_select= []
|
||||
|
||||
@ -197,7 +195,8 @@ from Blender.Mathutils import Vector
|
||||
|
||||
#take actual frame
|
||||
frameC=Blender.Get('curframe')
|
||||
render_context=Blender.Scene.getCurrent().getRenderingContext()
|
||||
scene = Blender.Scene.GetCurrent()
|
||||
render_context=scene.getRenderingContext()
|
||||
#ajust number of frames with NewMap and OldMapvalue values
|
||||
k=1.00*render_context.oldMapValue()/render_context.newMapValue()
|
||||
if k<1:
|
||||
@ -212,11 +211,9 @@ frameC=int(round(frameC*k, 0))
|
||||
|
||||
#List objects that we have to show trajectory in $objects
|
||||
# In this case, using a dict for unique objects is the fastest way.
|
||||
object_dict= dict([(ob.name, ob) for ob in Blender.Object.GetSelected()])
|
||||
object_dict= dict([(ob.name, ob) for ob in scene.objects.context])
|
||||
for obname in object_init_names:
|
||||
try: # checking if its alredy there.
|
||||
object_dict[obname]
|
||||
except: # Object is not there.
|
||||
if not object_dict.has_key(obname):
|
||||
try: # Object may be removed.
|
||||
object_dict[obname]= Blender.Object.Get(obname)
|
||||
except:
|
||||
|
@ -3721,7 +3721,7 @@ static PyObject *MFace_getImage( BPy_MFace *self )
|
||||
if( face->tpage )
|
||||
return Image_CreatePyObject( face->tpage );
|
||||
else
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5201,7 +5201,7 @@ static PyObject *MFaceSeq_delete( BPy_MFaceSeq * self, PyObject *args )
|
||||
/* clean up and return */
|
||||
MEM_freeN( face_table );
|
||||
mesh_update ( mesh );
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *MFaceSeq_selected( BPy_MFaceSeq * self )
|
||||
@ -5359,7 +5359,7 @@ static PyObject *Mesh_calcNormals( BPy_Mesh * self )
|
||||
|
||||
mesh_calc_normals( mesh->mvert, mesh->totvert, mesh->mface,
|
||||
mesh->totface, NULL );
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *Mesh_vertexShade( BPy_Mesh * self )
|
||||
@ -5377,7 +5377,7 @@ static PyObject *Mesh_vertexShade( BPy_Mesh * self )
|
||||
set_active_base( base );
|
||||
make_vertexcol(1);
|
||||
countall();
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
base = base->next;
|
||||
}
|
||||
@ -5392,7 +5392,7 @@ static PyObject *Mesh_vertexShade( BPy_Mesh * self )
|
||||
static PyObject *Mesh_Update( BPy_Mesh * self )
|
||||
{
|
||||
mesh_update( self->mesh );
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5431,7 +5431,7 @@ static PyObject *Mesh_findEdge( BPy_Mesh * self, PyObject *args )
|
||||
}
|
||||
++edge;
|
||||
}
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5804,7 +5804,7 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args )
|
||||
test_object_materials( ( ID * ) self->mesh );
|
||||
|
||||
mesh_update( self->mesh );
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5870,7 +5870,7 @@ static PyObject *Mesh_transform( BPy_Mesh *self, PyObject *args )
|
||||
}
|
||||
}
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * args )
|
||||
@ -5897,7 +5897,7 @@ static PyObject *Mesh_addVertGroup( PyObject * self, PyObject * args )
|
||||
|
||||
EXPP_allqueue( REDRAWBUTSALL, 1 );
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *Mesh_removeVertGroup( PyObject * self, PyObject * args )
|
||||
@ -5933,7 +5933,7 @@ static PyObject *Mesh_removeVertGroup( PyObject * self, PyObject * args )
|
||||
|
||||
EXPP_allqueue( REDRAWBUTSALL, 1 );
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
extern void add_vert_defnr( Object * ob, int def_nr, int vertnum, float weight,
|
||||
@ -6000,7 +6000,7 @@ static PyObject *Mesh_assignVertsToGroup( BPy_Mesh * self, PyObject * args )
|
||||
add_vert_defnr( object, nIndex, tempInt, weight, assignmode );
|
||||
}
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *Mesh_removeVertsFromGroup( BPy_Mesh * self, PyObject * args )
|
||||
@ -6069,7 +6069,7 @@ static PyObject *Mesh_removeVertsFromGroup( BPy_Mesh * self, PyObject * args )
|
||||
remove_vert_def_nr( object, nIndex, tempInt );
|
||||
}
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *Mesh_getVertsFromGroup( BPy_Mesh* self, PyObject * args )
|
||||
@ -6215,7 +6215,7 @@ static PyObject *Mesh_renameVertGroup( BPy_Mesh * self, PyObject * args )
|
||||
PyOS_snprintf( defGroup->name, 32, newGr );
|
||||
unique_vertexgroup_name( defGroup, object );
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@ -6410,6 +6410,18 @@ static PyObject *Mesh_removeLayer_internal( BPy_Mesh * self, PyObject * args, in
|
||||
|
||||
CustomData_free_layer(data, type, me->totface, i);
|
||||
mesh_update_customdata_pointers(me);
|
||||
|
||||
/* No more Color or UV layers left ?
|
||||
switch modes if this is the active object */
|
||||
if (!CustomData_has_layer(data, type)) {
|
||||
if (me == get_mesh(OBACT)) {
|
||||
if(type == CD_MCOL && (G.f & G_VERTEXPAINT))
|
||||
G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */
|
||||
if(type == CD_MTFACE && (G.f & G_FACESELECT))
|
||||
set_faceselect(); /* get out of faceselect mode */
|
||||
}
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@ -6452,7 +6464,7 @@ static PyObject *Mesh_renameLayer_internal( BPy_Mesh * self, PyObject * args, in
|
||||
layer = &data->layers[i];
|
||||
strcpy(layer->name, name_to); /* we alredy know the string sizes are under 32 */
|
||||
CustomData_set_layer_unique_name(data, i);
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *Mesh_renameUVLayer( BPy_Mesh * self, PyObject * args )
|
||||
@ -6706,7 +6718,7 @@ static PyObject *Mesh_Tools( BPy_Mesh * self, int type, void **args )
|
||||
if( attr )
|
||||
return attr;
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -7365,7 +7377,7 @@ static PyObject *Mesh_getActiveFace( BPy_Mesh * self )
|
||||
"PyInt_FromLong() failed" );
|
||||
}
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int Mesh_setActiveFace( BPy_Mesh * self, PyObject * value )
|
||||
|
Loading…
Reference in New Issue
Block a user