Merge branch 'blender-v2.83-release'
This commit is contained in:
commit
498bd0772e
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_math_inline.h"
|
||||
#include "BLI_sys_types.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifndef M_PI
|
||||
|
|
|
@ -359,6 +359,14 @@ MINLINE int divide_floor_i(int a, int b)
|
|||
return r ? d - ((a < 0) ^ (b < 0)) : d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer division that ceils the result, instead of flooring like normal C division.
|
||||
*/
|
||||
MINLINE uint divide_ceil_u(uint a, uint b)
|
||||
{
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
|
||||
/**
|
||||
* modulo that handles negative numbers, works the same as Python's.
|
||||
*/
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_fnmatch.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLO_readfile.h"
|
||||
|
@ -758,11 +759,11 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *region)
|
|||
layout->attribute_column_header_h = 0;
|
||||
layout->offset_top = 0;
|
||||
if (layout->flow_columns > 0) {
|
||||
layout->rows = numfiles / layout->flow_columns + 1; // XXX dirty, modulo is zero
|
||||
layout->rows = divide_ceil_u(numfiles, layout->flow_columns);
|
||||
}
|
||||
else {
|
||||
layout->flow_columns = 1;
|
||||
layout->rows = numfiles + 1; // XXX dirty, modulo is zero
|
||||
layout->rows = numfiles;
|
||||
}
|
||||
layout->height = sfile->layout->rows * (layout->tile_h + 2 * layout->tile_border_y) +
|
||||
layout->tile_border_y * 2 - layout->offset_top;
|
||||
|
@ -807,11 +808,11 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *region)
|
|||
file_attribute_columns_init(params, layout);
|
||||
|
||||
if (layout->rows > 0) {
|
||||
layout->flow_columns = numfiles / layout->rows + 1; // XXX dirty, modulo is zero
|
||||
layout->flow_columns = divide_ceil_u(numfiles, layout->rows);
|
||||
}
|
||||
else {
|
||||
layout->rows = 1;
|
||||
layout->flow_columns = numfiles + 1; // XXX dirty, modulo is zero
|
||||
layout->flow_columns = numfiles;
|
||||
}
|
||||
layout->width = sfile->layout->flow_columns * (layout->tile_w + 2 * layout->tile_border_x) +
|
||||
layout->tile_border_x * 2;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "BKE_lib_query.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
@ -66,13 +67,35 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
|
|||
BKE_gpencil_modifier_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void update_position(Object *ob, MirrorGpencilModifierData *mmd, bGPDstroke *gps, int axis)
|
||||
/* Mirror is using current object as origin. */
|
||||
static void update_mirror_local(Object *ob, bGPDstroke *gps, int axis)
|
||||
{
|
||||
int i;
|
||||
bGPDspoint *pt;
|
||||
float factor[3] = {1.0f, 1.0f, 1.0f};
|
||||
factor[axis] = -1.0f;
|
||||
|
||||
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
||||
mul_v3_v3(&pt->x, factor);
|
||||
}
|
||||
}
|
||||
|
||||
/* Mirror is using other object as origin. */
|
||||
static void update_mirror_object(Object *ob,
|
||||
MirrorGpencilModifierData *mmd,
|
||||
bGPDstroke *gps,
|
||||
int axis)
|
||||
{
|
||||
/* Calculate local matrix transformation. */
|
||||
float mat[3][3], inv_mat[3][3];
|
||||
BKE_object_to_mat3(ob, mat);
|
||||
invert_m3_m3(inv_mat, mat);
|
||||
|
||||
int i;
|
||||
bGPDspoint *pt;
|
||||
float factor[3] = {1.0f, 1.0f, 1.0f};
|
||||
factor[axis] = -1.0f;
|
||||
|
||||
float clear[3] = {0.0f, 0.0f, 0.0f};
|
||||
clear[axis] = 1.0f;
|
||||
|
||||
|
@ -81,34 +104,44 @@ static void update_position(Object *ob, MirrorGpencilModifierData *mmd, bGPDstro
|
|||
float half_origin[3];
|
||||
float rot_mat[3][3];
|
||||
|
||||
if (mmd->object) {
|
||||
float eul[3];
|
||||
mat4_to_eul(eul, mmd->object->obmat);
|
||||
mul_v3_fl(eul, 2.0f);
|
||||
eul_to_mat3(rot_mat, eul);
|
||||
sub_v3_v3v3(ob_origin, ob->obmat[3], mmd->object->obmat[3]);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(ob_origin, ob->obmat[3]);
|
||||
}
|
||||
float eul[3];
|
||||
mat4_to_eul(eul, mmd->object->obmat);
|
||||
mul_v3_fl(eul, 2.0f);
|
||||
eul_to_mat3(rot_mat, eul);
|
||||
sub_v3_v3v3(ob_origin, ob->obmat[3], mmd->object->obmat[3]);
|
||||
|
||||
/* only works with current axis */
|
||||
/* Only works with current axis. */
|
||||
mul_v3_v3(ob_origin, clear);
|
||||
|
||||
/* Invert the origin. */
|
||||
mul_v3_v3fl(pt_origin, ob_origin, -2.0f);
|
||||
mul_v3_v3fl(half_origin, pt_origin, 0.5f);
|
||||
|
||||
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
||||
mul_v3_v3(&pt->x, factor);
|
||||
if (mmd->object) {
|
||||
/* apply location */
|
||||
add_v3_v3(&pt->x, pt_origin);
|
||||
/* Apply any local transformation. */
|
||||
mul_m3_v3(mat, &pt->x);
|
||||
|
||||
/* apply rotation (around new center) */
|
||||
sub_v3_v3(&pt->x, half_origin);
|
||||
mul_m3_v3(rot_mat, &pt->x);
|
||||
add_v3_v3(&pt->x, half_origin);
|
||||
}
|
||||
/* Apply mirror effect. */
|
||||
mul_v3_v3(&pt->x, factor);
|
||||
/* Apply location. */
|
||||
add_v3_v3(&pt->x, pt_origin);
|
||||
/* Apply rotation (around new center). */
|
||||
sub_v3_v3(&pt->x, half_origin);
|
||||
mul_m3_v3(rot_mat, &pt->x);
|
||||
add_v3_v3(&pt->x, half_origin);
|
||||
|
||||
/* Undo local transformation to avoid double transform in drawing. */
|
||||
mul_m3_v3(inv_mat, &pt->x);
|
||||
}
|
||||
}
|
||||
|
||||
static void update_position(Object *ob, MirrorGpencilModifierData *mmd, bGPDstroke *gps, int axis)
|
||||
{
|
||||
if (mmd->object == NULL) {
|
||||
update_mirror_local(ob, gps, axis);
|
||||
}
|
||||
else {
|
||||
update_mirror_object(ob, mmd, gps, axis);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue