bugfix's
[#23108] bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') dosen't work in console [#23115] Crash when moving armature origin - setting the armature in editmode would leave editdata in some cases. - transforming selected linked objects to account for the movement of the obdata was only done for meshes, now do for curves and text3d. - added utility functions for getting curve & mesh bounds. - text3d moving center wasn't working at all. - changed drawobject.c to use BLI_math funcs in more places. - remove some unused code from operator object.origin_set.
This commit is contained in:
@@ -107,5 +107,9 @@ int clamp_nurb_order_v( struct Nurb *nu);
|
||||
|
||||
ListBase *BKE_curve_nurbs(struct Curve *cu);
|
||||
|
||||
int curve_bounds(struct Curve *cu, float min[3], float max[3]);
|
||||
int curve_center_median(struct Curve *cu, float cent[3]);
|
||||
int curve_center_bounds(struct Curve *cu, float cent[3]);
|
||||
void curve_translate(struct Curve *cu, float offset[3], int do_keys);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -140,7 +140,12 @@ int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to
|
||||
void mesh_layers_menu_concat(struct CustomData *data, int type, char *str);
|
||||
int mesh_layers_menu(struct CustomData *data, int type);
|
||||
|
||||
/* vertex level transformations & checks (no derived mesh) */
|
||||
|
||||
int mesh_bounds(struct Mesh *me, float min[3], float max[3]);
|
||||
int mesh_center_median(struct Mesh *me, float cent[3]);
|
||||
int mesh_center_bounds(struct Mesh *me, float cent[3]);
|
||||
void mesh_translate(struct Mesh *me, float offset[3], int do_keys);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ void tex_space_curve(Curve *cu)
|
||||
{
|
||||
DispList *dl;
|
||||
BoundBox *bb;
|
||||
float *fp, min[3], max[3], loc[3], size[3];
|
||||
float *fp, min[3], max[3];
|
||||
int tot, doit= 0;
|
||||
|
||||
if(cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
|
||||
@@ -303,20 +303,15 @@ void tex_space_curve(Curve *cu)
|
||||
min[0] = min[1] = min[2] = -1.0f;
|
||||
max[0] = max[1] = max[2] = 1.0f;
|
||||
}
|
||||
|
||||
loc[0]= (min[0]+max[0])/2.0f;
|
||||
loc[1]= (min[1]+max[1])/2.0f;
|
||||
loc[2]= (min[2]+max[2])/2.0f;
|
||||
|
||||
size[0]= (max[0]-min[0])/2.0f;
|
||||
size[1]= (max[1]-min[1])/2.0f;
|
||||
size[2]= (max[2]-min[2])/2.0f;
|
||||
|
||||
boundbox_set_from_min_max(bb, min, max);
|
||||
|
||||
if(cu->texflag & CU_AUTOSPACE) {
|
||||
VECCOPY(cu->loc, loc);
|
||||
VECCOPY(cu->size, size);
|
||||
mid_v3_v3v3(cu->loc, min, max);
|
||||
cu->size[0]= (max[0]-min[0])/2.0f;
|
||||
cu->size[1]= (max[1]-min[1])/2.0f;
|
||||
cu->size[2]= (max[2]-min[2])/2.0f;
|
||||
|
||||
cu->rot[0]= cu->rot[1]= cu->rot[2]= 0.0;
|
||||
|
||||
if(cu->size[0]==0.0) cu->size[0]= 1.0;
|
||||
@@ -3107,3 +3102,103 @@ ListBase *BKE_curve_nurbs(Curve *cu)
|
||||
|
||||
return &cu->nurb;
|
||||
}
|
||||
|
||||
|
||||
/* basic vertex data functions */
|
||||
int curve_bounds(Curve *cu, float min[3], float max[3])
|
||||
{
|
||||
ListBase *nurb_lb= BKE_curve_nurbs(cu);
|
||||
Nurb *nu;
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
for(nu= nurb_lb->first; nu; nu= nu->next)
|
||||
minmaxNurb(nu, min, max);
|
||||
|
||||
return (nurb_lb->first != NULL);
|
||||
}
|
||||
|
||||
int curve_center_median(Curve *cu, float cent[3])
|
||||
{
|
||||
ListBase *nurb_lb= BKE_curve_nurbs(cu);
|
||||
Nurb *nu;
|
||||
int total= 0;
|
||||
|
||||
zero_v3(cent);
|
||||
|
||||
for(nu= nurb_lb->first; nu; nu= nu->next) {
|
||||
int i;
|
||||
|
||||
if(nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt;
|
||||
i= nu->pntsu;
|
||||
total += i * 3;
|
||||
for(bezt= nu->bezt; i--; bezt++) {
|
||||
add_v3_v3(cent, bezt->vec[0]);
|
||||
add_v3_v3(cent, bezt->vec[1]);
|
||||
add_v3_v3(cent, bezt->vec[2]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BPoint *bp;
|
||||
i= nu->pntsu*nu->pntsv;
|
||||
total += i;
|
||||
for(bp= nu->bp; i--; bp++) {
|
||||
add_v3_v3(cent, bp->vec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mul_v3_fl(cent, 1.0f/(float)total);
|
||||
|
||||
return (total != 0);
|
||||
}
|
||||
|
||||
int curve_center_bounds(Curve *cu, float cent[3])
|
||||
{
|
||||
float min[3], max[3];
|
||||
|
||||
if(curve_bounds(cu, min, max)) {
|
||||
mid_v3_v3v3(cent, min, max);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void curve_translate(Curve *cu, float offset[3], int do_keys)
|
||||
{
|
||||
ListBase *nurb_lb= BKE_curve_nurbs(cu);
|
||||
Nurb *nu;
|
||||
int i;
|
||||
|
||||
for(nu= nurb_lb->first; nu; nu= nu->next) {
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
|
||||
if(nu->type == CU_BEZIER) {
|
||||
i= nu->pntsu;
|
||||
for(bezt= nu->bezt; i--; bezt++) {
|
||||
add_v3_v3(bezt->vec[0], offset);
|
||||
add_v3_v3(bezt->vec[1], offset);
|
||||
add_v3_v3(bezt->vec[2], offset);
|
||||
}
|
||||
}
|
||||
else {
|
||||
i= nu->pntsu*nu->pntsv;
|
||||
for(bp= nu->bp; i--; bp++) {
|
||||
add_v3_v3(bp->vec, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (do_keys && cu->key) {
|
||||
KeyBlock *kb;
|
||||
for (kb=cu->key->block.first; kb; kb=kb->next) {
|
||||
float *fp= kb->data;
|
||||
for (i= kb->totelem; i--; fp+=3) {
|
||||
add_v3_v3(fp, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,33 +320,22 @@ void make_local_mesh(Mesh *me)
|
||||
|
||||
void boundbox_mesh(Mesh *me, float *loc, float *size)
|
||||
{
|
||||
MVert *mvert;
|
||||
BoundBox *bb;
|
||||
float min[3], max[3];
|
||||
float mloc[3], msize[3];
|
||||
int a;
|
||||
|
||||
if(me->bb==0) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
|
||||
bb= me->bb;
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
if (!loc) loc= mloc;
|
||||
if (!size) size= msize;
|
||||
|
||||
mvert= me->mvert;
|
||||
for(a=0; a<me->totvert; a++, mvert++) {
|
||||
DO_MINMAX(mvert->co, min, max);
|
||||
}
|
||||
|
||||
if(!me->totvert) {
|
||||
if(!mesh_bounds(me, min, max)) {
|
||||
min[0] = min[1] = min[2] = -1.0f;
|
||||
max[0] = max[1] = max[2] = 1.0f;
|
||||
}
|
||||
|
||||
loc[0]= (min[0]+max[0])/2.0f;
|
||||
loc[1]= (min[1]+max[1])/2.0f;
|
||||
loc[2]= (min[2]+max[2])/2.0f;
|
||||
mid_v3_v3v3(loc, min, max);
|
||||
|
||||
size[0]= (max[0]-min[0])/2.0f;
|
||||
size[1]= (max[1]-min[1])/2.0f;
|
||||
@@ -369,9 +358,9 @@ void tex_space_mesh(Mesh *me)
|
||||
else if(size[a]<0.0 && size[a]> -0.00001) size[a]= -0.00001;
|
||||
}
|
||||
|
||||
VECCOPY(me->loc, loc);
|
||||
VECCOPY(me->size, size);
|
||||
me->rot[0]= me->rot[1]= me->rot[2]= 0.0;
|
||||
copy_v3_v3(me->loc, loc);
|
||||
copy_v3_v3(me->size, size);
|
||||
zero_v3(me->rot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,9 +402,7 @@ float *get_mesh_orco_verts(Object *ob)
|
||||
totvert = MIN2(tme->totvert, me->totvert);
|
||||
|
||||
for(a=0; a<totvert; a++, mvert++) {
|
||||
vcos[a][0]= mvert->co[0];
|
||||
vcos[a][1]= mvert->co[1];
|
||||
vcos[a][2]= mvert->co[2];
|
||||
copy_v3_v3(vcos[a], mvert->co);
|
||||
}
|
||||
|
||||
return (float*)vcos;
|
||||
@@ -431,9 +418,7 @@ void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int inve
|
||||
if(invert) {
|
||||
for(a=0; a<totvert; a++) {
|
||||
float *co = orco[a];
|
||||
co[0] = co[0]*size[0] + loc[0];
|
||||
co[1] = co[1]*size[1] + loc[1];
|
||||
co[2] = co[2]*size[2] + loc[2];
|
||||
madd_v3_v3v3v3(co, loc, co, size);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1497,3 +1482,60 @@ void mesh_pmv_off(Object *ob, Mesh *me)
|
||||
me->pv= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* basic vertex data functions */
|
||||
int mesh_bounds(Mesh *me, float min[3], float max[3])
|
||||
{
|
||||
int i= me->totvert;
|
||||
MVert *mvert;
|
||||
INIT_MINMAX(min, max);
|
||||
for(mvert= me->mvert; i--; mvert++) {
|
||||
DO_MINMAX(mvert->co, min, max);
|
||||
}
|
||||
|
||||
return (me->totvert != 0);
|
||||
}
|
||||
|
||||
int mesh_center_median(Mesh *me, float cent[3])
|
||||
{
|
||||
int i= me->totvert;
|
||||
MVert *mvert;
|
||||
zero_v3(cent);
|
||||
for(mvert= me->mvert; i--; mvert++) {
|
||||
add_v3_v3(cent, mvert->co);
|
||||
}
|
||||
mul_v3_fl(cent, 1.0f/(float)me->totvert);
|
||||
|
||||
return (me->totvert != 0);
|
||||
}
|
||||
|
||||
int mesh_center_bounds(Mesh *me, float cent[3])
|
||||
{
|
||||
float min[3], max[3];
|
||||
|
||||
if(mesh_bounds(me, min, max)) {
|
||||
mid_v3_v3v3(cent, min, max);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mesh_translate(Mesh *me, float offset[3], int do_keys)
|
||||
{
|
||||
int i= me->totvert;
|
||||
MVert *mvert;
|
||||
for(mvert= me->mvert; i--; mvert++) {
|
||||
add_v3_v3(mvert->co, offset);
|
||||
}
|
||||
|
||||
if (do_keys && me->key) {
|
||||
KeyBlock *kb;
|
||||
for (kb=me->key->block.first; kb; kb=kb->next) {
|
||||
float *fp= kb->data;
|
||||
for (i= kb->totelem; i--; fp+=3) {
|
||||
add_v3_v3(fp, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,34 +421,45 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
|
||||
|
||||
/* exported for use in editors/object/ */
|
||||
/* 0 == do center, 1 == center new, 2 == center cursor */
|
||||
void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode)
|
||||
void docenter_armature (Scene *scene, Object *ob, float cursor[3], int centermode, int around)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
EditBone *ebone;
|
||||
bArmature *arm= ob->data;
|
||||
float cent[3] = {0.0f, 0.0f, 0.0f};
|
||||
float min[3], max[3];
|
||||
float cent[3];
|
||||
|
||||
/* Put the armature into editmode */
|
||||
if(ob!=obedit)
|
||||
if(ob != obedit) {
|
||||
ED_armature_to_edit(ob);
|
||||
obedit= NULL; /* we cant use this so behave as if there is no obedit */
|
||||
}
|
||||
|
||||
/* Find the centerpoint */
|
||||
if (centermode == 2) {
|
||||
float *fp= give_cursor(scene, v3d);
|
||||
copy_v3_v3(cent, fp);
|
||||
copy_v3_v3(cent, cursor);
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_m4_v3(ob->imat, cent);
|
||||
}
|
||||
else {
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
DO_MINMAX(ebone->head, min, max);
|
||||
DO_MINMAX(ebone->tail, min, max);
|
||||
if(around==V3D_CENTROID) {
|
||||
int total= 0;
|
||||
zero_v3(cent);
|
||||
for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
total+=2;
|
||||
add_v3_v3(cent, ebone->head);
|
||||
add_v3_v3(cent, ebone->tail);
|
||||
}
|
||||
mul_v3_fl(cent, 1.0f/(float)total);
|
||||
}
|
||||
else {
|
||||
float min[3], max[3];
|
||||
INIT_MINMAX(min, max);
|
||||
for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
DO_MINMAX(ebone->head, min, max);
|
||||
DO_MINMAX(ebone->tail, min, max);
|
||||
}
|
||||
mid_v3_v3v3(cent, min, max);
|
||||
}
|
||||
|
||||
mid_v3_v3v3(cent, min, max);
|
||||
}
|
||||
|
||||
/* Do the adjustments */
|
||||
@@ -458,16 +469,16 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode)
|
||||
}
|
||||
|
||||
/* Turn the list into an armature */
|
||||
ED_armature_from_edit(ob);
|
||||
|
||||
if(obedit==NULL) {
|
||||
ED_armature_from_edit(ob);
|
||||
ED_armature_edit_free(ob);
|
||||
}
|
||||
|
||||
/* Adjust object location for new centerpoint */
|
||||
if(centermode && obedit==NULL) {
|
||||
mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */
|
||||
add_v3_v3(ob->loc, cent);
|
||||
}
|
||||
else {
|
||||
ED_armature_edit_free(ob);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------- */
|
||||
@@ -2018,7 +2029,6 @@ void ED_armature_edit_free(struct Object *ob)
|
||||
|
||||
BLI_freelistN(arm->edbo);
|
||||
}
|
||||
|
||||
MEM_freeN(arm->edbo);
|
||||
arm->edbo= NULL;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
|
||||
|
||||
void transform_armature_mirror_update(struct Object *obedit);
|
||||
void clear_armature(struct Scene *scene, struct Object *ob, char mode);
|
||||
void docenter_armature (struct Scene *scene, struct View3D *v3d, struct Object *ob, int centermode);
|
||||
void docenter_armature (struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
|
||||
|
||||
void ED_armature_apply_transform(struct Object *ob, float mat[4][4]);
|
||||
|
||||
|
||||
@@ -694,81 +694,73 @@ void texspace_edit(Scene *scene, View3D *v3d)
|
||||
|
||||
/********************* Set Object Center ************************/
|
||||
|
||||
static EnumPropertyItem prop_set_center_types[] = {
|
||||
{0, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"},
|
||||
{1, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Move object origin to center of object geometry"},
|
||||
{2, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3d cursor"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
enum {
|
||||
GEOMETRY_TO_ORIGIN=0,
|
||||
ORIGIN_TO_GEOMETRY,
|
||||
ORIGIN_TO_CURSOR
|
||||
};
|
||||
|
||||
/* 0 == do center, 1 == center new, 2 == center cursor */
|
||||
static int object_origin_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
Object *tob;
|
||||
Mesh *me, *tme;
|
||||
Curve *cu;
|
||||
/* BezTriple *bezt;
|
||||
BPoint *bp; */
|
||||
Nurb *nu, *nu1;
|
||||
EditVert *eve;
|
||||
float cent[3], centn[3], min[3], max[3];
|
||||
int a, total= 0;
|
||||
float cursor[3], cent[3], cent_neg[3], centn[3], min[3], max[3];
|
||||
int centermode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
int around = RNA_enum_get(op->ptr, "center"); /* initialized from v3d->around */
|
||||
|
||||
/* keep track of what is changed */
|
||||
int tot_change=0, tot_lib_error=0, tot_multiuser_arm_error=0;
|
||||
MVert *mvert;
|
||||
|
||||
if(scene->id.lib || v3d==NULL){
|
||||
BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed on Lib data");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
if (obedit && centermode > 0) {
|
||||
if (obedit && centermode != GEOMETRY_TO_ORIGIN) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
zero_v3(cent);
|
||||
|
||||
if(obedit) {
|
||||
else {
|
||||
/* get the view settings if 'around' isnt set and the view is available */
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
copy_v3_v3(cursor, give_cursor(scene, v3d));
|
||||
if(v3d && !RNA_property_is_set(op->ptr, "around"))
|
||||
around= v3d->around;
|
||||
}
|
||||
|
||||
zero_v3(cent);
|
||||
|
||||
if(obedit) {
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
|
||||
if(obedit->type==OB_MESH) {
|
||||
Mesh *me= obedit->data;
|
||||
EditMesh *em = BKE_mesh_get_editmesh(me);
|
||||
EditVert *eve;
|
||||
|
||||
for(eve= em->verts.first; eve; eve= eve->next) {
|
||||
if(v3d->around==V3D_CENTROID) {
|
||||
if(around==V3D_CENTROID) {
|
||||
int total= 0;
|
||||
for(eve= em->verts.first; eve; eve= eve->next) {
|
||||
total++;
|
||||
add_v3_v3(cent, eve->co);
|
||||
}
|
||||
else {
|
||||
DO_MINMAX(eve->co, min, max);
|
||||
}
|
||||
}
|
||||
|
||||
if(v3d->around==V3D_CENTROID) {
|
||||
mul_v3_fl(cent, 1.0f/(float)total);
|
||||
}
|
||||
else {
|
||||
for(eve= em->verts.first; eve; eve= eve->next) {
|
||||
DO_MINMAX(eve->co, min, max);
|
||||
}
|
||||
mid_v3_v3v3(cent, min, max);
|
||||
}
|
||||
|
||||
|
||||
for(eve= em->verts.first; eve; eve= eve->next) {
|
||||
sub_v3_v3(eve->co, cent);
|
||||
sub_v3_v3(eve->co, cent);
|
||||
}
|
||||
|
||||
|
||||
recalc_editnormals(em);
|
||||
tot_change++;
|
||||
DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
|
||||
BKE_mesh_end_editmesh(me, em);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* reset flags */
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
ob->flag &= ~OB_DONE;
|
||||
@@ -779,190 +771,93 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
|
||||
if(tob->data)
|
||||
((ID *)tob->data)->flag &= ~LIB_DOIT;
|
||||
}
|
||||
|
||||
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
if((ob->flag & OB_DONE)==0) {
|
||||
ob->flag |= OB_DONE;
|
||||
|
||||
if(obedit==NULL && (me=get_mesh(ob)) ) {
|
||||
if (me->id.lib) {
|
||||
tot_lib_error++;
|
||||
} else {
|
||||
if(centermode==2) {
|
||||
copy_v3_v3(cent, give_cursor(scene, v3d));
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_m4_v3(ob->imat, cent);
|
||||
} else {
|
||||
INIT_MINMAX(min, max);
|
||||
mvert= me->mvert;
|
||||
for(a=0; a<me->totvert; a++, mvert++) {
|
||||
DO_MINMAX(mvert->co, min, max);
|
||||
}
|
||||
|
||||
mid_v3_v3v3(cent, min, max);
|
||||
}
|
||||
if(ob->data == NULL) {
|
||||
/* pass */
|
||||
}
|
||||
else if (((ID *)ob->data)->lib) {
|
||||
tot_lib_error++;
|
||||
}
|
||||
|
||||
mvert= me->mvert;
|
||||
for(a=0; a<me->totvert; a++, mvert++) {
|
||||
sub_v3_v3(mvert->co, cent);
|
||||
}
|
||||
|
||||
if (me->key) {
|
||||
KeyBlock *kb;
|
||||
for (kb=me->key->block.first; kb; kb=kb->next) {
|
||||
float *fp= kb->data;
|
||||
|
||||
for (a=0; a<kb->totelem; a++, fp+=3) {
|
||||
sub_v3_v3(fp, cent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(obedit==NULL && ob->type==OB_MESH) {
|
||||
Mesh *me= ob->data;
|
||||
|
||||
tot_change++;
|
||||
me->id.flag |= LIB_DOIT;
|
||||
|
||||
if(centermode) {
|
||||
copy_v3_v3(centn, cent);
|
||||
mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */
|
||||
add_v3_v3(ob->loc, centn);
|
||||
|
||||
where_is_object(scene, ob);
|
||||
ignore_parent_tx(bmain, scene, ob);
|
||||
|
||||
/* other users? */
|
||||
CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) {
|
||||
if((ob_other->flag & OB_DONE)==0) {
|
||||
tme= get_mesh(ob_other);
|
||||
|
||||
if(tme==me) {
|
||||
|
||||
ob_other->flag |= OB_DONE;
|
||||
ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA;
|
||||
|
||||
copy_v3_v3(centn, cent);
|
||||
mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */
|
||||
add_v3_v3(ob_other->loc, centn);
|
||||
|
||||
where_is_object(scene, ob_other);
|
||||
ignore_parent_tx(bmain, scene, ob_other);
|
||||
|
||||
if(!(tme->id.flag & LIB_DOIT)) {
|
||||
mvert= tme->mvert;
|
||||
for(a=0; a<tme->totvert; a++, mvert++) {
|
||||
sub_v3_v3(mvert->co, cent);
|
||||
}
|
||||
|
||||
if (tme->key) {
|
||||
KeyBlock *kb;
|
||||
for (kb=tme->key->block.first; kb; kb=kb->next) {
|
||||
float *fp= kb->data;
|
||||
|
||||
for (a=0; a<kb->totelem; a++, fp+=3) {
|
||||
sub_v3_v3(fp, cent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tot_change++;
|
||||
tme->id.flag |= LIB_DOIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
}
|
||||
if(centermode == ORIGIN_TO_CURSOR) {
|
||||
copy_v3_v3(cent, cursor);
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_m4_v3(ob->imat, cent);
|
||||
} else {
|
||||
if(around==V3D_CENTROID)
|
||||
mesh_center_median(me, cent);
|
||||
else
|
||||
mesh_center_bounds(me, cent);
|
||||
}
|
||||
|
||||
negate_v3_v3(cent_neg, cent);
|
||||
mesh_translate(me, cent_neg, 1);
|
||||
|
||||
tot_change++;
|
||||
me->id.flag |= LIB_DOIT;
|
||||
}
|
||||
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
||||
|
||||
/* weak code here... (ton) */
|
||||
if(obedit==ob) {
|
||||
ListBase *editnurb= curve_get_editcurve(obedit);
|
||||
Curve *cu= ob->data;
|
||||
|
||||
nu1= editnurb->first;
|
||||
cu= obedit->data;
|
||||
if(centermode == ORIGIN_TO_CURSOR) {
|
||||
copy_v3_v3(cent, cursor);
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_m4_v3(ob->imat, cent);
|
||||
}
|
||||
else {
|
||||
cu= ob->data;
|
||||
nu1= cu->nurb.first;
|
||||
if(around==V3D_CENTROID)
|
||||
curve_center_median(cu, cent);
|
||||
else
|
||||
curve_center_bounds(cu, cent);
|
||||
}
|
||||
|
||||
if (cu->id.lib) {
|
||||
tot_lib_error++;
|
||||
} else {
|
||||
if(centermode==2) {
|
||||
copy_v3_v3(cent, give_cursor(scene, v3d));
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_m4_v3(ob->imat, cent);
|
||||
|
||||
/* don't allow Z change if curve is 2D */
|
||||
if( !( cu->flag & CU_3D ) )
|
||||
cent[2] = 0.0;
|
||||
}
|
||||
else {
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
nu= nu1;
|
||||
while(nu) {
|
||||
minmaxNurb(nu, min, max);
|
||||
nu= nu->next;
|
||||
}
|
||||
|
||||
mid_v3_v3v3(cent, min, max);
|
||||
}
|
||||
|
||||
nu= nu1;
|
||||
while(nu) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
a= nu->pntsu;
|
||||
while (a--) {
|
||||
sub_v3_v3(nu->bezt[a].vec[0], cent);
|
||||
sub_v3_v3(nu->bezt[a].vec[1], cent);
|
||||
sub_v3_v3(nu->bezt[a].vec[2], cent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
a= nu->pntsu*nu->pntsv;
|
||||
while (a--)
|
||||
sub_v3_v3(nu->bp[a].vec, cent);
|
||||
}
|
||||
nu= nu->next;
|
||||
}
|
||||
|
||||
if(centermode && obedit==NULL) {
|
||||
mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */
|
||||
add_v3_v3(ob->loc, cent);
|
||||
where_is_object(scene, ob);
|
||||
ignore_parent_tx(bmain, scene, ob);
|
||||
}
|
||||
|
||||
tot_change++;
|
||||
cu->id.flag |= LIB_DOIT;
|
||||
/* don't allow Z change if curve is 2D */
|
||||
if( !( cu->flag & CU_3D ) )
|
||||
cent[2] = 0.0;
|
||||
|
||||
if(obedit) {
|
||||
if (centermode==0) {
|
||||
DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
|
||||
}
|
||||
break;
|
||||
negate_v3_v3(cent_neg, cent);
|
||||
curve_translate(cu, cent_neg, 1);
|
||||
|
||||
tot_change++;
|
||||
cu->id.flag |= LIB_DOIT;
|
||||
|
||||
if(obedit) {
|
||||
if (centermode == GEOMETRY_TO_ORIGIN) {
|
||||
DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(ob->type==OB_FONT) {
|
||||
/* get from bb */
|
||||
|
||||
cu= ob->data;
|
||||
|
||||
if(cu->bb==NULL) {
|
||||
|
||||
Curve *cu= ob->data;
|
||||
|
||||
if(cu->bb==NULL && (centermode != ORIGIN_TO_CURSOR)) {
|
||||
/* do nothing*/
|
||||
} else if (cu->id.lib) {
|
||||
tot_lib_error++;
|
||||
} else {
|
||||
cu->xof= -0.5f*( cu->bb->vec[4][0] - cu->bb->vec[0][0]);
|
||||
cu->yof= -0.5f -0.5f*( cu->bb->vec[0][1] - cu->bb->vec[2][1]); /* extra 0.5 is the height o above line */
|
||||
|
||||
/* not really ok, do this better once! */
|
||||
cu->xof /= cu->fsize;
|
||||
cu->yof /= cu->fsize;
|
||||
}
|
||||
else {
|
||||
if(centermode == ORIGIN_TO_CURSOR) {
|
||||
copy_v3_v3(cent, cursor);
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_m4_v3(ob->imat, cent);
|
||||
}
|
||||
else {
|
||||
cent[0]= 0.5f * ( cu->bb->vec[4][0] + cu->bb->vec[0][0]);
|
||||
cent[1]= 0.5f * ( cu->bb->vec[0][1] + cu->bb->vec[2][1]) - 0.5f; /* extra 0.5 is the height o above line */
|
||||
}
|
||||
|
||||
cent[2]= 0.0f;
|
||||
|
||||
cu->xof= cu->xof - (cent[0] / cu->fsize);
|
||||
cu->yof= cu->yof - (cent[1] / cu->fsize);
|
||||
|
||||
tot_change++;
|
||||
cu->id.flag |= LIB_DOIT;
|
||||
@@ -970,29 +865,58 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
else if(ob->type==OB_ARMATURE) {
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
if (arm->id.lib) {
|
||||
tot_lib_error++;
|
||||
} else if(ID_REAL_USERS(arm) > 1) {
|
||||
|
||||
if(ID_REAL_USERS(arm) > 1) {
|
||||
/*BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature");
|
||||
return;*/
|
||||
tot_multiuser_arm_error++;
|
||||
} else {
|
||||
/* Function to recenter armatures in editarmature.c
|
||||
}
|
||||
else {
|
||||
/* Function to recenter armatures in editarmature.c
|
||||
* Bone + object locations are handled there.
|
||||
*/
|
||||
docenter_armature(scene, v3d, ob, centermode);
|
||||
docenter_armature(scene, ob, cursor, centermode, around);
|
||||
|
||||
tot_change++;
|
||||
cu->id.flag |= LIB_DOIT;
|
||||
|
||||
arm->id.flag |= LIB_DOIT;
|
||||
|
||||
where_is_object(scene, ob);
|
||||
ignore_parent_tx(bmain, scene, ob);
|
||||
|
||||
if(obedit)
|
||||
|
||||
if(obedit)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* offset other selected objects */
|
||||
if(centermode != GEOMETRY_TO_ORIGIN) {
|
||||
/* was the object data modified
|
||||
* note: the functions above must set 'cent' */
|
||||
if(ob->data && (((ID *)ob->data)->flag && LIB_DOIT) && ob->type != OB_ARMATURE) {
|
||||
copy_v3_v3(centn, cent);
|
||||
mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */
|
||||
add_v3_v3(ob->loc, centn);
|
||||
|
||||
where_is_object(scene, ob);
|
||||
ignore_parent_tx(bmain, scene, ob);
|
||||
|
||||
/* other users? */
|
||||
CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) {
|
||||
if((ob_other->flag & OB_DONE)==0 && (ob_other->data == ob->data)) {
|
||||
ob_other->flag |= OB_DONE;
|
||||
ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA;
|
||||
|
||||
copy_v3_v3(centn, cent);
|
||||
mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */
|
||||
add_v3_v3(ob_other->loc, centn);
|
||||
|
||||
where_is_object(scene, ob_other);
|
||||
ignore_parent_tx(bmain, scene, ob_other);
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
@@ -1002,26 +926,39 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
|
||||
tob->recalc= OB_RECALC_OB|OB_RECALC_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tot_change) {
|
||||
DAG_ids_flush_update(0);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Warn if any errors occurred */
|
||||
if (tot_lib_error+tot_multiuser_arm_error) {
|
||||
BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:",tot_lib_error+tot_multiuser_arm_error, tot_change);
|
||||
BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:",tot_lib_error+tot_multiuser_arm_error, tot_change);
|
||||
if (tot_lib_error)
|
||||
BKE_reportf(op->reports, RPT_WARNING, "|%i linked library objects",tot_lib_error);
|
||||
if (tot_multiuser_arm_error)
|
||||
BKE_reportf(op->reports, RPT_WARNING, "|%i multiuser armature object(s)",tot_multiuser_arm_error);
|
||||
}
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_origin_set(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem prop_set_center_types[] = {
|
||||
{GEOMETRY_TO_ORIGIN, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"},
|
||||
{ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Move object origin to center of object geometry"},
|
||||
{ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3d cursor"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem prop_set_bounds_types[] = {
|
||||
{V3D_CENTROID, "MEDIAN", 0, "Median Center", ""},
|
||||
{V3D_CENTER, "BOUNDS", 0, "Bounds Center", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Set Origin";
|
||||
ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3d cursor";
|
||||
@@ -1031,12 +968,12 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
|
||||
ot->invoke= WM_menu_invoke;
|
||||
ot->exec= object_origin_set_exec;
|
||||
|
||||
ot->poll= ED_operator_view3d_active;
|
||||
ot->poll= ED_operator_scene_editable;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
ot->prop= RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
|
||||
|
||||
RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_CENTROID, "Center", "");
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int l
|
||||
return;
|
||||
}
|
||||
|
||||
VECCOPY(vec4, vec);
|
||||
copy_v3_v3(vec4, vec);
|
||||
vec4[3]= 1.0;
|
||||
|
||||
mul_m4_v4(rv3d->persmatob, vec4);
|
||||
@@ -175,7 +175,7 @@ static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr)
|
||||
|
||||
adr[0]= IS_CLIPPED;
|
||||
|
||||
VECCOPY(vec4, vec);
|
||||
copy_v3_v3(vec4, vec);
|
||||
vec4[3]= 1.0;
|
||||
|
||||
mul_m4_v4(rv3d->persmatob, vec4);
|
||||
@@ -1146,7 +1146,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
||||
|
||||
/* and back to viewspace */
|
||||
glLoadMatrixf(rv3d->viewmat);
|
||||
VECCOPY(vec, ob->obmat[3]);
|
||||
copy_v3_v3(vec, ob->obmat[3]);
|
||||
|
||||
setlinestyle(0);
|
||||
|
||||
@@ -3257,7 +3257,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
|
||||
case PART_DRAW_DOT:
|
||||
{
|
||||
if(vd) {
|
||||
VECCOPY(vd,state->co) pdd->vd+=3;
|
||||
copy_v3_v3(vd,state->co); pdd->vd+=3;
|
||||
}
|
||||
if(cd) {
|
||||
cd[0]=ma_r;
|
||||
@@ -3282,7 +3282,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
|
||||
cd[14]=cd[17]=1.0;
|
||||
pdd->cd+=18;
|
||||
|
||||
VECCOPY(vec2,state->co);
|
||||
copy_v3_v3(vec2,state->co);
|
||||
}
|
||||
else {
|
||||
if(cd) {
|
||||
@@ -3291,47 +3291,47 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
|
||||
cd[2]=cd[5]=cd[8]=cd[11]=cd[14]=cd[17]=ma_b;
|
||||
pdd->cd+=18;
|
||||
}
|
||||
VECSUB(vec2,state->co,vec);
|
||||
sub_v3_v3v3(vec2, state->co, vec);
|
||||
}
|
||||
|
||||
VECADD(vec,state->co,vec);
|
||||
VECCOPY(pdd->vd,vec); pdd->vd+=3;
|
||||
VECCOPY(pdd->vd,vec2); pdd->vd+=3;
|
||||
add_v3_v3(vec, state->co);
|
||||
copy_v3_v3(pdd->vd,vec); pdd->vd+=3;
|
||||
copy_v3_v3(pdd->vd,vec2); pdd->vd+=3;
|
||||
|
||||
vec[1]=2.0f*pixsize;
|
||||
vec[0]=vec[2]=0.0;
|
||||
mul_qt_v3(state->rot,vec);
|
||||
if(draw_as==PART_DRAW_AXIS){
|
||||
VECCOPY(vec2,state->co);
|
||||
copy_v3_v3(vec2,state->co);
|
||||
}
|
||||
else VECSUB(vec2,state->co,vec);
|
||||
else sub_v3_v3v3(vec2, state->co, vec);
|
||||
|
||||
VECADD(vec,state->co,vec);
|
||||
VECCOPY(pdd->vd,vec); pdd->vd+=3;
|
||||
VECCOPY(pdd->vd,vec2); pdd->vd+=3;
|
||||
add_v3_v3(vec, state->co);
|
||||
copy_v3_v3(pdd->vd,vec); pdd->vd+=3;
|
||||
copy_v3_v3(pdd->vd,vec2); pdd->vd+=3;
|
||||
|
||||
vec[2]=2.0f*pixsize;
|
||||
vec[0]=vec[1]=0.0;
|
||||
mul_qt_v3(state->rot,vec);
|
||||
if(draw_as==PART_DRAW_AXIS){
|
||||
VECCOPY(vec2,state->co);
|
||||
copy_v3_v3(vec2,state->co);
|
||||
}
|
||||
else VECSUB(vec2,state->co,vec);
|
||||
else sub_v3_v3v3(vec2, state->co, vec);
|
||||
|
||||
VECADD(vec,state->co,vec);
|
||||
add_v3_v3(vec, state->co);
|
||||
|
||||
VECCOPY(pdd->vd,vec); pdd->vd+=3;
|
||||
VECCOPY(pdd->vd,vec2); pdd->vd+=3;
|
||||
copy_v3_v3(pdd->vd,vec); pdd->vd+=3;
|
||||
copy_v3_v3(pdd->vd,vec2); pdd->vd+=3;
|
||||
break;
|
||||
}
|
||||
case PART_DRAW_LINE:
|
||||
{
|
||||
VECCOPY(vec,state->vel);
|
||||
copy_v3_v3(vec,state->vel);
|
||||
normalize_v3(vec);
|
||||
if(draw & PART_DRAW_VEL_LENGTH)
|
||||
mul_v3_fl(vec,len_v3(state->vel));
|
||||
VECADDFAC(pdd->vd,state->co,vec,-draw_line[0]); pdd->vd+=3;
|
||||
VECADDFAC(pdd->vd,state->co,vec,draw_line[1]); pdd->vd+=3;
|
||||
madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd+=3;
|
||||
madd_v3_v3v3fl(pdd->vd, state->co, vec, draw_line[1]); pdd->vd+=3;
|
||||
if(cd) {
|
||||
cd[0]=cd[3]=ma_r;
|
||||
cd[1]=cd[4]=ma_g;
|
||||
@@ -3358,27 +3358,27 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
|
||||
}
|
||||
|
||||
|
||||
VECCOPY(bb->vec, state->co);
|
||||
VECCOPY(bb->vel, state->vel);
|
||||
copy_v3_v3(bb->vec, state->co);
|
||||
copy_v3_v3(bb->vel, state->vel);
|
||||
|
||||
psys_make_billboard(bb, xvec, yvec, zvec, bb_center);
|
||||
|
||||
VECADD(pdd->vd,bb_center,xvec);
|
||||
VECADD(pdd->vd,pdd->vd,yvec); pdd->vd+=3;
|
||||
add_v3_v3v3(pdd->vd, bb_center, xvec);
|
||||
add_v3_v3(pdd->vd, yvec); pdd->vd+=3;
|
||||
|
||||
VECSUB(pdd->vd,bb_center,xvec);
|
||||
VECADD(pdd->vd,pdd->vd,yvec); pdd->vd+=3;
|
||||
sub_v3_v3v3(pdd->vd, bb_center, vec);
|
||||
add_v3_v3(pdd->vd, yvec); pdd->vd+=3;
|
||||
|
||||
VECSUB(pdd->vd,bb_center,xvec);
|
||||
VECSUB(pdd->vd,pdd->vd,yvec); pdd->vd+=3;
|
||||
sub_v3_v3v3(pdd->vd, bb_center, xvec);
|
||||
sub_v3_v3v3(pdd->vd, pdd->vd,yvec); pdd->vd+=3;
|
||||
|
||||
VECADD(pdd->vd,bb_center,xvec);
|
||||
VECSUB(pdd->vd,pdd->vd,yvec); pdd->vd+=3;
|
||||
add_v3_v3v3(pdd->vd, bb_center, xvec);
|
||||
sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd+=3;
|
||||
|
||||
VECCOPY(pdd->nd, zvec); pdd->nd+=3;
|
||||
VECCOPY(pdd->nd, zvec); pdd->nd+=3;
|
||||
VECCOPY(pdd->nd, zvec); pdd->nd+=3;
|
||||
VECCOPY(pdd->nd, zvec); pdd->nd+=3;
|
||||
copy_v3_v3(pdd->nd, zvec); pdd->nd+=3;
|
||||
copy_v3_v3(pdd->nd, zvec); pdd->nd+=3;
|
||||
copy_v3_v3(pdd->nd, zvec); pdd->nd+=3;
|
||||
copy_v3_v3(pdd->nd, zvec); pdd->nd+=3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3787,11 +3787,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
|
||||
/* additional things to draw for each particle */
|
||||
/* (velocity, size and number) */
|
||||
if((part->draw & PART_DRAW_VEL) && pdd->vedata){
|
||||
VECCOPY(pdd->ved,state.co);
|
||||
pdd->ved+=3;
|
||||
VECCOPY(vel,state.vel);
|
||||
mul_v3_fl(vel,timestep);
|
||||
VECADD(pdd->ved,state.co,vel);
|
||||
copy_v3_v3(pdd->ved,state.co);
|
||||
pdd->ved += 3;
|
||||
mul_v3_v3fl(vel, state.vel, timestep);
|
||||
add_v3_v3v3(pdd->ved, state.co, vel);
|
||||
pdd->ved+=3;
|
||||
|
||||
totve++;
|
||||
@@ -4069,7 +4068,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj
|
||||
|
||||
if(timed) {
|
||||
for(k=0, pcol=pathcol, pkey=path; k<steps; k++, pkey++, pcol+=4){
|
||||
VECCOPY(pcol, pkey->col);
|
||||
copy_v3_v3(pcol, pkey->col);
|
||||
pcol[3] = 1.0f - fabs((float)CFRA - pkey->time)/(float)pset->fade_frames;
|
||||
}
|
||||
|
||||
@@ -4107,15 +4106,15 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obj
|
||||
|
||||
for(k=0, key=point->keys; k<point->totkey; k++, key++){
|
||||
if(pd) {
|
||||
VECCOPY(pd, key->co);
|
||||
copy_v3_v3(pd, key->co);
|
||||
pd += 3;
|
||||
}
|
||||
|
||||
if(key->flag&PEK_SELECT){
|
||||
VECCOPY(cd,sel_col);
|
||||
copy_v3_v3(cd,sel_col);
|
||||
}
|
||||
else{
|
||||
VECCOPY(cd,nosel_col);
|
||||
copy_v3_v3(cd,nosel_col);
|
||||
}
|
||||
|
||||
if(timed)
|
||||
@@ -4189,12 +4188,12 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[1] = root[2] = 0.0f;
|
||||
root[0] = -drw_size;
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
tip[1] = tip[2] = 0.0f;
|
||||
tip[0] = drw_size;
|
||||
mul_m3_v3(tr,tip);
|
||||
VECADD(tip,tip,com);
|
||||
add_v3_v3(tip, com);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
|
||||
@@ -4202,7 +4201,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[0] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4211,7 +4210,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[0] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4220,7 +4219,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[0] =th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4229,7 +4228,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[0] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4240,12 +4239,12 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[0] = root[2] = 0.0f;
|
||||
root[1] = -drw_size;
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
tip[0] = tip[2] = 0.0f;
|
||||
tip[1] = drw_size;
|
||||
mul_m3_v3(tr,tip);
|
||||
VECADD(tip,tip,com);
|
||||
add_v3_v3(tip, com);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
|
||||
@@ -4253,7 +4252,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[1] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4262,7 +4261,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[1] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4271,7 +4270,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[1] =th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4280,7 +4279,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[1] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4290,12 +4289,12 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[0] = root[1] = 0.0f;
|
||||
root[2] = -drw_size;
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
tip[0] = tip[1] = 0.0f;
|
||||
tip[2] = drw_size;
|
||||
mul_m3_v3(tr,tip);
|
||||
VECADD(tip,tip,com);
|
||||
add_v3_v3(tip, com);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
|
||||
@@ -4303,7 +4302,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[2] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4312,7 +4311,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[2] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4321,7 +4320,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[2] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4330,7 +4329,7 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
|
||||
root[2] = th;
|
||||
glBegin(GL_LINES);
|
||||
mul_m3_v3(tr,root);
|
||||
VECADD(root,root,com);
|
||||
add_v3_v3(root, com);
|
||||
glVertex3fv(root);
|
||||
glVertex3fv(tip);
|
||||
glEnd();
|
||||
@@ -4869,12 +4868,10 @@ static void drawspiral(float *cent, float rad, float tmat[][4], int start)
|
||||
start *= -1;
|
||||
}
|
||||
|
||||
VECCOPY(vx, tmat[0]);
|
||||
VECCOPY(vy, tmat[1]);
|
||||
mul_v3_fl(vx, rad);
|
||||
mul_v3_fl(vy, rad);
|
||||
mul_v3_v3fl(vx, tmat[0], rad);
|
||||
mul_v3_v3fl(vy, tmat[1], rad);
|
||||
|
||||
VECCOPY(vec, cent);
|
||||
copy_v3_v3(vec, cent);
|
||||
|
||||
if (inverse==0) {
|
||||
for(a=0; a<tot; a++) {
|
||||
@@ -5147,7 +5144,7 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d)
|
||||
UI_ThemeColorBlend(curcol, TH_BACK, 0.5);
|
||||
drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat);
|
||||
|
||||
VECCOPY(vec, guidevec1); /* max center */
|
||||
copy_v3_v3(vec, guidevec1); /* max center */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5326,13 +5323,13 @@ static void drawtexspace(Object *ob)
|
||||
}
|
||||
else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
|
||||
Curve *cu= ob->data;
|
||||
VECCOPY(size, cu->size);
|
||||
VECCOPY(loc, cu->loc);
|
||||
copy_v3_v3(size, cu->size);
|
||||
copy_v3_v3(loc, cu->loc);
|
||||
}
|
||||
else if(ob->type==OB_MBALL) {
|
||||
MetaBall *mb= ob->data;
|
||||
VECCOPY(size, mb->size);
|
||||
VECCOPY(loc, mb->loc);
|
||||
copy_v3_v3(size, mb->size);
|
||||
copy_v3_v3(loc, mb->loc);
|
||||
}
|
||||
else return;
|
||||
|
||||
@@ -5781,8 +5778,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
|
||||
if (cu->linewidth != 0.0) {
|
||||
cpack(0xff44ff);
|
||||
UI_ThemeColor(TH_WIRE);
|
||||
VECCOPY(vec1, ob->orig);
|
||||
VECCOPY(vec2, ob->orig);
|
||||
copy_v3_v3(vec1, ob->orig);
|
||||
copy_v3_v3(vec2, ob->orig);
|
||||
vec1[0] += cu->linewidth;
|
||||
vec2[0] += cu->linewidth;
|
||||
vec1[1] += cu->linedist * cu->fsize;
|
||||
@@ -6071,7 +6068,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
|
||||
if(density[index] > FLT_EPSILON)
|
||||
{
|
||||
float color[3];
|
||||
VECCOPY(tmp, smd->domain->p0);
|
||||
copy_v3_v3(tmp, smd->domain->p0);
|
||||
tmp[0] += smd->domain->dx * x + smd->domain->dx * 0.5;
|
||||
tmp[1] += smd->domain->dx * y + smd->domain->dx * 0.5;
|
||||
tmp[2] += smd->domain->dx * z + smd->domain->dx * 0.5;
|
||||
|
||||
Reference in New Issue
Block a user