WIP: Vulkan: Workbench #107886
|
@ -59,7 +59,13 @@ void device_metal_info(vector<DeviceInfo> &devices)
|
||||||
|
|
||||||
info.has_nanovdb = vendor == METAL_GPU_APPLE;
|
info.has_nanovdb = vendor == METAL_GPU_APPLE;
|
||||||
info.has_light_tree = vendor != METAL_GPU_AMD;
|
info.has_light_tree = vendor != METAL_GPU_AMD;
|
||||||
|
|
||||||
info.use_hardware_raytracing = vendor != METAL_GPU_INTEL;
|
info.use_hardware_raytracing = vendor != METAL_GPU_INTEL;
|
||||||
|
if (info.use_hardware_raytracing) {
|
||||||
|
if (@available(macos 11.0, *)) {
|
||||||
|
info.use_hardware_raytracing = device.supportsRaytracing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
devices.push_back(info);
|
devices.push_back(info);
|
||||||
device_index++;
|
device_index++;
|
||||||
|
|
|
@ -4268,8 +4268,6 @@ def km_grease_pencil_stroke_weight_draw(_params):
|
||||||
# Draw
|
# Draw
|
||||||
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
|
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
|
||||||
{"properties": [("wait_for_input", False)]}),
|
{"properties": [("wait_for_input", False)]}),
|
||||||
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
|
|
||||||
{"properties": [("wait_for_input", False)]}),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
return keymap
|
return keymap
|
||||||
|
|
|
@ -420,7 +420,15 @@ struct PartialUpdateRegisterImpl {
|
||||||
*/
|
*/
|
||||||
bool can_construct(ChangesetID changeset_id)
|
bool can_construct(ChangesetID changeset_id)
|
||||||
{
|
{
|
||||||
return changeset_id >= first_changeset_id;
|
if (changeset_id < first_changeset_id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changeset_id > last_changeset_id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -209,7 +209,8 @@ set(SRC
|
||||||
engines/overlay/overlay_extra.cc
|
engines/overlay/overlay_extra.cc
|
||||||
engines/overlay/overlay_facing.cc
|
engines/overlay/overlay_facing.cc
|
||||||
engines/overlay/overlay_fade.cc
|
engines/overlay/overlay_fade.cc
|
||||||
engines/overlay/overlay_gpencil.cc
|
engines/overlay/overlay_gpencil_legacy.cc
|
||||||
|
engines/overlay/overlay_grease_pencil.cc
|
||||||
engines/overlay/overlay_grid.cc
|
engines/overlay/overlay_grid.cc
|
||||||
engines/overlay/overlay_image.cc
|
engines/overlay/overlay_image.cc
|
||||||
engines/overlay/overlay_lattice.cc
|
engines/overlay/overlay_lattice.cc
|
||||||
|
|
|
@ -194,11 +194,18 @@ static void OVERLAY_cache_init(void *vedata)
|
||||||
OVERLAY_sculpt_cache_init(data);
|
OVERLAY_sculpt_cache_init(data);
|
||||||
break;
|
break;
|
||||||
case CTX_MODE_EDIT_GPENCIL:
|
case CTX_MODE_EDIT_GPENCIL:
|
||||||
|
if (U.experimental.use_grease_pencil_version3) {
|
||||||
|
OVERLAY_edit_grease_pencil_cache_init(data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OVERLAY_edit_gpencil_legacy_cache_init(data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CTX_MODE_PAINT_GPENCIL:
|
case CTX_MODE_PAINT_GPENCIL:
|
||||||
case CTX_MODE_SCULPT_GPENCIL:
|
case CTX_MODE_SCULPT_GPENCIL:
|
||||||
case CTX_MODE_VERTEX_GPENCIL:
|
case CTX_MODE_VERTEX_GPENCIL:
|
||||||
case CTX_MODE_WEIGHT_GPENCIL:
|
case CTX_MODE_WEIGHT_GPENCIL:
|
||||||
OVERLAY_edit_gpencil_cache_init(data);
|
OVERLAY_edit_gpencil_legacy_cache_init(data);
|
||||||
break;
|
break;
|
||||||
case CTX_MODE_EDIT_CURVES:
|
case CTX_MODE_EDIT_CURVES:
|
||||||
OVERLAY_edit_curves_cache_init(data);
|
OVERLAY_edit_curves_cache_init(data);
|
||||||
|
@ -220,7 +227,7 @@ static void OVERLAY_cache_init(void *vedata)
|
||||||
OVERLAY_mode_transfer_cache_init(data);
|
OVERLAY_mode_transfer_cache_init(data);
|
||||||
OVERLAY_extra_cache_init(data);
|
OVERLAY_extra_cache_init(data);
|
||||||
OVERLAY_facing_cache_init(data);
|
OVERLAY_facing_cache_init(data);
|
||||||
OVERLAY_gpencil_cache_init(data);
|
OVERLAY_gpencil_legacy_cache_init(data);
|
||||||
OVERLAY_grid_cache_init(data);
|
OVERLAY_grid_cache_init(data);
|
||||||
OVERLAY_image_cache_init(data);
|
OVERLAY_image_cache_init(data);
|
||||||
OVERLAY_metaball_cache_init(data);
|
OVERLAY_metaball_cache_init(data);
|
||||||
|
@ -279,6 +286,8 @@ static bool overlay_object_is_edit_mode(const OVERLAY_PrivateData *pd, const Obj
|
||||||
case OB_VOLUME:
|
case OB_VOLUME:
|
||||||
/* No edit mode yet. */
|
/* No edit mode yet. */
|
||||||
return false;
|
return false;
|
||||||
|
case OB_GREASE_PENCIL:
|
||||||
|
return pd->ctx_mode == CTX_MODE_EDIT_GPENCIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -430,6 +439,11 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
|
||||||
case OB_CURVES:
|
case OB_CURVES:
|
||||||
OVERLAY_edit_curves_cache_populate(data, ob);
|
OVERLAY_edit_curves_cache_populate(data, ob);
|
||||||
break;
|
break;
|
||||||
|
case OB_GREASE_PENCIL:
|
||||||
|
if (U.experimental.use_grease_pencil_version3) {
|
||||||
|
OVERLAY_edit_grease_pencil_cache_populate(data, ob);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (in_pose_mode && draw_bones) {
|
else if (in_pose_mode && draw_bones) {
|
||||||
|
@ -478,7 +492,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OB_GPENCIL_LEGACY:
|
case OB_GPENCIL_LEGACY:
|
||||||
OVERLAY_gpencil_cache_populate(data, ob);
|
OVERLAY_gpencil_legacy_cache_populate(data, ob);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -650,7 +664,7 @@ static void OVERLAY_draw_scene(void *vedata)
|
||||||
OVERLAY_armature_draw(data);
|
OVERLAY_armature_draw(data);
|
||||||
OVERLAY_particle_draw(data);
|
OVERLAY_particle_draw(data);
|
||||||
OVERLAY_metaball_draw(data);
|
OVERLAY_metaball_draw(data);
|
||||||
OVERLAY_gpencil_draw(data);
|
OVERLAY_gpencil_legacy_draw(data);
|
||||||
OVERLAY_extra_draw(data);
|
OVERLAY_extra_draw(data);
|
||||||
if (pd->overlay.flag & V3D_OVERLAY_VIEWER_ATTRIBUTE) {
|
if (pd->overlay.flag & V3D_OVERLAY_VIEWER_ATTRIBUTE) {
|
||||||
OVERLAY_viewer_attribute_draw(data);
|
OVERLAY_viewer_attribute_draw(data);
|
||||||
|
@ -718,11 +732,18 @@ static void OVERLAY_draw_scene(void *vedata)
|
||||||
OVERLAY_edit_particle_draw(data);
|
OVERLAY_edit_particle_draw(data);
|
||||||
break;
|
break;
|
||||||
case CTX_MODE_EDIT_GPENCIL:
|
case CTX_MODE_EDIT_GPENCIL:
|
||||||
|
if (U.experimental.use_grease_pencil_version3) {
|
||||||
|
OVERLAY_edit_grease_pencil_draw(data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
OVERLAY_edit_gpencil_legacy_draw(data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CTX_MODE_PAINT_GPENCIL:
|
case CTX_MODE_PAINT_GPENCIL:
|
||||||
case CTX_MODE_SCULPT_GPENCIL:
|
case CTX_MODE_SCULPT_GPENCIL:
|
||||||
case CTX_MODE_VERTEX_GPENCIL:
|
case CTX_MODE_VERTEX_GPENCIL:
|
||||||
case CTX_MODE_WEIGHT_GPENCIL:
|
case CTX_MODE_WEIGHT_GPENCIL:
|
||||||
OVERLAY_edit_gpencil_draw(data);
|
OVERLAY_edit_gpencil_legacy_draw(data);
|
||||||
break;
|
break;
|
||||||
case CTX_MODE_SCULPT_CURVES:
|
case CTX_MODE_SCULPT_CURVES:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "draw_common.h"
|
#include "draw_common.h"
|
||||||
#include "draw_manager_text.h"
|
#include "draw_manager_text.h"
|
||||||
|
|
||||||
void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
|
void OVERLAY_edit_gpencil_legacy_cache_init(OVERLAY_Data *vedata)
|
||||||
{
|
{
|
||||||
OVERLAY_PassList *psl = vedata->psl;
|
OVERLAY_PassList *psl = vedata->psl;
|
||||||
OVERLAY_PrivateData *pd = vedata->stl->pd;
|
OVERLAY_PrivateData *pd = vedata->stl->pd;
|
||||||
|
@ -205,7 +205,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata)
|
void OVERLAY_gpencil_legacy_cache_init(OVERLAY_Data *vedata)
|
||||||
{
|
{
|
||||||
OVERLAY_PassList *psl = vedata->psl;
|
OVERLAY_PassList *psl = vedata->psl;
|
||||||
OVERLAY_PrivateData *pd = vedata->stl->pd;
|
OVERLAY_PrivateData *pd = vedata->stl->pd;
|
||||||
|
@ -426,7 +426,7 @@ static void OVERLAY_gpencil_color_names(Object *ob)
|
||||||
nullptr, ob, nullptr, overlay_gpencil_draw_stroke_color_name, ob, false, cfra);
|
nullptr, ob, nullptr, overlay_gpencil_draw_stroke_color_name, ob, false, cfra);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OVERLAY_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
void OVERLAY_gpencil_legacy_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||||
{
|
{
|
||||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||||
View3D *v3d = draw_ctx->v3d;
|
View3D *v3d = draw_ctx->v3d;
|
||||||
|
@ -450,7 +450,7 @@ void OVERLAY_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OVERLAY_gpencil_draw(OVERLAY_Data *vedata)
|
void OVERLAY_gpencil_legacy_draw(OVERLAY_Data *vedata)
|
||||||
{
|
{
|
||||||
OVERLAY_PassList *psl = vedata->psl;
|
OVERLAY_PassList *psl = vedata->psl;
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ void OVERLAY_gpencil_draw(OVERLAY_Data *vedata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OVERLAY_edit_gpencil_draw(OVERLAY_Data *vedata)
|
void OVERLAY_edit_gpencil_legacy_draw(OVERLAY_Data *vedata)
|
||||||
{
|
{
|
||||||
OVERLAY_PassList *psl = vedata->psl;
|
OVERLAY_PassList *psl = vedata->psl;
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
* Copyright 2023 Blender Foundation. */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup draw_engine
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "DRW_render.h"
|
||||||
|
|
||||||
|
#include "BKE_grease_pencil.hh"
|
||||||
|
|
||||||
|
#include "overlay_private.hh"
|
||||||
|
|
||||||
|
void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata)
|
||||||
|
{
|
||||||
|
OVERLAY_PassList *psl = vedata->psl;
|
||||||
|
OVERLAY_PrivateData *pd = vedata->stl->pd;
|
||||||
|
|
||||||
|
GPUShader *sh;
|
||||||
|
DRWShadingGroup *grp;
|
||||||
|
|
||||||
|
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
|
||||||
|
DRW_STATE_BLEND_ALPHA;
|
||||||
|
DRW_PASS_CREATE(psl->edit_grease_pencil_ps, (state | pd->clipping_state));
|
||||||
|
|
||||||
|
sh = OVERLAY_shader_edit_particle_point();
|
||||||
|
grp = pd->edit_grease_pencil_points_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps);
|
||||||
|
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OVERLAY_edit_grease_pencil_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||||
|
{
|
||||||
|
OVERLAY_PrivateData *pd = vedata->stl->pd;
|
||||||
|
|
||||||
|
DRWShadingGroup *points_grp = pd->edit_grease_pencil_points_grp;
|
||||||
|
if (points_grp) {
|
||||||
|
struct GPUBatch *geom = DRW_cache_grease_pencil_edit_points_get(ob, pd->cfra);
|
||||||
|
DRW_shgroup_call_no_cull(points_grp, geom, ob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OVERLAY_edit_grease_pencil_draw(OVERLAY_Data *vedata)
|
||||||
|
{
|
||||||
|
OVERLAY_PassList *psl = vedata->psl;
|
||||||
|
|
||||||
|
if (psl->edit_grease_pencil_ps) {
|
||||||
|
DRW_draw_pass(psl->edit_grease_pencil_ps);
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,6 +73,7 @@ typedef struct OVERLAY_PassList {
|
||||||
DRWPass *edit_gpencil_ps;
|
DRWPass *edit_gpencil_ps;
|
||||||
DRWPass *edit_gpencil_gizmos_ps;
|
DRWPass *edit_gpencil_gizmos_ps;
|
||||||
DRWPass *edit_gpencil_curve_ps;
|
DRWPass *edit_gpencil_curve_ps;
|
||||||
|
DRWPass *edit_grease_pencil_ps;
|
||||||
DRWPass *edit_lattice_ps;
|
DRWPass *edit_lattice_ps;
|
||||||
DRWPass *edit_mesh_depth_ps[2];
|
DRWPass *edit_mesh_depth_ps[2];
|
||||||
DRWPass *edit_mesh_verts_ps[2];
|
DRWPass *edit_mesh_verts_ps[2];
|
||||||
|
@ -250,6 +251,7 @@ typedef struct OVERLAY_PrivateData {
|
||||||
DRWShadingGroup *edit_lattice_wires_grp;
|
DRWShadingGroup *edit_lattice_wires_grp;
|
||||||
DRWShadingGroup *edit_gpencil_points_grp;
|
DRWShadingGroup *edit_gpencil_points_grp;
|
||||||
DRWShadingGroup *edit_gpencil_wires_grp;
|
DRWShadingGroup *edit_gpencil_wires_grp;
|
||||||
|
DRWShadingGroup *edit_grease_pencil_points_grp;
|
||||||
DRWShadingGroup *edit_gpencil_curve_handle_grp;
|
DRWShadingGroup *edit_gpencil_curve_handle_grp;
|
||||||
DRWShadingGroup *edit_gpencil_curve_points_grp;
|
DRWShadingGroup *edit_gpencil_curve_points_grp;
|
||||||
DRWShadingGroup *edit_mesh_depth_grp[2];
|
DRWShadingGroup *edit_mesh_depth_grp[2];
|
||||||
|
@ -555,11 +557,15 @@ void OVERLAY_edit_curve_cache_populate(OVERLAY_Data *vedata, Object *ob);
|
||||||
void OVERLAY_edit_surf_cache_populate(OVERLAY_Data *vedata, Object *ob);
|
void OVERLAY_edit_surf_cache_populate(OVERLAY_Data *vedata, Object *ob);
|
||||||
void OVERLAY_edit_curve_draw(OVERLAY_Data *vedata);
|
void OVERLAY_edit_curve_draw(OVERLAY_Data *vedata);
|
||||||
|
|
||||||
void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata);
|
void OVERLAY_edit_gpencil_legacy_cache_init(OVERLAY_Data *vedata);
|
||||||
void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata);
|
void OVERLAY_gpencil_legacy_cache_init(OVERLAY_Data *vedata);
|
||||||
void OVERLAY_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob);
|
void OVERLAY_gpencil_legacy_cache_populate(OVERLAY_Data *vedata, Object *ob);
|
||||||
void OVERLAY_gpencil_draw(OVERLAY_Data *vedata);
|
void OVERLAY_gpencil_legacy_draw(OVERLAY_Data *vedata);
|
||||||
void OVERLAY_edit_gpencil_draw(OVERLAY_Data *vedata);
|
void OVERLAY_edit_gpencil_legacy_draw(OVERLAY_Data *vedata);
|
||||||
|
|
||||||
|
void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata);
|
||||||
|
void OVERLAY_edit_grease_pencil_cache_populate(OVERLAY_Data *vedata, Object *ob);
|
||||||
|
void OVERLAY_edit_grease_pencil_draw(OVERLAY_Data *vedata);
|
||||||
|
|
||||||
void OVERLAY_edit_lattice_cache_init(OVERLAY_Data *vedata);
|
void OVERLAY_edit_lattice_cache_init(OVERLAY_Data *vedata);
|
||||||
void OVERLAY_edit_lattice_cache_populate(OVERLAY_Data *vedata, Object *ob);
|
void OVERLAY_edit_lattice_cache_populate(OVERLAY_Data *vedata, Object *ob);
|
||||||
|
|
|
@ -280,6 +280,7 @@ void DRW_cache_gpencil_sbuffer_clear(struct Object *ob);
|
||||||
/* Grease Pencil */
|
/* Grease Pencil */
|
||||||
|
|
||||||
struct GPUBatch *DRW_cache_grease_pencil_get(struct Object *ob, int cfra);
|
struct GPUBatch *DRW_cache_grease_pencil_get(struct Object *ob, int cfra);
|
||||||
|
struct GPUBatch *DRW_cache_grease_pencil_edit_points_get(struct Object *ob, int cfra);
|
||||||
struct GPUVertBuf *DRW_cache_grease_pencil_position_buffer_get(struct Object *ob, int cfra);
|
struct GPUVertBuf *DRW_cache_grease_pencil_position_buffer_get(struct Object *ob, int cfra);
|
||||||
struct GPUVertBuf *DRW_cache_grease_pencil_color_buffer_get(struct Object *ob, int cfra);
|
struct GPUVertBuf *DRW_cache_grease_pencil_color_buffer_get(struct Object *ob, int cfra);
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,12 @@ struct GreasePencilBatchCache {
|
||||||
GPUIndexBuf *ibo;
|
GPUIndexBuf *ibo;
|
||||||
/** Batches */
|
/** Batches */
|
||||||
GPUBatch *geom_batch;
|
GPUBatch *geom_batch;
|
||||||
|
GPUBatch *edit_points;
|
||||||
|
|
||||||
|
/* Crazy-space point positions for original points. */
|
||||||
|
GPUVertBuf *edit_points_pos;
|
||||||
|
/* Selection of original points. */
|
||||||
|
GPUVertBuf *edit_points_selection;
|
||||||
|
|
||||||
/** Cache is dirty. */
|
/** Cache is dirty. */
|
||||||
bool is_dirty;
|
bool is_dirty;
|
||||||
|
@ -132,6 +138,10 @@ static void grease_pencil_batch_cache_clear(GreasePencil &grease_pencil)
|
||||||
GPU_VERTBUF_DISCARD_SAFE(cache->vbo_col);
|
GPU_VERTBUF_DISCARD_SAFE(cache->vbo_col);
|
||||||
GPU_INDEXBUF_DISCARD_SAFE(cache->ibo);
|
GPU_INDEXBUF_DISCARD_SAFE(cache->ibo);
|
||||||
|
|
||||||
|
GPU_BATCH_DISCARD_SAFE(cache->edit_points);
|
||||||
|
GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_pos);
|
||||||
|
GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_selection);
|
||||||
|
|
||||||
cache->is_dirty = true;
|
cache->is_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +187,7 @@ BLI_INLINE int32_t pack_rotation_aspect_hardness(float rot, float asp, float har
|
||||||
return packed;
|
return packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
static void grease_pencil_geom_batch_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
{
|
{
|
||||||
BLI_assert(grease_pencil.runtime != nullptr);
|
BLI_assert(grease_pencil.runtime != nullptr);
|
||||||
GreasePencilBatchCache *cache = static_cast<GreasePencilBatchCache *>(
|
GreasePencilBatchCache *cache = static_cast<GreasePencilBatchCache *>(
|
||||||
|
@ -199,6 +209,7 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
/* First, count how many vertices and triangles are needed for the whole object. Also record the
|
/* First, count how many vertices and triangles are needed for the whole object. Also record the
|
||||||
* offsets into the curves for the vertices and triangles. */
|
* offsets into the curves for the vertices and triangles. */
|
||||||
int total_points_num = 0;
|
int total_points_num = 0;
|
||||||
|
int total_verts_num = 0;
|
||||||
int total_triangles_num = 0;
|
int total_triangles_num = 0;
|
||||||
int v_offset = 0;
|
int v_offset = 0;
|
||||||
Vector<Array<int>> verts_start_offsets_per_visible_drawing;
|
Vector<Array<int>> verts_start_offsets_per_visible_drawing;
|
||||||
|
@ -239,15 +250,17 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
v_offset += 1 + points.size() + (is_cyclic ? 1 : 0) + 1;
|
v_offset += 1 + points.size() + (is_cyclic ? 1 : 0) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
total_points_num += curves.points_num();
|
||||||
|
|
||||||
/* One vertex is stored before and after as padding. Cyclic strokes have one extra
|
/* One vertex is stored before and after as padding. Cyclic strokes have one extra
|
||||||
* vertex. */
|
* vertex.*/
|
||||||
total_points_num += curves.points_num() + num_cyclic + curves.curves_num() * 2;
|
total_verts_num += curves.points_num() + num_cyclic + curves.curves_num() * 2;
|
||||||
total_triangles_num += (curves.points_num() + num_cyclic) * 2;
|
total_triangles_num += (curves.points_num() + num_cyclic) * 2;
|
||||||
total_triangles_num += drawing.triangles().size();
|
total_triangles_num += drawing.triangles().size();
|
||||||
|
|
||||||
if (drawing.has_stroke_buffer()) {
|
if (drawing.has_stroke_buffer()) {
|
||||||
const int num_buffer_points = drawing.stroke_buffer().size();
|
const int num_buffer_points = drawing.stroke_buffer().size();
|
||||||
total_points_num += 1 + num_buffer_points + 1;
|
total_verts_num += 1 + num_buffer_points + 1;
|
||||||
total_triangles_num += num_buffer_points * 2;
|
total_triangles_num += num_buffer_points * 2;
|
||||||
verts_start_offsets[curves.curves_range().size()] = v_offset;
|
verts_start_offsets[curves.curves_range().size()] = v_offset;
|
||||||
/* TODO: triangles for stroke buffer. */
|
/* TODO: triangles for stroke buffer. */
|
||||||
|
@ -258,6 +271,22 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
tris_start_offsets_per_visible_drawing.append(std::move(tris_start_offsets));
|
tris_start_offsets_per_visible_drawing.append(std::move(tris_start_offsets));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GPUVertFormat format_edit_points_pos = {0};
|
||||||
|
if (format_edit_points_pos.attr_len == 0) {
|
||||||
|
GPU_vertformat_attr_add(&format_edit_points_pos, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GPUVertFormat format_edit_points_selection = {0};
|
||||||
|
if (format_edit_points_selection.attr_len == 0) {
|
||||||
|
GPU_vertformat_attr_add(
|
||||||
|
&format_edit_points_selection, "selection", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
cache->edit_points_pos = GPU_vertbuf_create_with_format(&format_edit_points_pos);
|
||||||
|
cache->edit_points_selection = GPU_vertbuf_create_with_format(&format_edit_points_selection);
|
||||||
|
GPU_vertbuf_data_alloc(cache->edit_points_pos, total_points_num);
|
||||||
|
GPU_vertbuf_data_alloc(cache->edit_points_selection, total_points_num);
|
||||||
|
|
||||||
GPUUsageType vbo_flag = GPU_USAGE_STATIC | GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY;
|
GPUUsageType vbo_flag = GPU_USAGE_STATIC | GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY;
|
||||||
/* Create VBOs. */
|
/* Create VBOs. */
|
||||||
GPUVertFormat *format = grease_pencil_stroke_format();
|
GPUVertFormat *format = grease_pencil_stroke_format();
|
||||||
|
@ -265,8 +294,8 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
cache->vbo = GPU_vertbuf_create_with_format_ex(format, vbo_flag);
|
cache->vbo = GPU_vertbuf_create_with_format_ex(format, vbo_flag);
|
||||||
cache->vbo_col = GPU_vertbuf_create_with_format_ex(format_col, vbo_flag);
|
cache->vbo_col = GPU_vertbuf_create_with_format_ex(format_col, vbo_flag);
|
||||||
/* Add extra space at the end of the buffer because of quad load. */
|
/* Add extra space at the end of the buffer because of quad load. */
|
||||||
GPU_vertbuf_data_alloc(cache->vbo, total_points_num + 2);
|
GPU_vertbuf_data_alloc(cache->vbo, total_verts_num + 2);
|
||||||
GPU_vertbuf_data_alloc(cache->vbo_col, total_points_num + 2);
|
GPU_vertbuf_data_alloc(cache->vbo_col, total_verts_num + 2);
|
||||||
|
|
||||||
GPUIndexBufBuilder ibo;
|
GPUIndexBufBuilder ibo;
|
||||||
MutableSpan<GreasePencilStrokeVert> verts = {
|
MutableSpan<GreasePencilStrokeVert> verts = {
|
||||||
|
@ -275,10 +304,17 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
MutableSpan<GreasePencilColorVert> cols = {
|
MutableSpan<GreasePencilColorVert> cols = {
|
||||||
static_cast<GreasePencilColorVert *>(GPU_vertbuf_get_data(cache->vbo_col)),
|
static_cast<GreasePencilColorVert *>(GPU_vertbuf_get_data(cache->vbo_col)),
|
||||||
GPU_vertbuf_get_vertex_len(cache->vbo_col)};
|
GPU_vertbuf_get_vertex_len(cache->vbo_col)};
|
||||||
|
MutableSpan<float3> edit_points = {
|
||||||
|
static_cast<float3 *>(GPU_vertbuf_get_data(cache->edit_points_pos)),
|
||||||
|
GPU_vertbuf_get_vertex_len(cache->edit_points_pos)};
|
||||||
|
MutableSpan<float> edit_points_selection = {
|
||||||
|
static_cast<float *>(GPU_vertbuf_get_data(cache->edit_points_selection)),
|
||||||
|
GPU_vertbuf_get_vertex_len(cache->edit_points_selection)};
|
||||||
/* Create IBO. */
|
/* Create IBO. */
|
||||||
GPU_indexbuf_init(&ibo, GPU_PRIM_TRIS, total_triangles_num, 0xFFFFFFFFu);
|
GPU_indexbuf_init(&ibo, GPU_PRIM_TRIS, total_triangles_num, 0xFFFFFFFFu);
|
||||||
|
|
||||||
/* Fill buffers with data. */
|
/* Fill buffers with data. */
|
||||||
|
int drawing_start_offset = 0;
|
||||||
for (const int drawing_i : drawings.index_range()) {
|
for (const int drawing_i : drawings.index_range()) {
|
||||||
const GreasePencilDrawing &drawing = *drawings[drawing_i];
|
const GreasePencilDrawing &drawing = *drawings[drawing_i];
|
||||||
const bke::CurvesGeometry &curves = drawing.geometry.wrap();
|
const bke::CurvesGeometry &curves = drawing.geometry.wrap();
|
||||||
|
@ -290,6 +326,8 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
"radius", ATTR_DOMAIN_POINT, 1.0f);
|
"radius", ATTR_DOMAIN_POINT, 1.0f);
|
||||||
const VArray<float> opacities = *attributes.lookup_or_default<float>(
|
const VArray<float> opacities = *attributes.lookup_or_default<float>(
|
||||||
"opacity", ATTR_DOMAIN_POINT, 1.0f);
|
"opacity", ATTR_DOMAIN_POINT, 1.0f);
|
||||||
|
const VArray<float> selection_float = *attributes.lookup_or_default<float>(
|
||||||
|
".selection", ATTR_DOMAIN_POINT, false);
|
||||||
const VArray<int8_t> start_caps = *attributes.lookup_or_default<int8_t>(
|
const VArray<int8_t> start_caps = *attributes.lookup_or_default<int8_t>(
|
||||||
"start_cap", ATTR_DOMAIN_CURVE, 0);
|
"start_cap", ATTR_DOMAIN_CURVE, 0);
|
||||||
const VArray<int8_t> end_caps = *attributes.lookup_or_default<int8_t>(
|
const VArray<int8_t> end_caps = *attributes.lookup_or_default<int8_t>(
|
||||||
|
@ -300,6 +338,12 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
const Span<int> verts_start_offsets = verts_start_offsets_per_visible_drawing[drawing_i];
|
const Span<int> verts_start_offsets = verts_start_offsets_per_visible_drawing[drawing_i];
|
||||||
const Span<int> tris_start_offsets = tris_start_offsets_per_visible_drawing[drawing_i];
|
const Span<int> tris_start_offsets = tris_start_offsets_per_visible_drawing[drawing_i];
|
||||||
|
|
||||||
|
edit_points.slice(drawing_start_offset, curves.points_num()).copy_from(curves.positions());
|
||||||
|
MutableSpan<float> selection_slice = edit_points_selection.slice(drawing_start_offset,
|
||||||
|
curves.points_num());
|
||||||
|
selection_float.materialize(selection_slice);
|
||||||
|
drawing_start_offset += curves.points_num();
|
||||||
|
|
||||||
auto populate_point = [&](IndexRange verts_range,
|
auto populate_point = [&](IndexRange verts_range,
|
||||||
int curve_i,
|
int curve_i,
|
||||||
int8_t start_cap,
|
int8_t start_cap,
|
||||||
|
@ -435,8 +479,8 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark last 2 verts as invalid. */
|
/* Mark last 2 verts as invalid. */
|
||||||
verts[total_points_num + 0].mat = -1;
|
verts[total_verts_num + 0].mat = -1;
|
||||||
verts[total_points_num + 1].mat = -1;
|
verts[total_verts_num + 1].mat = -1;
|
||||||
/* Also mark first vert as invalid. */
|
/* Also mark first vert as invalid. */
|
||||||
verts[0].mat = -1;
|
verts[0].mat = -1;
|
||||||
|
|
||||||
|
@ -448,6 +492,10 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
GPU_vertbuf_use(cache->vbo);
|
GPU_vertbuf_use(cache->vbo);
|
||||||
GPU_vertbuf_use(cache->vbo_col);
|
GPU_vertbuf_use(cache->vbo_col);
|
||||||
|
|
||||||
|
/* Create the batches */
|
||||||
|
cache->edit_points = GPU_batch_create(GPU_PRIM_POINTS, cache->edit_points_pos, nullptr);
|
||||||
|
GPU_batch_vertbuf_add(cache->edit_points, cache->edit_points_selection, false);
|
||||||
|
|
||||||
cache->is_dirty = false;
|
cache->is_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,17 +546,27 @@ GPUBatch *DRW_cache_grease_pencil_get(Object *ob, int cfra)
|
||||||
using namespace blender::draw;
|
using namespace blender::draw;
|
||||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil, cfra);
|
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil, cfra);
|
||||||
grease_pencil_batches_ensure(grease_pencil, cfra);
|
grease_pencil_geom_batch_ensure(grease_pencil, cfra);
|
||||||
|
|
||||||
return cache->geom_batch;
|
return cache->geom_batch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUBatch *DRW_cache_grease_pencil_edit_points_get(Object *ob, int cfra)
|
||||||
|
{
|
||||||
|
using namespace blender::draw;
|
||||||
|
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||||
|
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil, cfra);
|
||||||
|
grease_pencil_geom_batch_ensure(grease_pencil, cfra);
|
||||||
|
|
||||||
|
return cache->edit_points;
|
||||||
|
}
|
||||||
|
|
||||||
GPUVertBuf *DRW_cache_grease_pencil_position_buffer_get(Object *ob, int cfra)
|
GPUVertBuf *DRW_cache_grease_pencil_position_buffer_get(Object *ob, int cfra)
|
||||||
{
|
{
|
||||||
using namespace blender::draw;
|
using namespace blender::draw;
|
||||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil, cfra);
|
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil, cfra);
|
||||||
grease_pencil_batches_ensure(grease_pencil, cfra);
|
grease_pencil_geom_batch_ensure(grease_pencil, cfra);
|
||||||
|
|
||||||
return cache->vbo;
|
return cache->vbo;
|
||||||
}
|
}
|
||||||
|
@ -518,7 +576,7 @@ GPUVertBuf *DRW_cache_grease_pencil_color_buffer_get(Object *ob, int cfra)
|
||||||
using namespace blender::draw;
|
using namespace blender::draw;
|
||||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||||
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil, cfra);
|
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil, cfra);
|
||||||
grease_pencil_batches_ensure(grease_pencil, cfra);
|
grease_pencil_geom_batch_ensure(grease_pencil, cfra);
|
||||||
|
|
||||||
return cache->vbo_col;
|
return cache->vbo_col;
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,19 +309,18 @@ static const BezTriple *fcurve_segment_end_get(FCurve *fcu, int index)
|
||||||
|
|
||||||
void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
|
void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
|
||||||
{
|
{
|
||||||
const float blend_factor = fabs(factor * 2 - 1);
|
|
||||||
const BezTriple *target_bezt;
|
const BezTriple *target_bezt;
|
||||||
/* Find which key to blend towards. */
|
/* Find which key to blend towards. */
|
||||||
if (factor < 0.5f) {
|
if (factor < 0) {
|
||||||
target_bezt = fcurve_segment_start_get(fcu, segment->start_index);
|
target_bezt = fcurve_segment_start_get(fcu, segment->start_index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
target_bezt = fcurve_segment_end_get(fcu, segment->start_index + segment->length);
|
target_bezt = fcurve_segment_end_get(fcu, segment->start_index + segment->length);
|
||||||
}
|
}
|
||||||
|
const float lerp_factor = fabs(factor);
|
||||||
/* Blend each key individually. */
|
/* Blend each key individually. */
|
||||||
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
||||||
const float key_y_value = interpf(
|
const float key_y_value = interpf(target_bezt->vec[1][1], fcu->bezt[i].vec[1][1], lerp_factor);
|
||||||
target_bezt->vec[1][1], fcu->bezt[i].vec[1][1], blend_factor);
|
|
||||||
BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value);
|
BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,8 +457,8 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor
|
||||||
|
|
||||||
/* In order to have a curve that favors the right key, the curve needs to be mirrored in x and y.
|
/* In order to have a curve that favors the right key, the curve needs to be mirrored in x and y.
|
||||||
* Having an exponent that is a fraction of 1 would produce a similar but inferior result. */
|
* Having an exponent that is a fraction of 1 would produce a similar but inferior result. */
|
||||||
const bool inverted = factor > 0.5;
|
const bool inverted = factor > 0;
|
||||||
const float exponent = 1 + fabs(factor * 2 - 1) * 4;
|
const float exponent = 1 + fabs(factor) * 4;
|
||||||
|
|
||||||
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
||||||
/* For easy calculation of the curve, the values are normalized. */
|
/* For easy calculation of the curve, the values are normalized. */
|
||||||
|
@ -486,8 +485,9 @@ void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float f
|
||||||
const BezTriple *right_bezt = fcurve_segment_end_get(fcu,
|
const BezTriple *right_bezt = fcurve_segment_end_get(fcu,
|
||||||
segment->start_index + segment->length);
|
segment->start_index + segment->length);
|
||||||
|
|
||||||
|
const float lerp_factor = (factor + 1) / 2;
|
||||||
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
|
||||||
const float key_y_value = interpf(right_bezt->vec[1][1], left_bezt->vec[1][1], factor);
|
const float key_y_value = interpf(right_bezt->vec[1][1], left_bezt->vec[1][1], lerp_factor);
|
||||||
BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value);
|
BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,7 +419,8 @@ static bool do_weight_paint_normalize_all_unlocked(MDeformVert *dvert,
|
||||||
|
|
||||||
dw = dvert->dw;
|
dw = dvert->dw;
|
||||||
for (int i = dvert->totweight; i != 0; i--, dw++) {
|
for (int i = dvert->totweight; i != 0; i--, dw++) {
|
||||||
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr]) {
|
/* Auto-normalize is only applied on bone-deformed vertex groups that have weight already. */
|
||||||
|
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr] && dw->weight > FLT_EPSILON) {
|
||||||
sum += dw->weight;
|
sum += dw->weight;
|
||||||
|
|
||||||
if (vgroup_locked[dw->def_nr] || (lock_active_vgroup && active_vgroup == dw->def_nr)) {
|
if (vgroup_locked[dw->def_nr] || (lock_active_vgroup && active_vgroup == dw->def_nr)) {
|
||||||
|
@ -461,7 +462,8 @@ static bool do_weight_paint_normalize_all_unlocked(MDeformVert *dvert,
|
||||||
|
|
||||||
dw = dvert->dw;
|
dw = dvert->dw;
|
||||||
for (int i = dvert->totweight; i != 0; i--, dw++) {
|
for (int i = dvert->totweight; i != 0; i--, dw++) {
|
||||||
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr]) {
|
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr] && dw->weight > FLT_EPSILON)
|
||||||
|
{
|
||||||
if ((vgroup_locked[dw->def_nr] == false) &&
|
if ((vgroup_locked[dw->def_nr] == false) &&
|
||||||
!(lock_active_vgroup && active_vgroup == dw->def_nr)) {
|
!(lock_active_vgroup && active_vgroup == dw->def_nr)) {
|
||||||
dw->weight *= fac;
|
dw->weight *= fac;
|
||||||
|
@ -476,7 +478,8 @@ static bool do_weight_paint_normalize_all_unlocked(MDeformVert *dvert,
|
||||||
|
|
||||||
dw = dvert->dw;
|
dw = dvert->dw;
|
||||||
for (int i = dvert->totweight; i != 0; i--, dw++) {
|
for (int i = dvert->totweight; i != 0; i--, dw++) {
|
||||||
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr]) {
|
if (dw->def_nr < defbase_tot && vgroup_bone_deformed[dw->def_nr] && dw->weight > FLT_EPSILON)
|
||||||
|
{
|
||||||
if ((vgroup_locked[dw->def_nr] == false) &&
|
if ((vgroup_locked[dw->def_nr] == false) &&
|
||||||
!(lock_active_vgroup && active_vgroup == dw->def_nr)) {
|
!(lock_active_vgroup && active_vgroup == dw->def_nr)) {
|
||||||
dw->weight = fac;
|
dw->weight = fac;
|
||||||
|
|
|
@ -406,21 +406,21 @@ static void file_draw_preview(const FileDirEntry *file,
|
||||||
|
|
||||||
/* the large image */
|
/* the large image */
|
||||||
|
|
||||||
float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
float document_img_col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||||
if (is_icon) {
|
if (is_icon) {
|
||||||
if (file->typeflag & FILE_TYPE_DIR) {
|
if (file->typeflag & FILE_TYPE_DIR) {
|
||||||
UI_GetThemeColor4fv(TH_ICON_FOLDER, col);
|
UI_GetThemeColor4fv(TH_ICON_FOLDER, document_img_col);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
UI_GetThemeColor4fv(TH_TEXT, col);
|
UI_GetThemeColor4fv(TH_TEXT, document_img_col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (file->typeflag & FILE_TYPE_FTFONT) {
|
else if (file->typeflag & FILE_TYPE_FTFONT) {
|
||||||
UI_GetThemeColor4fv(TH_TEXT, col);
|
UI_GetThemeColor4fv(TH_TEXT, document_img_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dimmed) {
|
if (dimmed) {
|
||||||
col[3] *= 0.3f;
|
document_img_col[3] *= 0.3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_icon && file->typeflag & FILE_TYPE_BLENDERLIB) {
|
if (!is_icon && file->typeflag & FILE_TYPE_BLENDERLIB) {
|
||||||
|
@ -441,7 +441,7 @@ static void file_draw_preview(const FileDirEntry *file,
|
||||||
scale,
|
scale,
|
||||||
1.0f,
|
1.0f,
|
||||||
1.0f,
|
1.0f,
|
||||||
col);
|
document_img_col);
|
||||||
|
|
||||||
GPU_blend(GPU_BLEND_ALPHA);
|
GPU_blend(GPU_BLEND_ALPHA);
|
||||||
|
|
||||||
|
@ -451,9 +451,7 @@ static void file_draw_preview(const FileDirEntry *file,
|
||||||
const float icon_size = 16.0f / icon_aspect * UI_SCALE_FAC;
|
const float icon_size = 16.0f / icon_aspect * UI_SCALE_FAC;
|
||||||
float icon_opacity = 0.3f;
|
float icon_opacity = 0.3f;
|
||||||
uchar icon_color[4] = {0, 0, 0, 255};
|
uchar icon_color[4] = {0, 0, 0, 255};
|
||||||
float bgcolor[4];
|
if (rgb_to_grayscale(document_img_col) < 0.5f) {
|
||||||
UI_GetThemeColor4fv(TH_ICON_FOLDER, bgcolor);
|
|
||||||
if (rgb_to_grayscale(bgcolor) < 0.5f) {
|
|
||||||
icon_color[0] = 255;
|
icon_color[0] = 255;
|
||||||
icon_color[1] = 255;
|
icon_color[1] = 255;
|
||||||
icon_color[2] = 255;
|
icon_color[2] = 255;
|
||||||
|
|
|
@ -644,6 +644,8 @@ static int blend_to_neighbor_invoke(bContext *C, wmOperator *op, const wmEvent *
|
||||||
gso->modal_update = blend_to_neighbor_modal_update;
|
gso->modal_update = blend_to_neighbor_modal_update;
|
||||||
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
||||||
common_draw_status_header(C, gso, "Blend to Neighbor");
|
common_draw_status_header(C, gso, "Blend to Neighbor");
|
||||||
|
ED_slider_factor_bounds_set(gso->slider, -1, 1);
|
||||||
|
ED_slider_factor_set(gso->slider, 0.0f);
|
||||||
|
|
||||||
return invoke_result;
|
return invoke_result;
|
||||||
}
|
}
|
||||||
|
@ -684,12 +686,12 @@ void GRAPH_OT_blend_to_neighbor(wmOperatorType *ot)
|
||||||
|
|
||||||
RNA_def_float_factor(ot->srna,
|
RNA_def_float_factor(ot->srna,
|
||||||
"factor",
|
"factor",
|
||||||
1.0f / 3.0f,
|
0.0f,
|
||||||
-FLT_MAX,
|
-FLT_MAX,
|
||||||
FLT_MAX,
|
FLT_MAX,
|
||||||
"Blend",
|
"Blend",
|
||||||
"The blend factor with 0.5 being the current frame",
|
"The blend factor with 0 being the current frame",
|
||||||
0.0f,
|
-1.0f,
|
||||||
1.0f);
|
1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,6 +731,8 @@ static int breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
gso->modal_update = breakdown_modal_update;
|
gso->modal_update = breakdown_modal_update;
|
||||||
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
||||||
common_draw_status_header(C, gso, "Breakdown");
|
common_draw_status_header(C, gso, "Breakdown");
|
||||||
|
ED_slider_factor_bounds_set(gso->slider, -1, 1);
|
||||||
|
ED_slider_factor_set(gso->slider, 0.0f);
|
||||||
|
|
||||||
return invoke_result;
|
return invoke_result;
|
||||||
}
|
}
|
||||||
|
@ -769,12 +773,12 @@ void GRAPH_OT_breakdown(wmOperatorType *ot)
|
||||||
|
|
||||||
RNA_def_float_factor(ot->srna,
|
RNA_def_float_factor(ot->srna,
|
||||||
"factor",
|
"factor",
|
||||||
1.0f / 3.0f,
|
0.0f,
|
||||||
-FLT_MAX,
|
-FLT_MAX,
|
||||||
FLT_MAX,
|
FLT_MAX,
|
||||||
"Factor",
|
"Factor",
|
||||||
"Favor either the left or the right key",
|
"Favor either the left or the right key",
|
||||||
0.0f,
|
-1.0f,
|
||||||
1.0f);
|
1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -834,6 +838,7 @@ static int blend_to_default_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||||
gso->modal_update = blend_to_default_modal_update;
|
gso->modal_update = blend_to_default_modal_update;
|
||||||
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
||||||
common_draw_status_header(C, gso, "Blend to Default Value");
|
common_draw_status_header(C, gso, "Blend to Default Value");
|
||||||
|
ED_slider_factor_set(gso->slider, 0.0f);
|
||||||
|
|
||||||
return invoke_result;
|
return invoke_result;
|
||||||
}
|
}
|
||||||
|
@ -874,7 +879,7 @@ void GRAPH_OT_blend_to_default(wmOperatorType *ot)
|
||||||
|
|
||||||
RNA_def_float_factor(ot->srna,
|
RNA_def_float_factor(ot->srna,
|
||||||
"factor",
|
"factor",
|
||||||
1.0f / 3.0f,
|
0.0f,
|
||||||
-FLT_MAX,
|
-FLT_MAX,
|
||||||
FLT_MAX,
|
FLT_MAX,
|
||||||
"Factor",
|
"Factor",
|
||||||
|
@ -918,6 +923,8 @@ static int ease_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
gso->modal_update = ease_modal_update;
|
gso->modal_update = ease_modal_update;
|
||||||
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
||||||
common_draw_status_header(C, gso, "Ease Keys");
|
common_draw_status_header(C, gso, "Ease Keys");
|
||||||
|
ED_slider_factor_bounds_set(gso->slider, -1, 1);
|
||||||
|
ED_slider_factor_set(gso->slider, 0.0f);
|
||||||
|
|
||||||
return invoke_result;
|
return invoke_result;
|
||||||
}
|
}
|
||||||
|
@ -959,12 +966,12 @@ void GRAPH_OT_ease(wmOperatorType *ot)
|
||||||
|
|
||||||
RNA_def_float_factor(ot->srna,
|
RNA_def_float_factor(ot->srna,
|
||||||
"factor",
|
"factor",
|
||||||
0.5f,
|
0.0f,
|
||||||
-FLT_MAX,
|
-FLT_MAX,
|
||||||
FLT_MAX,
|
FLT_MAX,
|
||||||
"Curve Bend",
|
"Curve Bend",
|
||||||
"Control the bend of the curve",
|
"Control the bend of the curve",
|
||||||
0.0f,
|
-1.0f,
|
||||||
1.0f);
|
1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2896,7 +2896,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OUTLINER_IDOP_REMAP: {
|
case OUTLINER_IDOP_REMAP: {
|
||||||
if (idlevel > 0) {
|
if (idlevel > 0 || objectlevel) {
|
||||||
outliner_do_libdata_operation(C, op->reports, scene, space_outliner, id_remap_fn, nullptr);
|
outliner_do_libdata_operation(C, op->reports, scene, space_outliner, id_remap_fn, nullptr);
|
||||||
/* No undo push here, operator does it itself (since it's a modal one, the op_undo_depth
|
/* No undo push here, operator does it itself (since it's a modal one, the op_undo_depth
|
||||||
* trick does not work here). */
|
* trick does not work here). */
|
||||||
|
|
|
@ -1332,11 +1332,12 @@ int transformEvent(TransInfo *t, const wmEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Per transform event, if present */
|
/* Per transform event, if present */
|
||||||
if (t->handleEvent && (!handled ||
|
if (t->mode_info && t->mode_info->handle_event_fn &&
|
||||||
|
(!handled ||
|
||||||
/* Needed for vertex slide, see #38756. */
|
/* Needed for vertex slide, see #38756. */
|
||||||
(event->type == MOUSEMOVE)))
|
(event->type == MOUSEMOVE)))
|
||||||
{
|
{
|
||||||
t->redraw |= t->handleEvent(t, event);
|
t->redraw |= t->mode_info->handle_event_fn(t, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to init modal numinput now, if possible. */
|
/* Try to init modal numinput now, if possible. */
|
||||||
|
@ -1441,10 +1442,8 @@ static void drawTransformView(const struct bContext *C, ARegion *region, void *a
|
||||||
drawPropCircle(C, t);
|
drawPropCircle(C, t);
|
||||||
drawSnapping(C, t);
|
drawSnapping(C, t);
|
||||||
|
|
||||||
if (region == t->region) {
|
if (region == t->region && t->mode_info && t->mode_info->draw_fn) {
|
||||||
/* edge slide, vert slide */
|
t->mode_info->draw_fn(t);
|
||||||
drawEdgeSlide(t);
|
|
||||||
drawVertSlide(t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2066,8 +2065,8 @@ void transformApply(bContext *C, TransInfo *t)
|
||||||
|
|
||||||
if (t->redraw == TREDRAW_HARD) {
|
if (t->redraw == TREDRAW_HARD) {
|
||||||
selectConstraint(t);
|
selectConstraint(t);
|
||||||
if (t->transform) {
|
if (t->mode_info) {
|
||||||
t->transform(t, t->mval); /* calls recalcData() */
|
t->mode_info->transform_fn(t, t->mval); /* calls recalcData() */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2143,8 +2142,8 @@ bool checkUseAxisMatrix(TransInfo *t)
|
||||||
|
|
||||||
bool transform_apply_matrix(TransInfo *t, float mat[4][4])
|
bool transform_apply_matrix(TransInfo *t, float mat[4][4])
|
||||||
{
|
{
|
||||||
if (t->transform_matrix != NULL) {
|
if (t->mode_info && t->mode_info->transform_matrix_fn) {
|
||||||
t->transform_matrix(t, mat);
|
t->mode_info->transform_matrix_fn(t, mat);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -309,14 +309,6 @@ typedef struct TransSnap {
|
||||||
double last;
|
double last;
|
||||||
void (*snap_target_fn)(struct TransInfo *, float *);
|
void (*snap_target_fn)(struct TransInfo *, float *);
|
||||||
void (*snap_source_fn)(struct TransInfo *);
|
void (*snap_source_fn)(struct TransInfo *);
|
||||||
/**
|
|
||||||
* Get the transform distance between two points (used by Closest snap)
|
|
||||||
*
|
|
||||||
* \note Return value can be anything,
|
|
||||||
* where the smallest absolute value defines what's closest.
|
|
||||||
*/
|
|
||||||
float (*snap_mode_distance_fn)(struct TransInfo *t, const float p1[3], const float p2[3]);
|
|
||||||
void (*snap_mode_apply_fn)(struct TransInfo *, float *);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-usable snap context data.
|
* Re-usable snap context data.
|
||||||
|
@ -508,6 +500,11 @@ typedef struct TransInfo {
|
||||||
/** TODO: It should be a member of #TransDataContainer. */
|
/** TODO: It should be a member of #TransDataContainer. */
|
||||||
struct TransConvertTypeInfo *data_type;
|
struct TransConvertTypeInfo *data_type;
|
||||||
|
|
||||||
|
/** Mode indicator as set for the operator.
|
||||||
|
* NOTE: A same `mode_info` can have different `mode`s. */
|
||||||
|
eTfmMode mode;
|
||||||
|
struct TransModeInfo *mode_info;
|
||||||
|
|
||||||
/** Current context/options for transform. */
|
/** Current context/options for transform. */
|
||||||
eTContext options;
|
eTContext options;
|
||||||
/** Generic flags for special behaviors. */
|
/** Generic flags for special behaviors. */
|
||||||
|
@ -520,20 +517,6 @@ typedef struct TransInfo {
|
||||||
eRedrawFlag redraw;
|
eRedrawFlag redraw;
|
||||||
/** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */
|
/** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */
|
||||||
eTHelpline helpline;
|
eTHelpline helpline;
|
||||||
/** Current mode. */
|
|
||||||
eTfmMode mode;
|
|
||||||
|
|
||||||
/** Main transform mode function. */
|
|
||||||
void (*transform)(struct TransInfo *, const int[2]);
|
|
||||||
/* Event handler function that determines whether the viewport needs to be redrawn. */
|
|
||||||
eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional callback to transform a single matrix.
|
|
||||||
*
|
|
||||||
* \note used by the gizmo to transform the matrix used to position it.
|
|
||||||
*/
|
|
||||||
void (*transform_matrix)(struct TransInfo *t, float mat_xform[4][4]);
|
|
||||||
|
|
||||||
/** Constraint Data. */
|
/** Constraint Data. */
|
||||||
TransCon con;
|
TransCon con;
|
||||||
|
|
|
@ -186,8 +186,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
||||||
copy_v2_v2_int(t->mouse.imval, mval);
|
copy_v2_v2_int(t->mouse.imval, mval);
|
||||||
copy_v2_v2_int(t->con.imval, mval);
|
copy_v2_v2_int(t->con.imval, mval);
|
||||||
|
|
||||||
t->transform = NULL;
|
t->mode_info = NULL;
|
||||||
t->handleEvent = NULL;
|
|
||||||
|
|
||||||
t->data_len_all = 0;
|
t->data_len_all = 0;
|
||||||
|
|
||||||
|
|
|
@ -1066,141 +1066,92 @@ void ElementResize(const TransInfo *t,
|
||||||
/** \name Transform Mode Initialization
|
/** \name Transform Mode Initialization
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
|
static TransModeInfo *mode_info_get(TransInfo *t, const int mode)
|
||||||
|
{
|
||||||
|
switch (mode) {
|
||||||
|
case TFM_TRANSLATION:
|
||||||
|
return &TransMode_translate;
|
||||||
|
case TFM_ROTATION:
|
||||||
|
return &TransMode_rotate;
|
||||||
|
case TFM_RESIZE:
|
||||||
|
return &TransMode_resize;
|
||||||
|
case TFM_SKIN_RESIZE:
|
||||||
|
return &TransMode_skinresize;
|
||||||
|
case TFM_TOSPHERE:
|
||||||
|
return &TransMode_tosphere;
|
||||||
|
case TFM_SHEAR:
|
||||||
|
return &TransMode_shear;
|
||||||
|
case TFM_BEND:
|
||||||
|
return &TransMode_bend;
|
||||||
|
case TFM_SHRINKFATTEN:
|
||||||
|
return &TransMode_shrinkfatten;
|
||||||
|
case TFM_TILT:
|
||||||
|
return &TransMode_tilt;
|
||||||
|
case TFM_CURVE_SHRINKFATTEN:
|
||||||
|
return &TransMode_curveshrinkfatten;
|
||||||
|
case TFM_MASK_SHRINKFATTEN:
|
||||||
|
return &TransMode_maskshrinkfatten;
|
||||||
|
case TFM_GPENCIL_SHRINKFATTEN:
|
||||||
|
return &TransMode_gpshrinkfatten;
|
||||||
|
case TFM_TRACKBALL:
|
||||||
|
return &TransMode_trackball;
|
||||||
|
case TFM_PUSHPULL:
|
||||||
|
return &TransMode_pushpull;
|
||||||
|
case TFM_EDGE_CREASE:
|
||||||
|
return &TransMode_edgecrease;
|
||||||
|
case TFM_VERT_CREASE:
|
||||||
|
return &TransMode_vertcrease;
|
||||||
|
case TFM_BONESIZE:
|
||||||
|
return &TransMode_bboneresize;
|
||||||
|
case TFM_BONE_ENVELOPE:
|
||||||
|
case TFM_BONE_ENVELOPE_DIST:
|
||||||
|
return &TransMode_boneenvelope;
|
||||||
|
case TFM_EDGE_SLIDE:
|
||||||
|
return &TransMode_edgeslide;
|
||||||
|
case TFM_VERT_SLIDE:
|
||||||
|
return &TransMode_vertslide;
|
||||||
|
case TFM_BONE_ROLL:
|
||||||
|
return &TransMode_boneroll;
|
||||||
|
case TFM_TIME_TRANSLATE:
|
||||||
|
return &TransMode_translate;
|
||||||
|
case TFM_TIME_SLIDE:
|
||||||
|
return &TransMode_timeslide;
|
||||||
|
case TFM_TIME_SCALE:
|
||||||
|
return &TransMode_timescale;
|
||||||
|
case TFM_TIME_EXTEND:
|
||||||
|
/* Do TFM_TIME_TRANSLATE (for most Animation Editors because they have only 1D transforms for
|
||||||
|
* time values) or TFM_TRANSLATION (for Graph/NLA Editors only since they uses 'standard'
|
||||||
|
* transforms to get 2D movement) depending on which editor this was called from. */
|
||||||
|
if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
|
||||||
|
return &TransMode_translate;
|
||||||
|
}
|
||||||
|
return &TransMode_timetranslate;
|
||||||
|
case TFM_BAKE_TIME:
|
||||||
|
return &TransMode_baketime;
|
||||||
|
case TFM_MIRROR:
|
||||||
|
return &TransMode_mirror;
|
||||||
|
case TFM_BWEIGHT:
|
||||||
|
return &TransMode_bevelweight;
|
||||||
|
case TFM_ALIGN:
|
||||||
|
return &TransMode_align;
|
||||||
|
case TFM_SEQ_SLIDE:
|
||||||
|
return &TransMode_seqslide;
|
||||||
|
case TFM_NORMAL_ROTATION:
|
||||||
|
return &TransMode_rotatenormal;
|
||||||
|
case TFM_GPENCIL_OPACITY:
|
||||||
|
return &TransMode_gpopacity;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
|
void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
|
||||||
{
|
{
|
||||||
t->mode = mode;
|
t->mode = mode;
|
||||||
|
t->mode_info = mode_info_get(t, mode);
|
||||||
|
|
||||||
switch (mode) {
|
if (t->mode_info) {
|
||||||
case TFM_TRANSLATION:
|
t->flag |= t->mode_info->flags;
|
||||||
initTranslation(t);
|
t->mode_info->init_fn(t, op);
|
||||||
break;
|
|
||||||
case TFM_ROTATION:
|
|
||||||
initRotation(t);
|
|
||||||
break;
|
|
||||||
case TFM_RESIZE: {
|
|
||||||
float mouse_dir_constraint[3];
|
|
||||||
if (op) {
|
|
||||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "mouse_dir_constraint");
|
|
||||||
if (prop) {
|
|
||||||
RNA_property_float_get_array(op->ptr, prop, mouse_dir_constraint);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* Resize is expected to have this property. */
|
|
||||||
BLI_assert(!STREQ(op->idname, "TRANSFORM_OT_resize"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
zero_v3(mouse_dir_constraint);
|
|
||||||
}
|
|
||||||
initResize(t, mouse_dir_constraint);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TFM_SKIN_RESIZE:
|
|
||||||
initSkinResize(t);
|
|
||||||
break;
|
|
||||||
case TFM_TOSPHERE:
|
|
||||||
initToSphere(t);
|
|
||||||
break;
|
|
||||||
case TFM_SHEAR:
|
|
||||||
initShear(t);
|
|
||||||
break;
|
|
||||||
case TFM_BEND:
|
|
||||||
initBend(t);
|
|
||||||
break;
|
|
||||||
case TFM_SHRINKFATTEN:
|
|
||||||
initShrinkFatten(t);
|
|
||||||
break;
|
|
||||||
case TFM_TILT:
|
|
||||||
initTilt(t);
|
|
||||||
break;
|
|
||||||
case TFM_CURVE_SHRINKFATTEN:
|
|
||||||
initCurveShrinkFatten(t);
|
|
||||||
break;
|
|
||||||
case TFM_MASK_SHRINKFATTEN:
|
|
||||||
initMaskShrinkFatten(t);
|
|
||||||
break;
|
|
||||||
case TFM_GPENCIL_SHRINKFATTEN:
|
|
||||||
initGPShrinkFatten(t);
|
|
||||||
break;
|
|
||||||
case TFM_TRACKBALL:
|
|
||||||
initTrackball(t);
|
|
||||||
break;
|
|
||||||
case TFM_PUSHPULL:
|
|
||||||
initPushPull(t);
|
|
||||||
break;
|
|
||||||
case TFM_EDGE_CREASE:
|
|
||||||
initEgdeCrease(t);
|
|
||||||
break;
|
|
||||||
case TFM_VERT_CREASE:
|
|
||||||
initVertCrease(t);
|
|
||||||
break;
|
|
||||||
case TFM_BONESIZE:
|
|
||||||
initBoneSize(t);
|
|
||||||
break;
|
|
||||||
case TFM_BONE_ENVELOPE:
|
|
||||||
case TFM_BONE_ENVELOPE_DIST:
|
|
||||||
initBoneEnvelope(t);
|
|
||||||
break;
|
|
||||||
case TFM_EDGE_SLIDE:
|
|
||||||
case TFM_VERT_SLIDE: {
|
|
||||||
const bool use_even = (op ? RNA_boolean_get(op->ptr, "use_even") : false);
|
|
||||||
const bool flipped = (op ? RNA_boolean_get(op->ptr, "flipped") : false);
|
|
||||||
const bool use_clamp = (op ? RNA_boolean_get(op->ptr, "use_clamp") : true);
|
|
||||||
if (mode == TFM_EDGE_SLIDE) {
|
|
||||||
const bool use_double_side = (op ? !RNA_boolean_get(op->ptr, "single_side") : true);
|
|
||||||
initEdgeSlide_ex(t, use_double_side, use_even, flipped, use_clamp);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
initVertSlide_ex(t, use_even, flipped, use_clamp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TFM_BONE_ROLL:
|
|
||||||
initBoneRoll(t);
|
|
||||||
break;
|
|
||||||
case TFM_TIME_TRANSLATE:
|
|
||||||
initTimeTranslate(t);
|
|
||||||
break;
|
|
||||||
case TFM_TIME_SLIDE:
|
|
||||||
initTimeSlide(t);
|
|
||||||
break;
|
|
||||||
case TFM_TIME_SCALE:
|
|
||||||
initTimeScale(t);
|
|
||||||
break;
|
|
||||||
case TFM_TIME_EXTEND:
|
|
||||||
/* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
|
|
||||||
* Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
|
|
||||||
* (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
|
|
||||||
* depending on which editor this was called from
|
|
||||||
*/
|
|
||||||
if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
|
|
||||||
initTranslation(t);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
initTimeTranslate(t);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TFM_BAKE_TIME:
|
|
||||||
initBakeTime(t);
|
|
||||||
break;
|
|
||||||
case TFM_MIRROR:
|
|
||||||
initMirror(t);
|
|
||||||
break;
|
|
||||||
case TFM_BWEIGHT:
|
|
||||||
initBevelWeight(t);
|
|
||||||
break;
|
|
||||||
case TFM_ALIGN:
|
|
||||||
initAlign(t);
|
|
||||||
break;
|
|
||||||
case TFM_SEQ_SLIDE:
|
|
||||||
initSeqSlide(t);
|
|
||||||
break;
|
|
||||||
case TFM_NORMAL_ROTATION:
|
|
||||||
initNormalRotation(t);
|
|
||||||
break;
|
|
||||||
case TFM_GPENCIL_OPACITY:
|
|
||||||
initGPOpacity(t);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->data_type == &TransConvertType_Mesh) {
|
if (t->data_type == &TransConvertType_Mesh) {
|
||||||
|
@ -1211,7 +1162,7 @@ void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
|
||||||
|
|
||||||
transform_gizmo_3d_model_from_constraint_and_mode_set(t);
|
transform_gizmo_3d_model_from_constraint_and_mode_set(t);
|
||||||
|
|
||||||
/* TODO(@germano): Some of these operations change the `t->mode`.
|
/* TODO(@mano-wii): Some of these operations change the `t->mode`.
|
||||||
* This can be bad for Redo. */
|
* This can be bad for Redo. */
|
||||||
// BLI_assert(t->mode == mode);
|
// BLI_assert(t->mode == mode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,37 @@ struct TransInfo;
|
||||||
struct bContext;
|
struct bContext;
|
||||||
struct wmOperator;
|
struct wmOperator;
|
||||||
|
|
||||||
|
typedef struct TransModeInfo {
|
||||||
|
int flags; /* eTFlag */
|
||||||
|
|
||||||
|
void (*init_fn)(TransInfo *, struct wmOperator *);
|
||||||
|
|
||||||
|
/** Main transform mode function. */
|
||||||
|
void (*transform_fn)(TransInfo *, const int[2]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional callback to transform a single matrix.
|
||||||
|
*
|
||||||
|
* \note used by the gizmo to transform the matrix used to position it.
|
||||||
|
*/
|
||||||
|
void (*transform_matrix_fn)(TransInfo *, float[4][4]);
|
||||||
|
|
||||||
|
/* Event handler function that determines whether the viewport needs to be redrawn. */
|
||||||
|
eRedrawFlag (*handle_event_fn)(TransInfo *, const struct wmEvent *);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the transform distance between two points (used by Closest snap)
|
||||||
|
*
|
||||||
|
* \note Return value can be anything,
|
||||||
|
* where the smallest absolute value defines what's closest.
|
||||||
|
*/
|
||||||
|
float (*snap_distance_fn)(struct TransInfo *t, const float p1[3], const float p2[3]);
|
||||||
|
void (*snap_apply_fn)(struct TransInfo *, float *);
|
||||||
|
|
||||||
|
/** Custom drawing. */
|
||||||
|
void (*draw_fn)(struct TransInfo *);
|
||||||
|
} TransModeInfo;
|
||||||
|
|
||||||
/* header of TransDataEdgeSlideVert, TransDataEdgeSlideEdge */
|
/* header of TransDataEdgeSlideVert, TransDataEdgeSlideEdge */
|
||||||
typedef struct TransDataGenericSlideVert {
|
typedef struct TransDataGenericSlideVert {
|
||||||
struct BMVert *v;
|
struct BMVert *v;
|
||||||
|
@ -68,125 +99,120 @@ void transform_mode_default_modal_orientation_set(TransInfo *t, int type);
|
||||||
|
|
||||||
/* transform_mode_align.c */
|
/* transform_mode_align.c */
|
||||||
|
|
||||||
void initAlign(TransInfo *t);
|
extern TransModeInfo TransMode_align;
|
||||||
|
|
||||||
/* transform_mode_baketime.c */
|
/* transform_mode_baketime.c */
|
||||||
|
|
||||||
void initBakeTime(TransInfo *t);
|
extern TransModeInfo TransMode_baketime;
|
||||||
|
|
||||||
/* transform_mode_bbone_resize.c */
|
/* transform_mode_bbone_resize.c */
|
||||||
|
|
||||||
void initBoneSize(TransInfo *t);
|
extern TransModeInfo TransMode_bboneresize;
|
||||||
|
|
||||||
/* transform_mode_bend.c */
|
/* transform_mode_bend.c */
|
||||||
|
|
||||||
void initBend(TransInfo *t);
|
extern TransModeInfo TransMode_bend;
|
||||||
|
|
||||||
/* transform_mode_boneenvelope.c */
|
/* transform_mode_boneenvelope.c */
|
||||||
|
|
||||||
void initBoneEnvelope(TransInfo *t);
|
extern TransModeInfo TransMode_boneenvelope;
|
||||||
|
|
||||||
/* transform_mode_boneroll.c */
|
/* transform_mode_boneroll.c */
|
||||||
|
|
||||||
void initBoneRoll(TransInfo *t);
|
extern TransModeInfo TransMode_boneroll;
|
||||||
|
|
||||||
/* transform_mode_curveshrinkfatten.c */
|
/* transform_mode_curveshrinkfatten.c */
|
||||||
|
|
||||||
void initCurveShrinkFatten(TransInfo *t);
|
extern TransModeInfo TransMode_curveshrinkfatten;
|
||||||
|
|
||||||
/* transform_mode_customdata.c */
|
/* transform_mode_customdata.c */
|
||||||
|
|
||||||
void initEgdeCrease(TransInfo *t);
|
extern TransModeInfo TransMode_edgecrease;
|
||||||
void initVertCrease(TransInfo *t);
|
extern TransModeInfo TransMode_vertcrease;
|
||||||
void initBevelWeight(TransInfo *t);
|
extern TransModeInfo TransMode_bevelweight;
|
||||||
|
|
||||||
/* transform_mode_edge_rotate_normal.c */
|
/* transform_mode_edge_rotate_normal.c */
|
||||||
|
|
||||||
void initNormalRotation(TransInfo *t);
|
extern TransModeInfo TransMode_rotatenormal;
|
||||||
|
|
||||||
/* transform_mode_edge_seq_slide.c */
|
/* transform_mode_edge_seq_slide.c */
|
||||||
|
|
||||||
void initSeqSlide(TransInfo *t);
|
extern TransModeInfo TransMode_seqslide;
|
||||||
|
|
||||||
/* transform_mode_edge_slide.c */
|
/* transform_mode_edge_slide.c */
|
||||||
|
|
||||||
void drawEdgeSlide(TransInfo *t);
|
extern TransModeInfo TransMode_edgeslide;
|
||||||
void initEdgeSlide_ex(
|
|
||||||
TransInfo *t, bool use_double_side, bool use_even, bool flipped, bool use_clamp);
|
|
||||||
void initEdgeSlide(TransInfo *t);
|
|
||||||
void transform_mode_edge_slide_reproject_input(TransInfo *t);
|
void transform_mode_edge_slide_reproject_input(TransInfo *t);
|
||||||
|
|
||||||
/* transform_mode_gpopacity.c */
|
/* transform_mode_gpopacity.c */
|
||||||
|
|
||||||
void initGPOpacity(TransInfo *t);
|
extern TransModeInfo TransMode_gpopacity;
|
||||||
|
|
||||||
/* transform_mode_gpshrinkfatten.c */
|
/* transform_mode_gpshrinkfatten.c */
|
||||||
|
|
||||||
void initGPShrinkFatten(TransInfo *t);
|
extern TransModeInfo TransMode_gpshrinkfatten;
|
||||||
|
|
||||||
/* transform_mode_maskshrinkfatten.c */
|
/* transform_mode_maskshrinkfatten.c */
|
||||||
|
|
||||||
void initMaskShrinkFatten(TransInfo *t);
|
extern TransModeInfo TransMode_maskshrinkfatten;
|
||||||
|
|
||||||
/* transform_mode_mirror.c */
|
/* transform_mode_mirror.c */
|
||||||
|
|
||||||
void initMirror(TransInfo *t);
|
extern TransModeInfo TransMode_mirror;
|
||||||
|
|
||||||
/* transform_mode_push_pull.c */
|
/* transform_mode_push_pull.c */
|
||||||
|
|
||||||
void initPushPull(TransInfo *t);
|
extern TransModeInfo TransMode_pushpull;
|
||||||
|
|
||||||
/* transform_mode_resize.c */
|
/* transform_mode_resize.c */
|
||||||
|
|
||||||
void initResize(TransInfo *t, float mouse_dir_constraint[3]);
|
extern TransModeInfo TransMode_resize;
|
||||||
|
|
||||||
/* transform_mode_rotate.c */
|
/* transform_mode_rotate.c */
|
||||||
|
|
||||||
void initRotation(TransInfo *t);
|
extern TransModeInfo TransMode_rotate;
|
||||||
|
|
||||||
/* transform_mode_shear.c */
|
/* transform_mode_shear.c */
|
||||||
|
|
||||||
void initShear(TransInfo *t);
|
extern TransModeInfo TransMode_shear;
|
||||||
|
|
||||||
/* transform_mode_shrink_fatten.c */
|
/* transform_mode_shrink_fatten.c */
|
||||||
|
|
||||||
void initShrinkFatten(TransInfo *t);
|
extern TransModeInfo TransMode_shrinkfatten;
|
||||||
|
|
||||||
/* transform_mode_skin_resize.c */
|
/* transform_mode_skin_resize.c */
|
||||||
|
|
||||||
void initSkinResize(TransInfo *t);
|
extern TransModeInfo TransMode_skinresize;
|
||||||
|
|
||||||
/* transform_mode_tilt.c */
|
/* transform_mode_tilt.c */
|
||||||
|
|
||||||
void initTilt(TransInfo *t);
|
extern TransModeInfo TransMode_tilt;
|
||||||
|
|
||||||
/* transform_mode_timescale.c */
|
/* transform_mode_timescale.c */
|
||||||
|
|
||||||
void initTimeScale(TransInfo *t);
|
extern TransModeInfo TransMode_timescale;
|
||||||
|
|
||||||
/* transform_mode_timeslide.c */
|
/* transform_mode_timeslide.c */
|
||||||
|
|
||||||
void initTimeSlide(TransInfo *t);
|
extern TransModeInfo TransMode_timeslide;
|
||||||
|
|
||||||
/* transform_mode_timetranslate.c */
|
/* transform_mode_timetranslate.c */
|
||||||
|
|
||||||
void initTimeTranslate(TransInfo *t);
|
extern TransModeInfo TransMode_timetranslate;
|
||||||
|
|
||||||
/* transform_mode_tosphere.c */
|
/* transform_mode_tosphere.c */
|
||||||
|
|
||||||
void initToSphere(TransInfo *t);
|
extern TransModeInfo TransMode_tosphere;
|
||||||
|
|
||||||
/* transform_mode_trackball.c */
|
/* transform_mode_trackball.c */
|
||||||
|
|
||||||
void initTrackball(TransInfo *t);
|
extern TransModeInfo TransMode_trackball;
|
||||||
|
|
||||||
/* transform_mode_translate.c */
|
/* transform_mode_translate.c */
|
||||||
|
|
||||||
void initTranslation(TransInfo *t);
|
extern TransModeInfo TransMode_translate;
|
||||||
|
|
||||||
/* transform_mode_vert_slide.c */
|
/* transform_mode_vert_slide.c */
|
||||||
|
|
||||||
void drawVertSlide(TransInfo *t);
|
extern TransModeInfo TransMode_vertslide;
|
||||||
void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp);
|
|
||||||
void initVertSlide(TransInfo *t);
|
|
||||||
void transform_mode_vert_slide_reproject_input(TransInfo *t);
|
void transform_mode_vert_slide_reproject_input(TransInfo *t);
|
||||||
|
|
|
@ -66,13 +66,20 @@ static void applyAlign(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, TIP_("Align"));
|
ED_area_status_text(t->area, TIP_("Align"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void initAlign(TransInfo *t)
|
static void initAlign(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
|
|
||||||
t->transform = applyAlign;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_align = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initAlign,
|
||||||
|
/*transform_fn*/ applyAlign,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -103,9 +103,8 @@ static void applyBakeTime(TransInfo *t, const int mval[2])
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initBakeTime(TransInfo *t)
|
static void initBakeTime(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->transform = applyBakeTime;
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
||||||
|
|
||||||
t->idx_max = 0;
|
t->idx_max = 0;
|
||||||
|
@ -119,3 +118,14 @@ void initBakeTime(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_baketime = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initBakeTime,
|
||||||
|
/*transform_fn*/ applyBakeTime,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -148,10 +148,9 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initBoneSize(TransInfo *t)
|
static void initBoneSize(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_BONESIZE;
|
t->mode = TFM_BONESIZE;
|
||||||
t->transform = applyBoneSize;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
||||||
|
|
||||||
|
@ -172,3 +171,14 @@ void initBoneSize(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_bboneresize = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initBoneSize,
|
||||||
|
/*transform_fn*/ applyBoneSize,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -324,7 +324,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initBend(TransInfo *t)
|
static void initBend(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
const float mval_fl[2] = {UNPACK2(t->mval)};
|
const float mval_fl[2] = {UNPACK2(t->mval)};
|
||||||
const float *curs;
|
const float *curs;
|
||||||
|
@ -332,8 +332,6 @@ void initBend(TransInfo *t)
|
||||||
struct BendCustomData *data;
|
struct BendCustomData *data;
|
||||||
|
|
||||||
t->mode = TFM_BEND;
|
t->mode = TFM_BEND;
|
||||||
t->transform = Bend;
|
|
||||||
t->handleEvent = handleEventBend;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_ANGLE_SPRING);
|
initMouseInputMode(t, &t->mouse, INPUT_ANGLE_SPRING);
|
||||||
|
|
||||||
|
@ -348,8 +346,6 @@ void initBend(TransInfo *t)
|
||||||
t->num.unit_type[0] = B_UNIT_ROTATION;
|
t->num.unit_type[0] = B_UNIT_ROTATION;
|
||||||
t->num.unit_type[1] = B_UNIT_LENGTH;
|
t->num.unit_type[1] = B_UNIT_LENGTH;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
|
|
||||||
// copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
|
// copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
|
||||||
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
|
if ((t->flag & T_OVERRIDE_CENTER) == 0) {
|
||||||
calculateCenterCursor(t, t->center_global);
|
calculateCenterCursor(t, t->center_global);
|
||||||
|
@ -378,3 +374,14 @@ void initBend(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_bend = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initBend,
|
||||||
|
/*transform_fn*/ Bend,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ handleEventBend,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -79,10 +79,8 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initBoneEnvelope(TransInfo *t)
|
static void initBoneEnvelope(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->transform = applyBoneEnvelope;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
||||||
|
|
||||||
t->idx_max = 0;
|
t->idx_max = 0;
|
||||||
|
@ -93,8 +91,17 @@ void initBoneEnvelope(TransInfo *t)
|
||||||
copy_v3_fl(t->num.val_inc, t->snap[0]);
|
copy_v3_fl(t->num.val_inc, t->snap[0]);
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_type[0] = B_UNIT_NONE;
|
t->num.unit_type[0] = B_UNIT_NONE;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_boneenvelope = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
|
||||||
|
/*init_fn*/ initBoneEnvelope,
|
||||||
|
/*transform_fn*/ applyBoneEnvelope,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -73,10 +73,9 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initBoneRoll(TransInfo *t)
|
static void initBoneRoll(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_BONE_ROLL;
|
t->mode = TFM_BONE_ROLL;
|
||||||
t->transform = applyBoneRoll;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
||||||
|
|
||||||
|
@ -89,8 +88,17 @@ void initBoneRoll(TransInfo *t)
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
|
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
|
||||||
t->num.unit_type[0] = B_UNIT_ROTATION;
|
t->num.unit_type[0] = B_UNIT_ROTATION;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_boneroll = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
|
||||||
|
/*init_fn*/ initBoneRoll,
|
||||||
|
/*transform_fn*/ applyBoneRoll,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -84,10 +84,9 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initCurveShrinkFatten(TransInfo *t)
|
static void initCurveShrinkFatten(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_CURVE_SHRINKFATTEN;
|
t->mode = TFM_CURVE_SHRINKFATTEN;
|
||||||
t->transform = applyCurveShrinkFatten;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
||||||
|
|
||||||
|
@ -100,8 +99,6 @@ void initCurveShrinkFatten(TransInfo *t)
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_type[0] = B_UNIT_NONE;
|
t->num.unit_type[0] = B_UNIT_NONE;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
|
|
||||||
float scale_factor = 0.0f;
|
float scale_factor = 0.0f;
|
||||||
if (((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW) &&
|
if (((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW) &&
|
||||||
(t->data_len_all == 1)) ||
|
(t->data_len_all == 1)) ||
|
||||||
|
@ -117,3 +114,14 @@ void initCurveShrinkFatten(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_curveshrinkfatten = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initCurveShrinkFatten,
|
||||||
|
/*transform_fn*/ applyCurveShrinkFatten,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -159,29 +159,57 @@ static void init_mode_impl(TransInfo *t)
|
||||||
copy_v3_fl(t->num.val_inc, t->snap[0]);
|
copy_v3_fl(t->num.val_inc, t->snap[0]);
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_type[0] = B_UNIT_NONE;
|
t->num.unit_type[0] = B_UNIT_NONE;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initEgdeCrease(TransInfo *t)
|
static void initEgdeCrease(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
init_mode_impl(t);
|
init_mode_impl(t);
|
||||||
t->mode = TFM_EDGE_CREASE;
|
t->mode = TFM_EDGE_CREASE;
|
||||||
t->transform = applyCrease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initVertCrease(TransInfo *t)
|
static void initVertCrease(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
init_mode_impl(t);
|
init_mode_impl(t);
|
||||||
t->mode = TFM_VERT_CREASE;
|
t->mode = TFM_VERT_CREASE;
|
||||||
t->transform = applyCrease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initBevelWeight(TransInfo *t)
|
static void initBevelWeight(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
init_mode_impl(t);
|
init_mode_impl(t);
|
||||||
t->mode = TFM_BWEIGHT;
|
t->mode = TFM_BWEIGHT;
|
||||||
t->transform = applyBevelWeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_edgecrease = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
|
||||||
|
/*init_fn*/ initEgdeCrease,
|
||||||
|
/*transform_fn*/ applyCrease,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
TransModeInfo TransMode_vertcrease = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
|
||||||
|
/*init_fn*/ initVertCrease,
|
||||||
|
/*transform_fn*/ applyCrease,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
TransModeInfo TransMode_bevelweight = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
|
||||||
|
/*init_fn*/ initBevelWeight,
|
||||||
|
/*transform_fn*/ applyBevelWeight,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -108,10 +108,9 @@ static void applyNormalRotation(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initNormalRotation(TransInfo *t)
|
static void initNormalRotation(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_NORMAL_ROTATION;
|
t->mode = TFM_NORMAL_ROTATION;
|
||||||
t->transform = applyNormalRotation;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
||||||
|
|
||||||
|
@ -139,3 +138,14 @@ void initNormalRotation(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_rotatenormal = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initNormalRotation,
|
||||||
|
/*transform_fn*/ applyNormalRotation,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -108,11 +108,8 @@ static void applySeqSlide(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSeqSlide(TransInfo *t)
|
static void initSeqSlide(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->transform = applySeqSlide;
|
|
||||||
t->tsnap.snap_mode_apply_fn = transform_snap_sequencer_apply_translate;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
|
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
|
||||||
|
|
||||||
t->idx_max = 1;
|
t->idx_max = 1;
|
||||||
|
@ -136,3 +133,14 @@ void initSeqSlide(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_seqslide = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initSeqSlide,
|
||||||
|
/*transform_fn*/ applySeqSlide,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ transform_snap_sequencer_apply_translate,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
#include "WM_types.h"
|
#include "WM_types.h"
|
||||||
|
|
||||||
|
#include "RNA_access.h"
|
||||||
|
|
||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
|
|
||||||
|
@ -1081,7 +1083,6 @@ static void freeEdgeSlideVerts(TransInfo *UNUSED(t),
|
||||||
|
|
||||||
static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
|
static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
|
||||||
{
|
{
|
||||||
if (t->mode == TFM_EDGE_SLIDE) {
|
|
||||||
EdgeSlideParams *slp = t->custom.mode.data;
|
EdgeSlideParams *slp = t->custom.mode.data;
|
||||||
|
|
||||||
if (slp) {
|
if (slp) {
|
||||||
|
@ -1115,16 +1116,11 @@ static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEven
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return TREDRAW_NOTHING;
|
return TREDRAW_NOTHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawEdgeSlide(TransInfo *t)
|
static void drawEdgeSlide(TransInfo *t)
|
||||||
{
|
{
|
||||||
if (t->mode != TFM_EDGE_SLIDE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeSlideData *sld = edgeSlideFirstGet(t);
|
EdgeSlideData *sld = edgeSlideFirstGet(t);
|
||||||
if (sld == NULL) {
|
if (sld == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -1484,18 +1480,13 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initEdgeSlide_ex(
|
static void initEdgeSlide_ex(
|
||||||
TransInfo *t, bool use_double_side, bool use_even, bool flipped, bool use_clamp)
|
TransInfo *t, bool use_double_side, bool use_even, bool flipped, bool use_clamp)
|
||||||
{
|
{
|
||||||
EdgeSlideData *sld;
|
EdgeSlideData *sld;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
t->mode = TFM_EDGE_SLIDE;
|
t->mode = TFM_EDGE_SLIDE;
|
||||||
t->transform = applyEdgeSlide;
|
|
||||||
t->handleEvent = handleEventEdgeSlide;
|
|
||||||
t->transform_matrix = NULL;
|
|
||||||
t->tsnap.snap_mode_apply_fn = edge_slide_snap_apply;
|
|
||||||
t->tsnap.snap_mode_distance_fn = transform_snap_distance_len_squared_fn;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
EdgeSlideParams *slp = MEM_callocN(sizeof(*slp), __func__);
|
EdgeSlideParams *slp = MEM_callocN(sizeof(*slp), __func__);
|
||||||
|
@ -1542,13 +1533,21 @@ void initEdgeSlide_ex(
|
||||||
copy_v3_fl(t->num.val_inc, t->snap[0]);
|
copy_v3_fl(t->num.val_inc, t->snap[0]);
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_type[0] = B_UNIT_NONE;
|
t->num.unit_type[0] = B_UNIT_NONE;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initEdgeSlide(TransInfo *t)
|
static void initEdgeSlide(TransInfo *t, wmOperator *op)
|
||||||
{
|
{
|
||||||
initEdgeSlide_ex(t, true, false, false, true);
|
bool use_double_side = true;
|
||||||
|
bool use_even = false;
|
||||||
|
bool flipped = false;
|
||||||
|
bool use_clamp = true;
|
||||||
|
if (op) {
|
||||||
|
use_double_side = !RNA_boolean_get(op->ptr, "single_side");
|
||||||
|
use_even = RNA_boolean_get(op->ptr, "use_even");
|
||||||
|
flipped = RNA_boolean_get(op->ptr, "flipped");
|
||||||
|
use_clamp = RNA_boolean_get(op->ptr, "use_clamp");
|
||||||
|
}
|
||||||
|
initEdgeSlide_ex(t, use_double_side, use_even, flipped, use_clamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -1581,3 +1580,14 @@ void transform_mode_edge_slide_reproject_input(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_edgeslide = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
|
||||||
|
/*init_fn*/ initEdgeSlide,
|
||||||
|
/*transform_fn*/ applyEdgeSlide,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ handleEventEdgeSlide,
|
||||||
|
/*snap_distance_fn*/ transform_snap_distance_len_squared_fn,
|
||||||
|
/*snap_apply_fn*/ edge_slide_snap_apply,
|
||||||
|
/*draw_fn*/ drawEdgeSlide,
|
||||||
|
};
|
||||||
|
|
|
@ -88,10 +88,9 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initGPOpacity(TransInfo *t)
|
static void initGPOpacity(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_GPENCIL_OPACITY;
|
t->mode = TFM_GPENCIL_OPACITY;
|
||||||
t->transform = applyGPOpacity;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
||||||
|
|
||||||
|
@ -107,8 +106,17 @@ void initGPOpacity(TransInfo *t)
|
||||||
#ifdef USE_NUM_NO_ZERO
|
#ifdef USE_NUM_NO_ZERO
|
||||||
t->num.val_flag[0] |= NUM_NO_ZERO;
|
t->num.val_flag[0] |= NUM_NO_ZERO;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_gpopacity = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initGPOpacity,
|
||||||
|
/*transform_fn*/ applyGPOpacity,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -90,10 +90,9 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initGPShrinkFatten(TransInfo *t)
|
static void initGPShrinkFatten(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_GPENCIL_SHRINKFATTEN;
|
t->mode = TFM_GPENCIL_SHRINKFATTEN;
|
||||||
t->transform = applyGPShrinkFatten;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
||||||
|
|
||||||
|
@ -109,8 +108,17 @@ void initGPShrinkFatten(TransInfo *t)
|
||||||
#ifdef USE_NUM_NO_ZERO
|
#ifdef USE_NUM_NO_ZERO
|
||||||
t->num.val_flag[0] |= NUM_NO_ZERO;
|
t->num.val_flag[0] |= NUM_NO_ZERO;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_gpshrinkfatten = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initGPShrinkFatten,
|
||||||
|
/*transform_fn*/ applyGPShrinkFatten,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -104,10 +104,9 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initMaskShrinkFatten(TransInfo *t)
|
static void initMaskShrinkFatten(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_MASK_SHRINKFATTEN;
|
t->mode = TFM_MASK_SHRINKFATTEN;
|
||||||
t->transform = applyMaskShrinkFatten;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
||||||
|
|
||||||
|
@ -123,8 +122,17 @@ void initMaskShrinkFatten(TransInfo *t)
|
||||||
#ifdef USE_NUM_NO_ZERO
|
#ifdef USE_NUM_NO_ZERO
|
||||||
t->num.val_flag[0] |= NUM_NO_ZERO;
|
t->num.val_flag[0] |= NUM_NO_ZERO;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_maskshrinkfatten = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initMaskShrinkFatten,
|
||||||
|
/*transform_fn*/ applyMaskShrinkFatten,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -216,12 +216,20 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initMirror(TransInfo *t)
|
static void initMirror(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->transform = applyMirror;
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
||||||
|
|
||||||
t->flag |= T_NULL_ONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_mirror = {
|
||||||
|
/*flags*/ T_NULL_ONE,
|
||||||
|
/*init_fn*/ initMirror,
|
||||||
|
/*transform_fn*/ applyMirror,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -169,10 +169,9 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initPushPull(TransInfo *t)
|
static void initPushPull(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_PUSHPULL;
|
t->mode = TFM_PUSHPULL;
|
||||||
t->transform = applyPushPull;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
|
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
|
||||||
|
|
||||||
|
@ -187,3 +186,14 @@ void initPushPull(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_pushpull = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initPushPull,
|
||||||
|
/*transform_fn*/ applyPushPull,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "DNA_windowmanager_types.h"
|
||||||
|
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_task.h"
|
#include "BLI_task.h"
|
||||||
|
|
||||||
|
@ -17,6 +19,8 @@
|
||||||
|
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
|
|
||||||
|
#include "RNA_access.h"
|
||||||
|
|
||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
|
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
|
@ -282,13 +286,22 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initResize(TransInfo *t, float mouse_dir_constraint[3])
|
static void initResize(TransInfo *t, wmOperator *op)
|
||||||
{
|
{
|
||||||
t->mode = TFM_RESIZE;
|
float mouse_dir_constraint[3];
|
||||||
t->transform = applyResize;
|
if (op) {
|
||||||
t->transform_matrix = NULL;
|
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "mouse_dir_constraint");
|
||||||
t->tsnap.snap_mode_apply_fn = ApplySnapResize;
|
if (prop) {
|
||||||
t->tsnap.snap_mode_distance_fn = ResizeBetween;
|
RNA_property_float_get_array(op->ptr, prop, mouse_dir_constraint);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Resize is expected to have this property. */
|
||||||
|
BLI_assert(!STREQ(op->idname, "TRANSFORM_OT_resize"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
zero_v3(mouse_dir_constraint);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_zero_v3(mouse_dir_constraint)) {
|
if (is_zero_v3(mouse_dir_constraint)) {
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
||||||
|
@ -323,7 +336,6 @@ void initResize(TransInfo *t, float mouse_dir_constraint[3])
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO);
|
initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
t->flag |= T_NULL_ONE;
|
|
||||||
t->num.val_flag[0] |= NUM_NULL_ONE;
|
t->num.val_flag[0] |= NUM_NULL_ONE;
|
||||||
t->num.val_flag[1] |= NUM_NULL_ONE;
|
t->num.val_flag[1] |= NUM_NULL_ONE;
|
||||||
t->num.val_flag[2] |= NUM_NULL_ONE;
|
t->num.val_flag[2] |= NUM_NULL_ONE;
|
||||||
|
@ -351,3 +363,14 @@ void initResize(TransInfo *t, float mouse_dir_constraint[3])
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_resize = {
|
||||||
|
/*flags*/ T_NULL_ONE,
|
||||||
|
/*init_fn*/ initResize,
|
||||||
|
/*transform_fn*/ applyResize,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ ResizeBetween,
|
||||||
|
/*snap_apply_fn*/ ApplySnapResize,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -405,7 +405,7 @@ static void applyRotationMatrix(TransInfo *t, float mat_xform[4][4])
|
||||||
mul_m4_m4m4(mat_xform, mat4, mat_xform);
|
mul_m4_m4m4(mat_xform, mat4, mat_xform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initRotation(TransInfo *t)
|
static void initRotation(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
if (t->spacetype == SPACE_ACTION) {
|
if (t->spacetype == SPACE_ACTION) {
|
||||||
BKE_report(t->reports, RPT_ERROR, "Rotation is not supported in the Dope Sheet Editor");
|
BKE_report(t->reports, RPT_ERROR, "Rotation is not supported in the Dope Sheet Editor");
|
||||||
|
@ -413,10 +413,6 @@ void initRotation(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
t->mode = TFM_ROTATION;
|
t->mode = TFM_ROTATION;
|
||||||
t->transform = applyRotation;
|
|
||||||
t->transform_matrix = applyRotationMatrix;
|
|
||||||
t->tsnap.snap_mode_apply_fn = ApplySnapRotation;
|
|
||||||
t->tsnap.snap_mode_distance_fn = RotationBetween;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
||||||
|
|
||||||
|
@ -438,3 +434,14 @@ void initRotation(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_rotate = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initRotation,
|
||||||
|
/*transform_fn*/ applyRotation,
|
||||||
|
/*transform_matrix_fn*/ applyRotationMatrix,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ RotationBetween,
|
||||||
|
/*snap_apply_fn*/ ApplySnapRotation,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -320,11 +320,9 @@ static void apply_shear(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initShear(TransInfo *t)
|
static void initShear(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_SHEAR;
|
t->mode = TFM_SHEAR;
|
||||||
t->transform = apply_shear;
|
|
||||||
t->handleEvent = handleEventShear;
|
|
||||||
|
|
||||||
if (t->orient_axis == t->orient_axis_ortho) {
|
if (t->orient_axis == t->orient_axis_ortho) {
|
||||||
t->orient_axis = 2;
|
t->orient_axis = 2;
|
||||||
|
@ -342,9 +340,18 @@ void initShear(TransInfo *t)
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_type[0] = B_UNIT_NONE; /* Don't think we have any unit here? */
|
t->num.unit_type[0] = B_UNIT_NONE; /* Don't think we have any unit here? */
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
|
|
||||||
transform_mode_default_modal_orientation_set(t, V3D_ORIENT_VIEW);
|
transform_mode_default_modal_orientation_set(t, V3D_ORIENT_VIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_shear = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initShear,
|
||||||
|
/*transform_fn*/ apply_shear,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ handleEventShear,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -170,7 +170,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initShrinkFatten(TransInfo *t)
|
static void initShrinkFatten(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
if ((t->flag & T_EDIT) == 0 || (t->obedit_type != OB_MESH)) {
|
if ((t->flag & T_EDIT) == 0 || (t->obedit_type != OB_MESH)) {
|
||||||
BKE_report(t->reports, RPT_ERROR, "'Shrink/Fatten' meshes is only supported in edit mode");
|
BKE_report(t->reports, RPT_ERROR, "'Shrink/Fatten' meshes is only supported in edit mode");
|
||||||
|
@ -178,8 +178,6 @@ void initShrinkFatten(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
t->mode = TFM_SHRINKFATTEN;
|
t->mode = TFM_SHRINKFATTEN;
|
||||||
t->transform = applyShrinkFatten;
|
|
||||||
t->handleEvent = shrinkfatten_handleEvent;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
|
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
|
||||||
|
|
||||||
|
@ -192,8 +190,6 @@ void initShrinkFatten(TransInfo *t)
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_type[0] = B_UNIT_LENGTH;
|
t->num.unit_type[0] = B_UNIT_LENGTH;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
|
|
||||||
if (t->keymap) {
|
if (t->keymap) {
|
||||||
/* Workaround to use the same key as the modal keymap. */
|
/* Workaround to use the same key as the modal keymap. */
|
||||||
t->custom.mode.data = (void *)WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE);
|
t->custom.mode.data = (void *)WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE);
|
||||||
|
@ -201,3 +197,14 @@ void initShrinkFatten(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_shrinkfatten = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initShrinkFatten,
|
||||||
|
/*transform_fn*/ applyShrinkFatten,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ shrinkfatten_handleEvent,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -134,10 +134,9 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSkinResize(TransInfo *t)
|
static void initSkinResize(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_SKIN_RESIZE;
|
t->mode = TFM_SKIN_RESIZE;
|
||||||
t->transform = applySkinResize;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
||||||
|
|
||||||
|
@ -167,3 +166,14 @@ void initSkinResize(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_skinresize = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initSkinResize,
|
||||||
|
/*transform_fn*/ applySkinResize,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -77,10 +77,9 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTilt(TransInfo *t)
|
static void initTilt(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_TILT;
|
t->mode = TFM_TILT;
|
||||||
t->transform = applyTilt;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
|
||||||
|
|
||||||
|
@ -93,8 +92,17 @@ void initTilt(TransInfo *t)
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
|
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
|
||||||
t->num.unit_type[0] = B_UNIT_ROTATION;
|
t->num.unit_type[0] = B_UNIT_ROTATION;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_tilt = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
|
||||||
|
/*init_fn*/ initTilt,
|
||||||
|
/*transform_fn*/ applyTilt,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -94,7 +94,7 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTimeScale(TransInfo *t)
|
static void initTimeScale(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
float center[2];
|
float center[2];
|
||||||
|
|
||||||
|
@ -106,7 +106,6 @@ void initTimeScale(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
t->mode = TFM_TIME_SCALE;
|
t->mode = TFM_TIME_SCALE;
|
||||||
t->transform = applyTimeScale;
|
|
||||||
|
|
||||||
/* recalculate center2d to use scene->r.cfra and mouse Y, since that's
|
/* recalculate center2d to use scene->r.cfra and mouse Y, since that's
|
||||||
* what is used in time scale */
|
* what is used in time scale */
|
||||||
|
@ -121,7 +120,6 @@ void initTimeScale(TransInfo *t)
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
|
||||||
|
|
||||||
t->flag |= T_NULL_ONE;
|
|
||||||
t->num.val_flag[0] |= NUM_NULL_ONE;
|
t->num.val_flag[0] |= NUM_NULL_ONE;
|
||||||
|
|
||||||
/* Numeric-input has max of (n-1). */
|
/* Numeric-input has max of (n-1). */
|
||||||
|
@ -138,3 +136,14 @@ void initTimeScale(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_timescale = {
|
||||||
|
/*flags*/ T_NULL_ONE,
|
||||||
|
/*init_fn*/ initTimeScale,
|
||||||
|
/*transform_fn*/ applyTimeScale,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -148,7 +148,7 @@ static void applyTimeSlide(TransInfo *t, const int mval[2])
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTimeSlide(TransInfo *t)
|
static void initTimeSlide(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
/* this tool is only really available in the Action Editor... */
|
/* this tool is only really available in the Action Editor... */
|
||||||
if (t->spacetype == SPACE_ACTION) {
|
if (t->spacetype == SPACE_ACTION) {
|
||||||
|
@ -162,7 +162,6 @@ void initTimeSlide(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
t->mode = TFM_TIME_SLIDE;
|
t->mode = TFM_TIME_SLIDE;
|
||||||
t->transform = applyTimeSlide;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
||||||
|
|
||||||
|
@ -219,3 +218,14 @@ void initTimeSlide(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_timeslide = {
|
||||||
|
/*flags*/ T_NULL_ONE,
|
||||||
|
/*init_fn*/ initTimeSlide,
|
||||||
|
/*transform_fn*/ applyTimeSlide,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -119,15 +119,13 @@ static void applyTimeTranslate(TransInfo *t, const int mval[2])
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTimeTranslate(TransInfo *t)
|
static void initTimeTranslate(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
/* this tool is only really available in the Action Editor... */
|
/* this tool is only really available in the Action Editor... */
|
||||||
if (!ELEM(t->spacetype, SPACE_ACTION, SPACE_SEQ)) {
|
if (!ELEM(t->spacetype, SPACE_ACTION, SPACE_SEQ)) {
|
||||||
t->state = TRANS_CANCEL;
|
t->state = TRANS_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
t->transform = applyTimeTranslate;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
initMouseInputMode(t, &t->mouse, INPUT_NONE);
|
||||||
|
|
||||||
/* Numeric-input has max of (n-1). */
|
/* Numeric-input has max of (n-1). */
|
||||||
|
@ -145,3 +143,14 @@ void initTimeTranslate(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_timetranslate = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initTimeTranslate,
|
||||||
|
/*transform_fn*/ applyTimeTranslate,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -237,10 +237,9 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initToSphere(TransInfo *t)
|
static void initToSphere(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_TOSPHERE;
|
t->mode = TFM_TOSPHERE;
|
||||||
t->transform = applyToSphere;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
|
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
|
||||||
|
|
||||||
|
@ -254,7 +253,6 @@ void initToSphere(TransInfo *t)
|
||||||
t->num.unit_type[0] = B_UNIT_NONE;
|
t->num.unit_type[0] = B_UNIT_NONE;
|
||||||
|
|
||||||
t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
|
t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
|
|
||||||
struct ToSphereInfo *data = MEM_callocN(sizeof(*data), __func__);
|
struct ToSphereInfo *data = MEM_callocN(sizeof(*data), __func__);
|
||||||
t->custom.mode.data = data;
|
t->custom.mode.data = data;
|
||||||
|
@ -264,3 +262,14 @@ void initToSphere(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_tosphere = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initToSphere,
|
||||||
|
/*transform_fn*/ applyToSphere,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -187,11 +187,9 @@ static void applyTrackballMatrix(TransInfo *t, float mat_xform[4][4])
|
||||||
mul_m4_m4m4(mat_xform, mat4, mat_xform);
|
mul_m4_m4m4(mat_xform, mat4, mat_xform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTrackball(TransInfo *t)
|
static void initTrackball(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
t->mode = TFM_TRACKBALL;
|
t->mode = TFM_TRACKBALL;
|
||||||
t->transform = applyTrackball;
|
|
||||||
t->transform_matrix = applyTrackballMatrix;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL);
|
initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL);
|
||||||
|
|
||||||
|
@ -205,8 +203,17 @@ void initTrackball(TransInfo *t)
|
||||||
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
|
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
|
||||||
t->num.unit_type[0] = B_UNIT_ROTATION;
|
t->num.unit_type[0] = B_UNIT_ROTATION;
|
||||||
t->num.unit_type[1] = B_UNIT_ROTATION;
|
t->num.unit_type[1] = B_UNIT_ROTATION;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_trackball = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT,
|
||||||
|
/*init_fn*/ initTrackball,
|
||||||
|
/*transform_fn*/ applyTrackball,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ NULL,
|
||||||
|
/*snap_apply_fn*/ NULL,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -666,7 +666,7 @@ static void applyTranslationMatrix(TransInfo *t, float mat_xform[4][4])
|
||||||
add_v3_v3(mat_xform[3], delta);
|
add_v3_v3(mat_xform[3], delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTranslation(TransInfo *t)
|
static void initTranslation(TransInfo *t, struct wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
if (t->spacetype == SPACE_ACTION) {
|
if (t->spacetype == SPACE_ACTION) {
|
||||||
/* this space uses time translate */
|
/* this space uses time translate */
|
||||||
|
@ -675,13 +675,9 @@ void initTranslation(TransInfo *t)
|
||||||
"Use 'Time_Translate' transform mode instead of 'Translation' mode "
|
"Use 'Time_Translate' transform mode instead of 'Translation' mode "
|
||||||
"for translating keyframes in Dope Sheet Editor");
|
"for translating keyframes in Dope Sheet Editor");
|
||||||
t->state = TRANS_CANCEL;
|
t->state = TRANS_CANCEL;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
t->transform = applyTranslation;
|
|
||||||
t->transform_matrix = applyTranslationMatrix;
|
|
||||||
t->tsnap.snap_mode_apply_fn = ApplySnapTranslation;
|
|
||||||
t->tsnap.snap_mode_distance_fn = transform_snap_distance_len_squared_fn;
|
|
||||||
|
|
||||||
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
|
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
|
||||||
|
|
||||||
t->idx_max = (t->flag & T_2D_EDIT) ? 1 : 2;
|
t->idx_max = (t->flag & T_2D_EDIT) ? 1 : 2;
|
||||||
|
@ -716,3 +712,14 @@ void initTranslation(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_translate = {
|
||||||
|
/*flags*/ 0,
|
||||||
|
/*init_fn*/ initTranslation,
|
||||||
|
/*transform_fn*/ applyTranslation,
|
||||||
|
/*transform_matrix_fn*/ applyTranslationMatrix,
|
||||||
|
/*handle_event_fn*/ NULL,
|
||||||
|
/*snap_distance_fn*/ transform_snap_distance_len_squared_fn,
|
||||||
|
/*snap_apply_fn*/ ApplySnapTranslation,
|
||||||
|
/*draw_fn*/ NULL,
|
||||||
|
};
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
#include "WM_types.h"
|
#include "WM_types.h"
|
||||||
|
|
||||||
|
#include "RNA_access.h"
|
||||||
|
|
||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
|
|
||||||
|
@ -304,7 +306,6 @@ static void freeVertSlideVerts(TransInfo *UNUSED(t),
|
||||||
|
|
||||||
static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
|
static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
|
||||||
{
|
{
|
||||||
if (t->mode == TFM_VERT_SLIDE) {
|
|
||||||
VertSlideParams *slp = t->custom.mode.data;
|
VertSlideParams *slp = t->custom.mode.data;
|
||||||
|
|
||||||
if (slp) {
|
if (slp) {
|
||||||
|
@ -346,13 +347,12 @@ static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEven
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return TREDRAW_NOTHING;
|
return TREDRAW_NOTHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawVertSlide(TransInfo *t)
|
static void drawVertSlide(TransInfo *t)
|
||||||
{
|
{
|
||||||
if ((t->mode == TFM_VERT_SLIDE) && TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data) {
|
if (TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data) {
|
||||||
const VertSlideParams *slp = t->custom.mode.data;
|
const VertSlideParams *slp = t->custom.mode.data;
|
||||||
VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
|
VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data;
|
||||||
const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
|
const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
|
||||||
|
@ -610,15 +610,10 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
|
||||||
ED_area_status_text(t->area, str);
|
ED_area_status_text(t->area, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
|
static void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
|
||||||
{
|
{
|
||||||
|
|
||||||
t->mode = TFM_VERT_SLIDE;
|
t->mode = TFM_VERT_SLIDE;
|
||||||
t->transform = applyVertSlide;
|
|
||||||
t->handleEvent = handleEventVertSlide;
|
|
||||||
t->transform_matrix = NULL;
|
|
||||||
t->tsnap.snap_mode_apply_fn = vert_slide_snap_apply;
|
|
||||||
t->tsnap.snap_mode_distance_fn = transform_snap_distance_len_squared_fn;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
VertSlideParams *slp = MEM_callocN(sizeof(*slp), __func__);
|
VertSlideParams *slp = MEM_callocN(sizeof(*slp), __func__);
|
||||||
|
@ -664,13 +659,19 @@ void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp)
|
||||||
copy_v3_fl(t->num.val_inc, t->snap[0]);
|
copy_v3_fl(t->num.val_inc, t->snap[0]);
|
||||||
t->num.unit_sys = t->scene->unit.system;
|
t->num.unit_sys = t->scene->unit.system;
|
||||||
t->num.unit_type[0] = B_UNIT_NONE;
|
t->num.unit_type[0] = B_UNIT_NONE;
|
||||||
|
|
||||||
t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initVertSlide(TransInfo *t)
|
static void initVertSlide(TransInfo *t, wmOperator *op)
|
||||||
{
|
{
|
||||||
initVertSlide_ex(t, false, false, true);
|
bool use_even = false;
|
||||||
|
bool flipped = false;
|
||||||
|
bool use_clamp = true;
|
||||||
|
if (op) {
|
||||||
|
use_even = RNA_boolean_get(op->ptr, "use_even");
|
||||||
|
flipped = RNA_boolean_get(op->ptr, "flipped");
|
||||||
|
use_clamp = RNA_boolean_get(op->ptr, "use_clamp");
|
||||||
|
}
|
||||||
|
initVertSlide_ex(t, use_even, flipped, use_clamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -693,3 +694,14 @@ void transform_mode_vert_slide_reproject_input(TransInfo *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
TransModeInfo TransMode_vertslide = {
|
||||||
|
/*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
|
||||||
|
/*init_fn*/ initVertSlide,
|
||||||
|
/*transform_fn*/ applyVertSlide,
|
||||||
|
/*transform_matrix_fn*/ NULL,
|
||||||
|
/*handle_event_fn*/ handleEventVertSlide,
|
||||||
|
/*snap_distance_fn*/ transform_snap_distance_len_squared_fn,
|
||||||
|
/*snap_apply_fn*/ vert_slide_snap_apply,
|
||||||
|
/*draw_fn*/ drawVertSlide,
|
||||||
|
};
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
|
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
#include "transform_convert.h"
|
#include "transform_convert.h"
|
||||||
|
#include "transform_mode.h"
|
||||||
#include "transform_snap.h"
|
#include "transform_snap.h"
|
||||||
|
|
||||||
/* use half of flt-max so we can scale up without an exception */
|
/* use half of flt-max so we can scale up without an exception */
|
||||||
|
@ -546,7 +547,7 @@ void transform_snap_mixed_apply(TransInfo *t, float *vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validSnap(t)) {
|
if (validSnap(t)) {
|
||||||
t->tsnap.snap_mode_apply_fn(t, vec);
|
t->mode_info->snap_apply_fn(t, vec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1317,7 +1318,7 @@ static void snap_source_closest_fn(TransInfo *t)
|
||||||
copy_v3_v3(loc, bb->vec[j]);
|
copy_v3_v3(loc, bb->vec[j]);
|
||||||
mul_m4_v3(td->ext->obmat, loc);
|
mul_m4_v3(td->ext->obmat, loc);
|
||||||
|
|
||||||
dist = t->tsnap.snap_mode_distance_fn(t, loc, t->tsnap.snap_target);
|
dist = t->mode_info->snap_distance_fn(t, loc, t->tsnap.snap_target);
|
||||||
|
|
||||||
if ((dist != TRANSFORM_DIST_INVALID) &&
|
if ((dist != TRANSFORM_DIST_INVALID) &&
|
||||||
(closest == nullptr || fabsf(dist) < fabsf(dist_closest))) {
|
(closest == nullptr || fabsf(dist) < fabsf(dist_closest))) {
|
||||||
|
@ -1334,7 +1335,7 @@ static void snap_source_closest_fn(TransInfo *t)
|
||||||
|
|
||||||
copy_v3_v3(loc, td->center);
|
copy_v3_v3(loc, td->center);
|
||||||
|
|
||||||
dist = t->tsnap.snap_mode_distance_fn(t, loc, t->tsnap.snap_target);
|
dist = t->mode_info->snap_distance_fn(t, loc, t->tsnap.snap_target);
|
||||||
|
|
||||||
if ((dist != TRANSFORM_DIST_INVALID) &&
|
if ((dist != TRANSFORM_DIST_INVALID) &&
|
||||||
(closest == nullptr || fabsf(dist) < fabsf(dist_closest))) {
|
(closest == nullptr || fabsf(dist) < fabsf(dist_closest))) {
|
||||||
|
@ -1359,7 +1360,7 @@ static void snap_source_closest_fn(TransInfo *t)
|
||||||
mul_m4_v3(tc->mat, loc);
|
mul_m4_v3(tc->mat, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
dist = t->tsnap.snap_mode_distance_fn(t, loc, t->tsnap.snap_target);
|
dist = t->mode_info->snap_distance_fn(t, loc, t->tsnap.snap_target);
|
||||||
|
|
||||||
if ((dist != TRANSFORM_DIST_INVALID) &&
|
if ((dist != TRANSFORM_DIST_INVALID) &&
|
||||||
(closest == nullptr || fabsf(dist) < fabsf(dist_closest))) {
|
(closest == nullptr || fabsf(dist) < fabsf(dist_closest))) {
|
||||||
|
|
|
@ -276,7 +276,10 @@ std::optional<Mesh *> mesh_copy_selection(
|
||||||
if (vert_mask.is_empty()) {
|
if (vert_mask.is_empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (vert_mask.size() == src_mesh.totvert) {
|
const bool same_verts = vert_mask.size() == src_mesh.totvert;
|
||||||
|
const bool same_edges = edge_mask.size() == src_mesh.totedge;
|
||||||
|
const bool same_polys = poly_mask.size() == src_mesh.totpoly;
|
||||||
|
if (same_verts && same_edges && same_polys) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,6 +411,12 @@ std::optional<Mesh *> mesh_copy_selection_keep_verts(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool same_edges = edge_mask.size() == src_mesh.totedge;
|
||||||
|
const bool same_polys = poly_mask.size() == src_mesh.totpoly;
|
||||||
|
if (same_edges && same_polys) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
Mesh *dst_mesh = create_mesh_no_attributes(
|
Mesh *dst_mesh = create_mesh_no_attributes(
|
||||||
src_mesh, src_mesh.totvert, edge_mask.size(), poly_mask.size(), 0);
|
src_mesh, src_mesh.totvert, edge_mask.size(), poly_mask.size(), 0);
|
||||||
bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write();
|
bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write();
|
||||||
|
@ -488,6 +497,11 @@ std::optional<Mesh *> mesh_copy_selection_keep_edges(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool same_polys = poly_mask.size() == src_mesh.totpoly;
|
||||||
|
if (same_polys) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
Mesh *dst_mesh = create_mesh_no_attributes(
|
Mesh *dst_mesh = create_mesh_no_attributes(
|
||||||
src_mesh, src_mesh.totvert, src_mesh.totedge, poly_mask.size(), 0);
|
src_mesh, src_mesh.totvert, src_mesh.totedge, poly_mask.size(), 0);
|
||||||
bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write();
|
bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write();
|
||||||
|
|
|
@ -322,7 +322,7 @@ messenger_callback(VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
|
||||||
{
|
{
|
||||||
debugging_tools.print_labels(callback_data);
|
debugging_tools.print_labels(callback_data);
|
||||||
}
|
}
|
||||||
return VK_TRUE;
|
return VK_FALSE;
|
||||||
};
|
};
|
||||||
|
|
||||||
VkResult VKDebuggingTools::init_messenger(VkInstance vk_instance)
|
VkResult VKDebuggingTools::init_messenger(VkInstance vk_instance)
|
||||||
|
|
|
@ -1019,6 +1019,8 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
|
||||||
/* For now, do not allow remapping data in linked data from here... */
|
/* For now, do not allow remapping data in linked data from here... */
|
||||||
BKE_libblock_remap(
|
BKE_libblock_remap(
|
||||||
bmain, id, new_id, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE);
|
bmain, id, new_id, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE);
|
||||||
|
|
||||||
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,11 +238,27 @@ const EnumPropertyItem rna_enum_brush_gpencil_types_items[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const EnumPropertyItem rna_enum_brush_gpencil_vertex_types_items[] = {
|
const EnumPropertyItem rna_enum_brush_gpencil_vertex_types_items[] = {
|
||||||
{GPVERTEX_TOOL_DRAW, "DRAW", ICON_BRUSH_MIX, "Draw", ""},
|
{GPVERTEX_TOOL_DRAW, "DRAW", ICON_BRUSH_MIX, "Draw", "Paint a color on stroke points"},
|
||||||
{GPVERTEX_TOOL_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", ""},
|
{GPVERTEX_TOOL_BLUR,
|
||||||
{GPVERTEX_TOOL_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", ""},
|
"BLUR",
|
||||||
{GPVERTEX_TOOL_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", ""},
|
ICON_BRUSH_BLUR,
|
||||||
{GPVERTEX_TOOL_REPLACE, "REPLACE", ICON_BRUSH_BLUR, "Replace", ""},
|
"Blur",
|
||||||
|
"Smooth out the colors of adjacent stroke points"},
|
||||||
|
{GPVERTEX_TOOL_AVERAGE,
|
||||||
|
"AVERAGE",
|
||||||
|
ICON_BRUSH_BLUR,
|
||||||
|
"Average",
|
||||||
|
"Smooth out colors with the average color under the brush"},
|
||||||
|
{GPVERTEX_TOOL_SMEAR,
|
||||||
|
"SMEAR",
|
||||||
|
ICON_BRUSH_BLUR,
|
||||||
|
"Smear",
|
||||||
|
"Smudge colors by grabbing and dragging them"},
|
||||||
|
{GPVERTEX_TOOL_REPLACE,
|
||||||
|
"REPLACE",
|
||||||
|
ICON_BRUSH_BLUR,
|
||||||
|
"Replace",
|
||||||
|
"Replace the color of stroke points that already have a color applied"},
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, NULL, 0, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue