merge more etch-a-ton code. nothing works, but it compiles. Will try to get it working this week end.
This commit is contained in:
45
source/blender/editors/armature/BIF_generate.h
Normal file
45
source/blender/editors/armature/BIF_generate.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* $Id: $
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef BIF_GENERATE_H
|
||||
#define BIF_GENERATE_H
|
||||
|
||||
struct bContext;
|
||||
struct EditBone;
|
||||
struct BArcIterator;
|
||||
struct bArmature;
|
||||
struct ListBase;
|
||||
|
||||
typedef int(NextSubdivisionFunc)(struct bContext*, struct BArcIterator*, int, int, float[3], float[3]);
|
||||
|
||||
float calcArcCorrelation(struct BArcIterator *iter, int start, int end, float v0[3], float n[3]);
|
||||
|
||||
int nextFixedSubdivision(struct bContext *C, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
|
||||
int nextLengthSubdivision(struct bContext *C, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
|
||||
int nextAdaptativeSubdivision(struct bContext *C, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
|
||||
|
||||
struct EditBone * subdivideArcBy(struct bContext *C, struct bArmature *arm, ListBase *editbones, struct BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion);
|
||||
|
||||
void setBoneRollFromNormal(struct EditBone *bone, float *no, float invmat[][4], float tmat[][3]);
|
||||
|
||||
|
||||
#endif /* BIF_GENERATE_H */
|
||||
160
source/blender/editors/armature/BIF_retarget.h
Normal file
160
source/blender/editors/armature/BIF_retarget.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* $Id: $
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef BIF_RETARGET_H
|
||||
#define BIF_RETARGET_H
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include "BLI_graph.h"
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "reeb.h"
|
||||
|
||||
struct Object;
|
||||
struct bArmature;
|
||||
struct bContext;
|
||||
|
||||
struct EditBone;
|
||||
|
||||
struct RigJoint;
|
||||
struct RigGraph;
|
||||
struct RigNode;
|
||||
struct RigArc;
|
||||
struct RigEdge;
|
||||
|
||||
#define USE_THREADS
|
||||
|
||||
typedef struct RigGraph {
|
||||
ListBase arcs;
|
||||
ListBase nodes;
|
||||
|
||||
float length;
|
||||
|
||||
FreeArc free_arc;
|
||||
FreeNode free_node;
|
||||
RadialSymmetry radial_symmetry;
|
||||
AxialSymmetry axial_symmetry;
|
||||
/*********************************/
|
||||
|
||||
int flag;
|
||||
|
||||
ListBase controls;
|
||||
ListBase* editbones;
|
||||
|
||||
struct RigNode *head;
|
||||
ReebGraph *link_mesh;
|
||||
|
||||
|
||||
struct ThreadedWorker *worker;
|
||||
|
||||
GHash *bones_map; /* map of editbones by name */
|
||||
GHash *controls_map; /* map of rigcontrols by bone pointer */
|
||||
|
||||
struct Object *ob;
|
||||
} RigGraph;
|
||||
|
||||
typedef struct RigNode {
|
||||
void *next, *prev;
|
||||
float p[3];
|
||||
int flag;
|
||||
|
||||
int degree;
|
||||
struct BArc **arcs;
|
||||
|
||||
int subgraph_index;
|
||||
|
||||
int symmetry_level;
|
||||
int symmetry_flag;
|
||||
float symmetry_axis[3];
|
||||
/*********************************/
|
||||
|
||||
ReebNode *link_mesh;
|
||||
} RigNode;
|
||||
|
||||
typedef struct RigArc {
|
||||
void *next, *prev;
|
||||
RigNode *head, *tail;
|
||||
int flag;
|
||||
|
||||
float length;
|
||||
|
||||
int symmetry_level;
|
||||
int symmetry_group;
|
||||
int symmetry_flag;
|
||||
/*********************************/
|
||||
|
||||
ListBase edges;
|
||||
int count;
|
||||
ReebArc *link_mesh;
|
||||
} RigArc;
|
||||
|
||||
typedef struct RigEdge {
|
||||
struct RigEdge *next, *prev;
|
||||
float head[3], tail[3];
|
||||
float length;
|
||||
float angle; /* angle to next edge */
|
||||
float up_angle; /* angle between up_axis and the joint normal (defined as Previous edge CrossProduct Current edge */
|
||||
struct EditBone *bone;
|
||||
float up_axis[3];
|
||||
} RigEdge;
|
||||
|
||||
/* Graph flags */
|
||||
#define RIG_FREE_BONELIST 1
|
||||
|
||||
/* Control flags */
|
||||
#define RIG_CTRL_HEAD_DONE 1
|
||||
#define RIG_CTRL_TAIL_DONE 2
|
||||
#define RIG_CTRL_PARENT_DEFORM 4
|
||||
#define RIG_CTRL_FIT_ROOT 8
|
||||
#define RIG_CTRL_FIT_BONE 16
|
||||
|
||||
#define RIG_CTRL_DONE (RIG_CTRL_HEAD_DONE|RIG_CTRL_TAIL_DONE)
|
||||
|
||||
/* Control tail flags */
|
||||
typedef enum {
|
||||
TL_NONE = 0,
|
||||
TL_TAIL,
|
||||
TL_HEAD
|
||||
} LinkTailMode;
|
||||
|
||||
typedef struct RigControl {
|
||||
struct RigControl *next, *prev;
|
||||
float head[3], tail[3];
|
||||
struct EditBone *bone;
|
||||
struct EditBone *link;
|
||||
struct EditBone *link_tail;
|
||||
float up_axis[3];
|
||||
float offset[3];
|
||||
float qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */
|
||||
int flag;
|
||||
LinkTailMode tail_mode;
|
||||
} RigControl;
|
||||
|
||||
void BIF_retargetArc(struct bContext *C, ReebArc *earc, RigGraph *template_rigg);
|
||||
RigGraph *RIG_graphFromArmature(struct bContext *C, struct Object *ob, struct bArmature *arm);
|
||||
int RIG_nbJoints(RigGraph *rg);
|
||||
char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index);
|
||||
void RIG_freeRigGraph(BGraph *rg);
|
||||
|
||||
#endif /* BIF_RETARGET_H */
|
||||
@@ -64,6 +64,9 @@ void POSE_OT_select_connected(struct wmOperatorType *ot);
|
||||
/* editarmature.c */
|
||||
struct bArmature;
|
||||
struct EditBone;
|
||||
struct ListBase;
|
||||
|
||||
void make_boneList(struct ListBase *edbo, struct ListBase *bones, struct EditBone *parent);
|
||||
|
||||
struct EditBone *addEditBone(struct bArmature *arm, char *name);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_transform.h"
|
||||
// XXX etch-a-ton #include "BIF_generate.h"
|
||||
#include "BIF_generate.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
@@ -1762,6 +1762,8 @@ void mouse_armature(bContext *C, short mval[2], int extend)
|
||||
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
BIF_sk_selectStroke(C, mval, extend);
|
||||
|
||||
nearBone= get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask);
|
||||
if (nearBone) {
|
||||
|
||||
@@ -1856,7 +1858,7 @@ void ED_armature_to_edit(Object *ob)
|
||||
arm->edbo= MEM_callocN(sizeof(ListBase), "edbo armature");
|
||||
make_boneList(arm->edbo, &arm->bonebase,NULL);
|
||||
|
||||
// XXX etch-a-ton BIF_freeTemplates(); /* force template update when entering editmode */
|
||||
// BIF_freeTemplates(); /* force template update when entering editmode */
|
||||
}
|
||||
|
||||
|
||||
|
||||
331
source/blender/editors/armature/editarmature_generate.c
Normal file
331
source/blender/editors/armature/editarmature_generate.c
Normal file
@@ -0,0 +1,331 @@
|
||||
/**
|
||||
* $Id: editarmature_generate.c $
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
* editarmature.c: Interface for creating and posing armature objects
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_armature_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_graph.h"
|
||||
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "ED_armature.h"
|
||||
#include "BIF_generate.h"
|
||||
|
||||
void setBoneRollFromNormal(EditBone *bone, float *no, float invmat[][4], float tmat[][3])
|
||||
{
|
||||
if (no != NULL && !VecIsNull(no))
|
||||
{
|
||||
float tangent[3], cotangent[3], normal[3];
|
||||
|
||||
VECCOPY(normal, no);
|
||||
Mat3MulVecfl(tmat, normal);
|
||||
|
||||
VecSubf(tangent, bone->tail, bone->head);
|
||||
Crossf(cotangent, tangent, normal);
|
||||
Crossf(normal, cotangent, tangent);
|
||||
|
||||
Normalize(normal);
|
||||
|
||||
bone->roll = ED_rollBoneToVector(bone, normal);
|
||||
}
|
||||
}
|
||||
|
||||
float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], float n[3])
|
||||
{
|
||||
int len = 2 + abs(end - start);
|
||||
|
||||
if (len > 2)
|
||||
{
|
||||
float avg_t = 0.0f;
|
||||
float s_t = 0.0f;
|
||||
float s_xyz = 0.0f;
|
||||
int i;
|
||||
|
||||
/* First pass, calculate average */
|
||||
for (i = start; i <= end; i++)
|
||||
{
|
||||
float v[3];
|
||||
|
||||
IT_peek(iter, i);
|
||||
VecSubf(v, iter->p, v0);
|
||||
avg_t += Inpf(v, n);
|
||||
}
|
||||
|
||||
avg_t /= Inpf(n, n);
|
||||
avg_t += 1.0f; /* adding start (0) and end (1) values */
|
||||
avg_t /= len;
|
||||
|
||||
/* Second pass, calculate s_xyz and s_t */
|
||||
for (i = start; i <= end; i++)
|
||||
{
|
||||
float v[3], d[3];
|
||||
float dt;
|
||||
|
||||
IT_peek(iter, i);
|
||||
VecSubf(v, iter->p, v0);
|
||||
Projf(d, v, n);
|
||||
VecSubf(v, v, d);
|
||||
|
||||
dt = VecLength(d) - avg_t;
|
||||
|
||||
s_t += dt * dt;
|
||||
s_xyz += Inpf(v, v);
|
||||
}
|
||||
|
||||
/* adding start(0) and end(1) values to s_t */
|
||||
s_t += (avg_t * avg_t) + (1 - avg_t) * (1 - avg_t);
|
||||
|
||||
return 1.0f - s_xyz / s_t;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
int nextFixedSubdivision(bContext *C, BArcIterator *iter, int start, int end, float head[3], float p[3])
|
||||
{
|
||||
static float stroke_length = 0;
|
||||
static float current_length;
|
||||
static char n;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
float *v1, *v2;
|
||||
float length_threshold;
|
||||
int i;
|
||||
|
||||
if (stroke_length == 0)
|
||||
{
|
||||
current_length = 0;
|
||||
|
||||
IT_peek(iter, start);
|
||||
v1 = iter->p;
|
||||
|
||||
for (i = start + 1; i <= end; i++)
|
||||
{
|
||||
IT_peek(iter, i);
|
||||
v2 = iter->p;
|
||||
|
||||
stroke_length += VecLenf(v1, v2);
|
||||
|
||||
v1 = v2;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
current_length = 0;
|
||||
}
|
||||
|
||||
n++;
|
||||
|
||||
length_threshold = n * stroke_length / scene->toolsettings->skgen_subdivision_number;
|
||||
|
||||
IT_peek(iter, start);
|
||||
v1 = iter->p;
|
||||
|
||||
/* < and not <= because we don't care about end, it is P_EXACT anyway */
|
||||
for (i = start + 1; i < end; i++)
|
||||
{
|
||||
IT_peek(iter, i);
|
||||
v2 = iter->p;
|
||||
|
||||
current_length += VecLenf(v1, v2);
|
||||
|
||||
if (current_length >= length_threshold)
|
||||
{
|
||||
VECCOPY(p, v2);
|
||||
return i;
|
||||
}
|
||||
|
||||
v1 = v2;
|
||||
}
|
||||
|
||||
stroke_length = 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
int nextAdaptativeSubdivision(bContext *C, BArcIterator *iter, int start, int end, float head[3], float p[3])
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
float correlation_threshold = scene->toolsettings->skgen_correlation_limit;
|
||||
float *start_p;
|
||||
float n[3];
|
||||
int i;
|
||||
|
||||
IT_peek(iter, start);
|
||||
start_p = iter->p;
|
||||
|
||||
for (i = start + 2; i <= end; i++)
|
||||
{
|
||||
/* Calculate normal */
|
||||
IT_peek(iter, i);
|
||||
VecSubf(n, iter->p, head);
|
||||
|
||||
if (calcArcCorrelation(iter, start, i, start_p, n) < correlation_threshold)
|
||||
{
|
||||
IT_peek(iter, i - 1);
|
||||
VECCOPY(p, iter->p);
|
||||
return i - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int nextLengthSubdivision(bContext *C, BArcIterator *iter, int start, int end, float head[3], float p[3])
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
float lengthLimit = scene->toolsettings->skgen_length_limit;
|
||||
int same = 1;
|
||||
int i;
|
||||
|
||||
i = start + 1;
|
||||
while (i <= end)
|
||||
{
|
||||
float *vec0;
|
||||
float *vec1;
|
||||
|
||||
IT_peek(iter, i - 1);
|
||||
vec0 = iter->p;
|
||||
|
||||
IT_peek(iter, i);
|
||||
vec1 = iter->p;
|
||||
|
||||
/* If lengthLimit hits the current segment */
|
||||
if (VecLenf(vec1, head) > lengthLimit)
|
||||
{
|
||||
if (same == 0)
|
||||
{
|
||||
float dv[3], off[3];
|
||||
float a, b, c, f;
|
||||
|
||||
/* Solve quadratic distance equation */
|
||||
VecSubf(dv, vec1, vec0);
|
||||
a = Inpf(dv, dv);
|
||||
|
||||
VecSubf(off, vec0, head);
|
||||
b = 2 * Inpf(dv, off);
|
||||
|
||||
c = Inpf(off, off) - (lengthLimit * lengthLimit);
|
||||
|
||||
f = (-b + (float)sqrt(b * b - 4 * a * c)) / (2 * a);
|
||||
|
||||
//printf("a %f, b %f, c %f, f %f\n", a, b, c, f);
|
||||
|
||||
if (isnan(f) == 0 && f < 1.0f)
|
||||
{
|
||||
VECCOPY(p, dv);
|
||||
VecMulf(p, f);
|
||||
VecAddf(p, p, vec0);
|
||||
}
|
||||
else
|
||||
{
|
||||
VECCOPY(p, vec1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float dv[3];
|
||||
|
||||
VecSubf(dv, vec1, vec0);
|
||||
Normalize(dv);
|
||||
|
||||
VECCOPY(p, dv);
|
||||
VecMulf(p, lengthLimit);
|
||||
VecAddf(p, p, head);
|
||||
}
|
||||
|
||||
return i - 1; /* restart at lower bound */
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
same = 0; // Reset same
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
EditBone * subdivideArcBy(bContext *C, bArmature *arm, ListBase *editbones, BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion)
|
||||
{
|
||||
EditBone *lastBone = NULL;
|
||||
EditBone *child = NULL;
|
||||
EditBone *parent = NULL;
|
||||
int bone_start = 0;
|
||||
int end = iter->length;
|
||||
int index;
|
||||
|
||||
IT_head(iter);
|
||||
|
||||
parent = addEditBone(arm, "Bone");
|
||||
VECCOPY(parent->head, iter->p);
|
||||
|
||||
index = next_subdividion(C, iter, bone_start, end, parent->head, parent->tail);
|
||||
while (index != -1)
|
||||
{
|
||||
IT_peek(iter, index);
|
||||
|
||||
child = addEditBone(arm, "Bone");
|
||||
VECCOPY(child->head, parent->tail);
|
||||
child->parent = parent;
|
||||
child->flag |= BONE_CONNECTED;
|
||||
|
||||
/* going to next bone, fix parent */
|
||||
Mat4MulVecfl(invmat, parent->tail);
|
||||
Mat4MulVecfl(invmat, parent->head);
|
||||
setBoneRollFromNormal(parent, iter->no, invmat, tmat);
|
||||
|
||||
parent = child; // new child is next parent
|
||||
bone_start = index; // start next bone from current index
|
||||
|
||||
index = next_subdividion(C, iter, bone_start, end, parent->head, parent->tail);
|
||||
}
|
||||
|
||||
iter->tail(iter);
|
||||
|
||||
VECCOPY(parent->tail, iter->p);
|
||||
|
||||
/* fix last bone */
|
||||
Mat4MulVecfl(invmat, parent->tail);
|
||||
Mat4MulVecfl(invmat, parent->head);
|
||||
setBoneRollFromNormal(parent, iter->no, invmat, tmat);
|
||||
lastBone = parent;
|
||||
|
||||
return lastBone;
|
||||
}
|
||||
2961
source/blender/editors/armature/editarmature_retarget.c
Normal file
2961
source/blender/editors/armature/editarmature_retarget.c
Normal file
File diff suppressed because it is too large
Load Diff
3141
source/blender/editors/armature/editarmature_sketch.c
Normal file
3141
source/blender/editors/armature/editarmature_sketch.c
Normal file
File diff suppressed because it is too large
Load Diff
3725
source/blender/editors/armature/reeb.c
Normal file
3725
source/blender/editors/armature/reeb.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -176,8 +176,10 @@ void verifyFaces(ReebGraph *rg);
|
||||
|
||||
#define REEB_MAX_MULTI_LEVEL 10
|
||||
|
||||
struct bContext;
|
||||
|
||||
ReebGraph *BIF_ReebGraphFromEditMesh(void);
|
||||
ReebGraph *BIF_ReebGraphMultiFromEditMesh(void);
|
||||
ReebGraph *BIF_ReebGraphMultiFromEditMesh(struct bContext *C);
|
||||
void BIF_flagMultiArcs(ReebGraph *rg, int flag);
|
||||
|
||||
void BIF_GlobalReebGraphFromEditMesh(void);
|
||||
|
||||
@@ -156,8 +156,10 @@ typedef enum SnapMode
|
||||
|
||||
#define SNAP_MIN_DISTANCE 30
|
||||
|
||||
int snapObjects(struct TransInfo *t, int *dist, float *loc, float *no, SnapMode mode);
|
||||
int peelObjects(struct TransInfo *t, struct ListBase *depth_peels, short mval[2]);
|
||||
int peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, short mval[2]);
|
||||
int peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, short mval[2]);
|
||||
int snapObjectsTransform(struct TransInfo *t, short mval[2], int *dist, float *loc, float *no, SnapMode mode);
|
||||
int snapObjectsContext(struct bContext *C, short mval[2], int *dist, float *loc, float *no, SnapMode mode);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ void docenter_armature (struct Scene *scene, struct View3D *v3d, struct Object *
|
||||
|
||||
void auto_align_armature(struct Scene *scene, struct View3D *v3d, short mode);
|
||||
void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); /* if bone is already in list, pass it as param to ignore it */
|
||||
void armature_bone_rename(Object *ob, char *oldnamep, char *newnamep);
|
||||
void armature_bone_rename(struct Object *ob, char *oldnamep, char *newnamep);
|
||||
|
||||
void undo_push_armature(struct bContext *C, char *name);
|
||||
|
||||
@@ -122,6 +122,29 @@ void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
|
||||
int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);
|
||||
void ED_pose_deselectall(struct Object *ob, int test, int doundo);
|
||||
|
||||
/* sketch */
|
||||
|
||||
int BIF_paintSketch(struct bContext *C, short mbut);
|
||||
void BIF_endStrokeSketch(struct bContext *C);
|
||||
void BIF_convertSketch(struct bContext *C);
|
||||
void BIF_deleteSketch(struct bContext *C);
|
||||
void BIF_selectAllSketch(struct bContext *C, int mode); /* -1: deselect, 0: select, 1: toggle */
|
||||
int BIF_validSketchMode(struct bContext *C);
|
||||
int BIF_fullSketchMode(struct bContext *C); /* full sketch turned on (not Quick) */
|
||||
void BIF_cancelStrokeSketch(struct bContext *C);
|
||||
void BIF_sk_selectStroke(struct bContext *C, short mval[2], int extend);
|
||||
|
||||
void BIF_makeListTemplates(struct bContext *C);
|
||||
char *BIF_listTemplates(struct bContext *C);
|
||||
int BIF_currentTemplate(struct bContext *C);
|
||||
void BIF_freeTemplates(struct bContext *C);
|
||||
void BIF_setTemplate(struct bContext *C, int index);
|
||||
int BIF_nbJointsTemplate(struct bContext *C);
|
||||
char * BIF_nameBoneTemplate(struct bContext *C);
|
||||
|
||||
void BDR_queueDrawSketch(struct bContext *C);
|
||||
void BDR_drawSketch(struct bContext *C);
|
||||
void BDR_drawSketchNames(struct bContext *C);
|
||||
|
||||
#endif /* ED_ARMATURE_H */
|
||||
|
||||
|
||||
@@ -1557,25 +1557,25 @@ static void view3d_panel_gpencil(const bContext *C, ARegion *ar, short cntrl) //
|
||||
uiEndBlock(C, block);
|
||||
}
|
||||
|
||||
/* XXX etch-a-ton */
|
||||
#if 0
|
||||
static void delete_sketch_armature(void *arg1, void *arg2)
|
||||
static void delete_sketch_armature(bContext *C, void *arg1, void *arg2)
|
||||
{
|
||||
BIF_deleteSketch();
|
||||
BIF_deleteSketch(C);
|
||||
}
|
||||
|
||||
static void convert_sketch_armature(void *arg1, void *arg2)
|
||||
static void convert_sketch_armature(bContext *C, void *arg1, void *arg2)
|
||||
{
|
||||
BIF_convertSketch();
|
||||
BIF_convertSketch(C);
|
||||
}
|
||||
|
||||
static void assign_template_sketch_armature(void *arg1, void *arg2)
|
||||
static void assign_template_sketch_armature(bContext *C, void *arg1, void *arg2)
|
||||
{
|
||||
int index = *(int*)arg1;
|
||||
BIF_setTemplate(index);
|
||||
BIF_setTemplate(C, index);
|
||||
}
|
||||
static void view3d_panel_bonesketch_spaces(short cntrl)
|
||||
static void view3d_panel_bonesketch_spaces(const bContext *C, ARegion *ar, short cntrl)
|
||||
{
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
static int template_index;
|
||||
static char joint_label[128];
|
||||
uiBlock *block;
|
||||
@@ -1585,7 +1585,7 @@ static void view3d_panel_bonesketch_spaces(short cntrl)
|
||||
int nb_joints;
|
||||
|
||||
/* replace with check call to sketching lib */
|
||||
if (G.obedit && G.obedit->type == OB_ARMATURE)
|
||||
if (obedit && obedit->type == OB_ARMATURE)
|
||||
{
|
||||
static char subdiv_tooltip[4][64] = {
|
||||
"Subdivide arcs based on a fixed number of bones",
|
||||
@@ -1595,20 +1595,18 @@ static void view3d_panel_bonesketch_spaces(short cntrl)
|
||||
};
|
||||
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "view3d_panel_bonesketch_spaces", UI_EMBOSS, UI_HELV, curarea->win);
|
||||
uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
|
||||
uiSetPanelHandler(VIEW3D_HANDLER_BONESKETCH); // for close and esc
|
||||
|
||||
if(uiNewPanel(curarea, block, "Bone Sketching", "View3d", 10, 230, 250, height)==0) return;
|
||||
block= uiBeginBlock(C, ar, "view3d_panel_bonesketch_spaces", UI_EMBOSS, UI_HELV);
|
||||
if(uiNewPanel(C, ar, block, "Bone Sketching", "View3d", 340, 10, 318, height)==0) return;
|
||||
uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
|
||||
|
||||
uiNewPanelHeight(block, height);
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
|
||||
/* use real flag instead of 1 */
|
||||
uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, yco, 160, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
|
||||
uiDefButBitC(block, TOG, BONE_SKETCHING_ADJUST, B_REDR, "A", 170, yco, 20, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Adjust strokes by drawing near them");
|
||||
uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 190, yco, 20, 20, &G.scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
|
||||
uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, yco, 160, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones");
|
||||
uiDefButBitC(block, TOG, BONE_SKETCHING_ADJUST, B_REDR, "A", 170, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Adjust strokes by drawing near them");
|
||||
uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 190, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
|
||||
yco -= 20;
|
||||
|
||||
but = uiDefBut(block, BUT, B_REDR, "Convert", 10,yco,100,20, 0, 0, 0, 0, 0, "Convert sketch to armature");
|
||||
@@ -1622,27 +1620,27 @@ static void view3d_panel_bonesketch_spaces(short cntrl)
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
|
||||
uiDefButC(block, MENU, B_REDR, "Subdivision Method%t|Length%x1|Adaptative%x2|Fixed%x0|Template%x3", 10,yco,60,19, &G.scene->toolsettings->bone_sketching_convert, 0, 0, 0, 0, subdiv_tooltip[(unsigned char)G.scene->toolsettings->bone_sketching_convert]);
|
||||
uiDefButC(block, MENU, B_REDR, "Subdivision Method%t|Length%x1|Adaptative%x2|Fixed%x0|Template%x3", 10,yco,60,19, &scene->toolsettings->bone_sketching_convert, 0, 0, 0, 0, subdiv_tooltip[(unsigned char)scene->toolsettings->bone_sketching_convert]);
|
||||
|
||||
switch(G.scene->toolsettings->bone_sketching_convert)
|
||||
switch(scene->toolsettings->bone_sketching_convert)
|
||||
{
|
||||
case SK_CONVERT_CUT_LENGTH:
|
||||
uiDefButF(block, NUM, B_REDR, "Lim:", 70, yco, 140, 19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0, "Maximum length of the subdivided bones");
|
||||
uiDefButF(block, NUM, B_REDR, "Lim:", 70, yco, 140, 19, &scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0, "Maximum length of the subdivided bones");
|
||||
yco -= 20;
|
||||
break;
|
||||
case SK_CONVERT_CUT_ADAPTATIVE:
|
||||
uiDefButF(block, NUM, B_REDR, "Thres:", 70, yco, 140, 19, &G.scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0, "Correlation threshold for subdivision");
|
||||
uiDefButF(block, NUM, B_REDR, "Thres:", 70, yco, 140, 19, &scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0, "Correlation threshold for subdivision");
|
||||
yco -= 20;
|
||||
break;
|
||||
default:
|
||||
case SK_CONVERT_CUT_FIXED:
|
||||
uiDefButC(block, NUM, B_REDR, "Num:", 70, yco, 140, 19, &G.scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Number of subdivided bones");
|
||||
uiDefButC(block, NUM, B_REDR, "Num:", 70, yco, 140, 19, &scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Number of subdivided bones");
|
||||
yco -= 20;
|
||||
break;
|
||||
case SK_CONVERT_RETARGET:
|
||||
uiDefButC(block, ROW, B_DIFF, "No", 70, yco, 40,19, &G.scene->toolsettings->skgen_retarget_roll, 0, 0, 0, 0, "No special roll treatment");
|
||||
uiDefButC(block, ROW, B_DIFF, "View", 110, yco, 50,19, &G.scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_VIEW, 0, 0, "Roll bones perpendicular to view");
|
||||
uiDefButC(block, ROW, B_DIFF, "Joint", 160, yco, 50,19, &G.scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_JOINT, 0, 0, "Roll bones relative to joint bend");
|
||||
uiDefButC(block, ROW, B_NOP, "No", 70, yco, 40,19, &scene->toolsettings->skgen_retarget_roll, 0, 0, 0, 0, "No special roll treatment");
|
||||
uiDefButC(block, ROW, B_NOP, "View", 110, yco, 50,19, &scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_VIEW, 0, 0, "Roll bones perpendicular to view");
|
||||
uiDefButC(block, ROW, B_NOP, "Joint", 160, yco, 50,19, &scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_JOINT, 0, 0, "Roll bones relative to joint bend");
|
||||
yco -= 30;
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
@@ -1650,35 +1648,36 @@ static void view3d_panel_bonesketch_spaces(short cntrl)
|
||||
uiBlockBeginAlign(block);
|
||||
/* button here to select what to do (copy or not), template, ...*/
|
||||
|
||||
BIF_makeListTemplates();
|
||||
template_index = BIF_currentTemplate();
|
||||
BIF_makeListTemplates(C);
|
||||
template_index = BIF_currentTemplate(C);
|
||||
|
||||
but = uiDefButI(block, MENU, B_REDR, BIF_listTemplates(), 10,yco,200,19, &template_index, 0, 0, 0, 0, "Template");
|
||||
but = uiDefButI(block, MENU, B_REDR, BIF_listTemplates(C), 10,yco,200,19, &template_index, 0, 0, 0, 0, "Template");
|
||||
uiButSetFunc(but, assign_template_sketch_armature, &template_index, NULL);
|
||||
|
||||
yco -= 20;
|
||||
|
||||
uiDefButF(block, NUM, B_DIFF, "A:", 10, yco, 66,19, &G.scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0, "Angle Weight");
|
||||
uiDefButF(block, NUM, B_DIFF, "L:", 76, yco, 67,19, &G.scene->toolsettings->skgen_retarget_length_weight, 0, 10, 1, 0, "Length Weight");
|
||||
uiDefButF(block, NUM, B_DIFF, "D:", 143,yco, 67,19, &G.scene->toolsettings->skgen_retarget_distance_weight, 0, 10, 1, 0, "Distance Weight");
|
||||
uiDefButF(block, NUM, B_NOP, "A:", 10, yco, 66,19, &scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0, "Angle Weight");
|
||||
uiDefButF(block, NUM, B_NOP, "L:", 76, yco, 67,19, &scene->toolsettings->skgen_retarget_length_weight, 0, 10, 1, 0, "Length Weight");
|
||||
uiDefButF(block, NUM, B_NOP, "D:", 143,yco, 67,19, &scene->toolsettings->skgen_retarget_distance_weight, 0, 10, 1, 0, "Distance Weight");
|
||||
yco -= 20;
|
||||
|
||||
uiDefBut(block, TEX,B_DIFF,"S:", 10, yco, 90, 20, G.scene->toolsettings->skgen_side_string, 0.0, 8.0, 0, 0, "Text to replace &S with");
|
||||
uiDefBut(block, TEX,B_DIFF,"N:", 100, yco, 90, 20, G.scene->toolsettings->skgen_num_string, 0.0, 8.0, 0, 0, "Text to replace &N with");
|
||||
uiDefIconButBitC(block, TOG, SK_RETARGET_AUTONAME, B_DIFF, ICON_AUTO,190,yco,20,20, &G.scene->toolsettings->skgen_retarget_options, 0, 0, 0, 0, "Use Auto Naming");
|
||||
uiDefBut(block, TEX,B_REDR,"S:", 10, yco, 90, 20, scene->toolsettings->skgen_side_string, 0.0, 8.0, 0, 0, "Text to replace &S with");
|
||||
uiDefBut(block, TEX,B_REDR,"N:", 100, yco, 90, 20, scene->toolsettings->skgen_num_string, 0.0, 8.0, 0, 0, "Text to replace &N with");
|
||||
uiDefIconButBitC(block, TOG, SK_RETARGET_AUTONAME, B_NOP, ICON_AUTO,190,yco,20,20, &scene->toolsettings->skgen_retarget_options, 0, 0, 0, 0, "Use Auto Naming");
|
||||
yco -= 20;
|
||||
|
||||
/* auto renaming magic */
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
nb_joints = BIF_nbJointsTemplate();
|
||||
nb_joints = BIF_nbJointsTemplate(C);
|
||||
|
||||
if (nb_joints == -1)
|
||||
{
|
||||
nb_joints = G.totvertsel;
|
||||
//XXX
|
||||
//nb_joints = G.totvertsel;
|
||||
}
|
||||
|
||||
bone_name = BIF_nameBoneTemplate();
|
||||
bone_name = BIF_nameBoneTemplate(C);
|
||||
|
||||
BLI_snprintf(joint_label, 32, "%i joints: %s", nb_joints, bone_name);
|
||||
|
||||
@@ -1689,12 +1688,11 @@ static void view3d_panel_bonesketch_spaces(short cntrl)
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
uiDefButBitS(block, TOG, SCE_SNAP_PEEL_OBJECT, B_DIFF, "Peel Objects", 10, yco, 200, 20, &G.scene->snap_flag, 0, 0, 0, 0, "Peel whole objects as one");
|
||||
uiDefButBitS(block, TOG, SCE_SNAP_PEEL_OBJECT, B_NOP, "Peel Objects", 10, yco, 200, 20, &scene->snap_flag, 0, 0, 0, 0, "Peel whole objects as one");
|
||||
|
||||
if(yco < 0) uiNewPanelHeight(block, height-yco);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void view3d_buttons_area_defbuts(const bContext *C, ARegion *ar)
|
||||
{
|
||||
@@ -1708,7 +1706,8 @@ void view3d_buttons_area_defbuts(const bContext *C, ARegion *ar)
|
||||
view3d_panel_transform_spaces(C, ar, 0);
|
||||
if(0)
|
||||
view3d_panel_gpencil(C, ar, 0);
|
||||
// XXX etch-a-ton view3d_panel_bonesketch_spaces(C, ar, 0);
|
||||
|
||||
view3d_panel_bonesketch_spaces(C, ar, 0);
|
||||
|
||||
uiDrawPanels(C, 1); /* 1 = align */
|
||||
uiMatchPanelsView2d(ar); /* sets v2d->totrct */
|
||||
|
||||
@@ -2053,7 +2053,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
|
||||
// if (v3d->flag2 & V3D_DISPGP)
|
||||
// draw_gpencil_3dview(ar, 1);
|
||||
|
||||
// XXX etch-a-ton BDR_drawSketch();
|
||||
BDR_drawSketch(C);
|
||||
|
||||
ED_region_pixelspace(ar);
|
||||
|
||||
|
||||
@@ -70,9 +70,7 @@
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_view3d.h"
|
||||
|
||||
// XXX etch-a-ton #include "BIF_sketch.h"
|
||||
// XXX etch-a-ton #include "BDR_sketch.h"
|
||||
#include "ED_armature.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
@@ -1145,12 +1143,13 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
|
||||
draw_object(scene, ar, v3d, BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
|
||||
}
|
||||
else if((vc->obedit && vc->obedit->type==OB_ARMATURE)) {
|
||||
/* XXX etch-a-ton if(BIF_fullSketchMode()) {
|
||||
BDR_drawSketchNames();
|
||||
}
|
||||
else*/ {
|
||||
/* XXX etch-a-ton */
|
||||
// if(BIF_fullSketchMode(C)) {
|
||||
// BDR_drawSketchNames(C);
|
||||
// }
|
||||
// else {
|
||||
draw_object(scene, ar, v3d, BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
|
||||
}
|
||||
// }
|
||||
}
|
||||
else {
|
||||
Base *base;
|
||||
|
||||
@@ -521,7 +521,7 @@ void CalcSnapGeometry(TransInfo *t, float *vec)
|
||||
|
||||
depth_peels.first = depth_peels.last = NULL;
|
||||
|
||||
peelObjects(t, &depth_peels, t->mval);
|
||||
peelObjectsTransForm(t, &depth_peels, t->mval);
|
||||
|
||||
// if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS)
|
||||
// {
|
||||
@@ -613,7 +613,7 @@ void CalcSnapGeometry(TransInfo *t, float *vec)
|
||||
mode = SNAP_NOT_OBEDIT;
|
||||
}
|
||||
|
||||
found = snapObjects(t, &dist, loc, no, mode);
|
||||
found = snapObjectsTransform(t, t->mval, &dist, loc, no, mode);
|
||||
}
|
||||
|
||||
if (found == 1)
|
||||
@@ -834,7 +834,7 @@ void TargetSnapClosest(TransInfo *t)
|
||||
}
|
||||
/*================================================================*/
|
||||
|
||||
int snapFace(TransInfo *t, float v1co[3], float v2co[3], float v3co[3], float *v4co, short mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
||||
int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], float *v4co, short mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
||||
{
|
||||
float lambda;
|
||||
int result;
|
||||
@@ -864,7 +864,7 @@ int snapFace(TransInfo *t, float v1co[3], float v2co[3], float v3co[3], float *v
|
||||
|
||||
new_depth = VecLenf(location, ray_start);
|
||||
|
||||
project_int(t->ar, location, screen_loc);
|
||||
project_int(ar, location, screen_loc);
|
||||
new_dist = abs(screen_loc[0] - mval[0]) + abs(screen_loc[1] - mval[1]);
|
||||
|
||||
if (new_dist <= *dist && new_depth < *depth)
|
||||
@@ -885,7 +885,7 @@ int snapFace(TransInfo *t, float v1co[3], float v2co[3], float v3co[3], float *v
|
||||
return retval;
|
||||
}
|
||||
|
||||
int snapEdge(TransInfo *t, float v1co[3], short v1no[3], float v2co[3], short v2no[3], short mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
||||
int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], short mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
||||
{
|
||||
float intersect[3] = {0, 0, 0}, ray_end[3], dvec[3];
|
||||
int result;
|
||||
@@ -932,7 +932,7 @@ int snapEdge(TransInfo *t, float v1co[3], short v1no[3], float v2co[3], short v2
|
||||
|
||||
new_depth = VecLenf(location, ray_start);
|
||||
|
||||
project_int(t->ar, location, screen_loc);
|
||||
project_int(ar, location, screen_loc);
|
||||
new_dist = abs(screen_loc[0] - mval[0]) + abs(screen_loc[1] - mval[1]);
|
||||
|
||||
/* 10% threshold if edge is closer but a bit further
|
||||
@@ -970,7 +970,7 @@ int snapEdge(TransInfo *t, float v1co[3], short v1no[3], float v2co[3], short v2
|
||||
return retval;
|
||||
}
|
||||
|
||||
int snapVertex(TransInfo *t, float vco[3], short vno[3], short mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
||||
int snapVertex(ARegion *ar, float vco[3], short vno[3], short mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float *loc, float *no, int *dist, float *depth)
|
||||
{
|
||||
int retval = 0;
|
||||
float dvec[3];
|
||||
@@ -990,7 +990,7 @@ int snapVertex(TransInfo *t, float vco[3], short vno[3], short mval[2], float ra
|
||||
|
||||
new_depth = VecLenf(location, ray_start);
|
||||
|
||||
project_int(t->ar, location, screen_loc);
|
||||
project_int(ar, location, screen_loc);
|
||||
new_dist = abs(screen_loc[0] - mval[0]) + abs(screen_loc[1] - mval[1]);
|
||||
|
||||
if (new_dist <= *dist && new_depth < *depth)
|
||||
@@ -1014,7 +1014,7 @@ int snapVertex(TransInfo *t, float vco[3], short vno[3], short mval[2], float ra
|
||||
return retval;
|
||||
}
|
||||
|
||||
int snapArmature(TransInfo *t, Object *ob, bArmature *arm, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth)
|
||||
int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth)
|
||||
{
|
||||
float imat[4][4];
|
||||
float ray_start_local[3], ray_normal_local[3];
|
||||
@@ -1036,14 +1036,14 @@ int snapArmature(TransInfo *t, Object *ob, bArmature *arm, float obmat[][4], flo
|
||||
if (eBone->layer & arm->layer) {
|
||||
/* skip hidden or moving (selected) bones */
|
||||
if ((eBone->flag & (BONE_HIDDEN_A|BONE_ROOTSEL|BONE_TIPSEL))==0) {
|
||||
switch (t->scene->snap_mode)
|
||||
switch (snap_mode)
|
||||
{
|
||||
case SCE_SNAP_MODE_VERTEX:
|
||||
retval |= snapVertex(t, eBone->head, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
retval |= snapVertex(t, eBone->tail, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
retval |= snapVertex(ar, eBone->head, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
retval |= snapVertex(ar, eBone->tail, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
break;
|
||||
case SCE_SNAP_MODE_EDGE:
|
||||
retval |= snapEdge(t, eBone->head, NULL, eBone->tail, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
retval |= snapEdge(ar, eBone->head, NULL, eBone->tail, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1062,14 +1062,14 @@ int snapArmature(TransInfo *t, Object *ob, bArmature *arm, float obmat[][4], flo
|
||||
float *head_vec = pchan->pose_head;
|
||||
float *tail_vec = pchan->pose_tail;
|
||||
|
||||
switch (t->scene->snap_mode)
|
||||
switch (snap_mode)
|
||||
{
|
||||
case SCE_SNAP_MODE_VERTEX:
|
||||
retval |= snapVertex(t, head_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
retval |= snapVertex(t, tail_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
retval |= snapVertex(ar, head_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
retval |= snapVertex(ar, tail_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
break;
|
||||
case SCE_SNAP_MODE_EDGE:
|
||||
retval |= snapEdge(t, head_vec, NULL, tail_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
retval |= snapEdge(ar, head_vec, NULL, tail_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1079,7 +1079,7 @@ int snapArmature(TransInfo *t, Object *ob, bArmature *arm, float obmat[][4], flo
|
||||
return retval;
|
||||
}
|
||||
|
||||
int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, EditMesh *em, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth)
|
||||
int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, EditMesh *em, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth)
|
||||
{
|
||||
int retval = 0;
|
||||
int totvert = dm->getNumVerts(dm);
|
||||
@@ -1113,7 +1113,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, EditMesh *em, flo
|
||||
|
||||
if (test == 1) {
|
||||
|
||||
switch (t->scene->snap_mode)
|
||||
switch (snap_mode)
|
||||
{
|
||||
case SCE_SNAP_MODE_FACE:
|
||||
{
|
||||
@@ -1172,12 +1172,12 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, EditMesh *em, flo
|
||||
v4co = verts[f->v4].co;
|
||||
}
|
||||
|
||||
result = snapFace(t, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, v4co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
||||
result = snapFace(ar, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, v4co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
||||
retval |= result;
|
||||
|
||||
if (f->v4 && result == 0)
|
||||
{
|
||||
retval |= snapFace(t, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, verts[f->v2].co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
||||
retval |= snapFace(ar, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, verts[f->v2].co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1236,7 +1236,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, EditMesh *em, flo
|
||||
|
||||
if (test)
|
||||
{
|
||||
retval |= snapVertex(t, v->co, v->no, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
||||
retval |= snapVertex(ar, v->co, v->no, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1296,7 +1296,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, EditMesh *em, flo
|
||||
|
||||
if (test)
|
||||
{
|
||||
retval |= snapEdge(t, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
||||
retval |= snapEdge(ar, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1313,16 +1313,10 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, EditMesh *em, flo
|
||||
return retval;
|
||||
}
|
||||
|
||||
int snapObject(TransInfo *t, Object *ob, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth)
|
||||
int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth)
|
||||
{
|
||||
int editobject = 0;
|
||||
int retval = 0;
|
||||
|
||||
if (ob == t->obedit)
|
||||
{
|
||||
editobject = 1;
|
||||
}
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
EditMesh *em;
|
||||
DerivedMesh *dm;
|
||||
@@ -1330,41 +1324,39 @@ int snapObject(TransInfo *t, Object *ob, float obmat[][4], float ray_start[3], f
|
||||
if (editobject)
|
||||
{
|
||||
em = ((Mesh *)ob->data)->edit_mesh;
|
||||
dm = editmesh_get_derived_cage(t->scene, t->obedit, em, CD_MASK_BAREMESH);
|
||||
dm = editmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
|
||||
}
|
||||
else
|
||||
{
|
||||
em = NULL;
|
||||
dm = mesh_get_derived_final(t->scene, ob, CD_MASK_BAREMESH);
|
||||
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
|
||||
}
|
||||
|
||||
retval = snapDerivedMesh(t, ob, dm, em, obmat, ray_start, ray_normal, mval, loc, no, dist, depth);
|
||||
retval = snapDerivedMesh(scene->snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, mval, loc, no, dist, depth);
|
||||
|
||||
dm->release(dm);
|
||||
}
|
||||
else if (ob->type == OB_ARMATURE)
|
||||
{
|
||||
retval = snapArmature(t, ob, ob->data, obmat, ray_start, ray_normal, mval, loc, no, dist, depth);
|
||||
retval = snapArmature(scene->snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, loc, no, dist, depth);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int snapObjects(TransInfo *t, int *dist, float *loc, float *no, SnapMode mode) {
|
||||
Scene *scene = t->scene;
|
||||
View3D *v3d = t->view;
|
||||
int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, short mval[2], int *dist, float *loc, float *no, SnapMode mode) {
|
||||
Base *base;
|
||||
float depth = FLT_MAX;
|
||||
int retval = 0;
|
||||
float ray_start[3], ray_normal[3];
|
||||
|
||||
viewray(t->ar, v3d, t->mval, ray_start, ray_normal);
|
||||
viewray(ar, v3d, mval, ray_start, ray_normal);
|
||||
|
||||
if (mode == SNAP_ALL && t->obedit)
|
||||
if (mode == SNAP_ALL && obedit)
|
||||
{
|
||||
Object *ob = t->obedit;
|
||||
Object *ob = obedit;
|
||||
|
||||
retval |= snapObject(t, ob, ob->obmat, ray_start, ray_normal, t->mval, loc, no, dist, &depth);
|
||||
retval |= snapObject(scene, ar, ob, 1, ob->obmat, ray_start, ray_normal, mval, loc, no, dist, &depth);
|
||||
}
|
||||
|
||||
base= FIRSTBASE;
|
||||
@@ -1375,25 +1367,38 @@ int snapObjects(TransInfo *t, int *dist, float *loc, float *no, SnapMode mode) {
|
||||
if (ob->transflag & OB_DUPLI)
|
||||
{
|
||||
DupliObject *dupli_ob;
|
||||
ListBase *lb = object_duplilist(t->scene, ob);
|
||||
ListBase *lb = object_duplilist(scene, ob);
|
||||
|
||||
for(dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next)
|
||||
{
|
||||
Object *ob = dupli_ob->ob;
|
||||
|
||||
retval |= snapObject(t, ob, dupli_ob->mat, ray_start, ray_normal, t->mval, loc, no, dist, &depth);
|
||||
retval |= snapObject(scene, ar, ob, 0, dupli_ob->mat, ray_start, ray_normal, mval, loc, no, dist, &depth);
|
||||
}
|
||||
|
||||
free_object_duplilist(lb);
|
||||
}
|
||||
|
||||
retval |= snapObject(t, ob, ob->obmat, ray_start, ray_normal, t->mval, loc, no, dist, &depth);
|
||||
retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, loc, no, dist, &depth);
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int snapObjectsTransform(TransInfo *t, short mval[2], int *dist, float *loc, float *no, SnapMode mode)
|
||||
{
|
||||
return snapObjects(t->scene, t->view, t->ar, t->obedit, mval, dist, loc, no, mode);
|
||||
}
|
||||
|
||||
int snapObjectsContext(bContext *C, short mval[2], int *dist, float *loc, float *no, SnapMode mode)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
|
||||
return snapObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), mval, dist, loc, no, mode);
|
||||
}
|
||||
|
||||
/******************** PEELING *********************************/
|
||||
|
||||
|
||||
@@ -1451,7 +1456,7 @@ void addDepthPeel(ListBase *depth_peels, float depth, float p[3], float no[3], O
|
||||
peel->flag = 0;
|
||||
}
|
||||
|
||||
int peelDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], ListBase *depth_peels)
|
||||
int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], ListBase *depth_peels)
|
||||
{
|
||||
int retval = 0;
|
||||
int totvert = dm->getNumVerts(dm);
|
||||
@@ -1559,15 +1564,13 @@ int peelDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
|
||||
return retval;
|
||||
}
|
||||
|
||||
int peelObjects(TransInfo *t, ListBase *depth_peels, short mval[2])
|
||||
int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, ListBase *depth_peels, short mval[2])
|
||||
{
|
||||
Scene *scene= t->scene;
|
||||
View3D *v3d= t->view;
|
||||
Base *base;
|
||||
int retval = 0;
|
||||
float ray_start[3], ray_normal[3];
|
||||
|
||||
viewray(t->ar, v3d, t->mval, ray_start, ray_normal);
|
||||
viewray(ar, v3d, mval, ray_start, ray_normal);
|
||||
|
||||
for ( base = scene->base.first; base != NULL; base = base->next ) {
|
||||
if ( BASE_SELECTABLE(v3d, base) ) {
|
||||
@@ -1576,7 +1579,7 @@ int peelObjects(TransInfo *t, ListBase *depth_peels, short mval[2])
|
||||
if (ob->transflag & OB_DUPLI)
|
||||
{
|
||||
DupliObject *dupli_ob;
|
||||
ListBase *lb = object_duplilist(t->scene, ob);
|
||||
ListBase *lb = object_duplilist(scene, ob);
|
||||
|
||||
for(dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next)
|
||||
{
|
||||
@@ -1586,7 +1589,7 @@ int peelObjects(TransInfo *t, ListBase *depth_peels, short mval[2])
|
||||
DerivedMesh *dm;
|
||||
int val;
|
||||
|
||||
val = peelDerivedMesh(t, ob, dm, dupli_ob->mat, ray_start, ray_normal, mval, depth_peels);
|
||||
val = peelDerivedMesh(ob, dm, dupli_ob->mat, ray_start, ray_normal, mval, depth_peels);
|
||||
|
||||
retval = retval || val;
|
||||
|
||||
@@ -1602,18 +1605,18 @@ int peelObjects(TransInfo *t, ListBase *depth_peels, short mval[2])
|
||||
DerivedMesh *dm = NULL;
|
||||
int val;
|
||||
|
||||
if (ob != t->obedit)
|
||||
if (ob != obedit)
|
||||
{
|
||||
dm = mesh_get_derived_final(t->scene, ob, CD_MASK_BAREMESH);
|
||||
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
|
||||
|
||||
val = peelDerivedMesh(t, ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels);
|
||||
val = peelDerivedMesh(ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels);
|
||||
}
|
||||
else
|
||||
{
|
||||
em = ((Mesh *)ob->data)->edit_mesh;
|
||||
dm = editmesh_get_derived_cage(t->scene, t->obedit, em, CD_MASK_BAREMESH);
|
||||
dm = editmesh_get_derived_cage(scene, obedit, em, CD_MASK_BAREMESH);
|
||||
|
||||
val = peelDerivedMesh(t, ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels);
|
||||
val = peelDerivedMesh(ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels);
|
||||
}
|
||||
|
||||
retval = retval || val;
|
||||
@@ -1629,6 +1632,19 @@ int peelObjects(TransInfo *t, ListBase *depth_peels, short mval[2])
|
||||
return retval;
|
||||
}
|
||||
|
||||
int peelObjectsTransForm(TransInfo *t, ListBase *depth_peels, short mval[2])
|
||||
{
|
||||
return peelObjects(t->scene, t->view, t->ar, t->obedit, depth_peels, mval);
|
||||
}
|
||||
|
||||
int peelObjectsContext(bContext *C, ListBase *depth_peels, short mval[2])
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
|
||||
return peelObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), depth_peels, mval);
|
||||
}
|
||||
|
||||
/*================================================================*/
|
||||
|
||||
static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action);
|
||||
|
||||
@@ -196,7 +196,13 @@ void WM_exit(bContext *C)
|
||||
/* all non-screen and non-space stuff editors did, like editmode */
|
||||
if(C)
|
||||
ED_editors_exit(C);
|
||||
|
||||
|
||||
// XXX
|
||||
// BIF_GlobalReebFree();
|
||||
// BIF_freeRetarget();
|
||||
// BIF_freeTemplates();
|
||||
// BIF_freeSketch();
|
||||
|
||||
/* Context should still working here. but radio tool needs cleaning... */
|
||||
freeAllRad(CTX_data_scene(C));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user