[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24046] trunk/blender/source/blender: Two fixes:
Joshua Leung
aligorith at gmail.com
Thu Oct 22 05:12:47 CEST 2009
Revision: 24046
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24046
Author: aligorith
Date: 2009-10-22 05:12:44 +0200 (Thu, 22 Oct 2009)
Log Message:
-----------
Two fixes:
* RNA Path fixing when renaming data now checks if a path in question cannot be resolved before trying to fix it. This should reduce the number of misindentified cases I hope.
* Silenced compiler warnings for EdgeSlide stuff that mingw was making about unused variables.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/anim_sys.c
trunk/blender/source/blender/editors/transform/transform.c
Modified: trunk/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim_sys.c 2009-10-22 02:14:11 UTC (rev 24045)
+++ trunk/blender/source/blender/blenkernel/intern/anim_sys.c 2009-10-22 03:12:44 UTC (rev 24046)
@@ -238,6 +238,19 @@
/* Path Validation -------------------------------------------- */
+/* Check if a given RNA Path is valid, by tracing it from the given ID, and seeing if we can resolve it */
+static short check_rna_path_is_valid (ID *owner_id, char *path)
+{
+ PointerRNA id_ptr, ptr;
+ PropertyRNA *prop=NULL;
+
+ /* make initial RNA pointer to start resolving from */
+ RNA_id_pointer_create(owner_id, &id_ptr);
+
+ /* try to resolve */
+ return RNA_path_resolve(&id_ptr, path, &ptr, &prop);
+}
+
/* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate
* NOTE: we assume that oldName and newName have [" "] padding around them
*/
@@ -249,39 +262,49 @@
int oldNameLen= strlen(oldName);
/* only start fixing the path if the prefix and oldName feature in the path,
- * and prefix occurs immediately before oldName (the +2 should take care of any [")
+ * and prefix occurs immediately before oldName
*/
if ( (prefixPtr && oldNamePtr) && (prefixPtr+prefixLen == oldNamePtr) ) {
- DynStr *ds= BLI_dynstr_new();
- char *postfixPtr= oldNamePtr+oldNameLen;
- char *newPath = NULL;
- char oldChar;
-
- /* add the part of the string that goes up to the start of the prefix */
- if (prefixPtr > oldpath) {
- oldChar= prefixPtr[0];
- prefixPtr[0]= 0;
- BLI_dynstr_append(ds, oldpath);
- prefixPtr[0]= oldChar;
+ /* if we haven't aren't able to resolve the path now, try again after fixing it */
+ if (check_rna_path_is_valid(owner_id, oldpath) == 0) {
+ DynStr *ds= BLI_dynstr_new();
+ char *postfixPtr= oldNamePtr+oldNameLen;
+ char *newPath = NULL;
+ char oldChar;
+
+ /* add the part of the string that goes up to the start of the prefix */
+ if (prefixPtr > oldpath) {
+ oldChar= prefixPtr[0];
+ prefixPtr[0]= 0;
+ BLI_dynstr_append(ds, oldpath);
+ prefixPtr[0]= oldChar;
+ }
+
+ /* add the prefix */
+ BLI_dynstr_append(ds, prefix);
+
+ /* add the new name (complete with brackets) */
+ BLI_dynstr_append(ds, newName);
+
+ /* add the postfix */
+ BLI_dynstr_append(ds, postfixPtr);
+
+ /* create new path, and cleanup old data */
+ newPath= BLI_dynstr_get_cstring(ds);
+ BLI_dynstr_free(ds);
+
+ /* check if the new path will solve our problems */
+ // TODO: will need to check whether this step really helps in practice
+ if (check_rna_path_is_valid(owner_id, newPath)) {
+ /* free the old path, and return the new one, since we've solved the issues */
+ MEM_freeN(oldpath);
+ return newPath;
+ }
+ else {
+ /* still couldn't resolve the path... so, might as well just leave it alone */
+ MEM_freeN(newPath);
+ }
}
-
- /* add the prefix */
- BLI_dynstr_append(ds, prefix);
-
- /* add the new name (complete with brackets) */
- BLI_dynstr_append(ds, newName);
-
- /* add the postfix */
- BLI_dynstr_append(ds, postfixPtr);
-
- /* create new path, and cleanup old data */
- newPath= BLI_dynstr_get_cstring(ds);
- BLI_dynstr_free(ds);
-
- MEM_freeN(oldpath);
-
- /* return the new path */
- return newPath;
}
/* the old path doesn't need to be changed */
Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c 2009-10-22 02:14:11 UTC (rev 24045)
+++ trunk/blender/source/blender/editors/transform/transform.c 2009-10-22 03:12:44 UTC (rev 24046)
@@ -3942,10 +3942,8 @@
LinkNode *edgelist = NULL, *vertlist=NULL, *look;
GHash *vertgh;
TransDataSlideVert *tempsv;
- float perc = 0, percp = 0,vertdist; // XXX, projectMat[4][4];
- float shiftlabda= 0.0f,len = 0.0f;
- int i, j, numsel, numadded=0, timesthrough = 0, vertsel=0, prop=1, cancel = 0,flip=0;
- int wasshift = 0;
+ float vertdist; // XXX, projectMat[4][4];
+ int i, j, numsel, numadded=0, timesthrough = 0, vertsel=0;
/* UV correction vars */
GHash **uvarray= NULL;
SlideData *sld = MEM_callocN(sizeof(*sld), "sld");
@@ -3956,8 +3954,7 @@
float projectMat[4][4];
float start[3] = {0.0f, 0.0f, 0.0f}, end[3] = {0.0f, 0.0f, 0.0f};
float vec[3];
- //short mval[2], mvalo[2];
- float labda = 0.0f, totvec=0.0;
+ float totvec=0.0;
if (!v3d) {
/*ok, let's try to survive this*/
@@ -3965,8 +3962,7 @@
} else {
view3d_get_object_project_mat(v3d, t->obedit, projectMat);
}
-
- //mvalo[0] = -1; mvalo[1] = -1;
+
numsel =0;
// Get number of selected edges and clear some flags
@@ -4468,23 +4464,20 @@
Mesh *me= t->obedit->data;
EditMesh *em = me->edit_mesh;
SlideData *sld = t->customData;
- EditEdge *first=NULL,*last=NULL, *temp = NULL;
EditVert *ev, *nearest = sld->nearest;
EditVert *centerVert, *upVert, *downVert;
- LinkNode *edgelist = sld->edgelist, *vertlist=sld->vertlist, *look;
+ LinkNode *vertlist=sld->vertlist, *look;
GHash *vertgh = sld->vhash;
TransDataSlideVert *tempsv;
- float shiftlabda= 0.0f,len = 0.0f;
- int i = 0, numadded=0, timesthrough = 0, vertsel=0, prop=1, cancel = 0,flip=0;
- int wasshift = 0;
+ float len = 0.0f;
+ int prop=1, flip=0;
/* UV correction vars */
GHash **uvarray= sld->uvhash;
int uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
int uvlay_idx;
- TransDataSlideUv *slideuvs=sld->slideuv, *suv=sld->slideuv, *suv_last=NULL;
+ TransDataSlideUv *suv=sld->slideuv;
float uv_tmp[2];
LinkNode *fuv_link;
- float labda = 0.0f;
len = 0.0f;
@@ -4579,7 +4572,6 @@
int EdgeSlide(TransInfo *t, short mval[2])
{
- TransData *td = t->data;
char str[50];
float final;
More information about the Bf-blender-cvs
mailing list