Transform: Snap used multiple eval contexts
Changes for 2.8x to use EvaluationContext caused some confusion - Would use scene layer passed from snap context. - Would generate duplis from Main eval context. - Would take context argument and use it to create another eval context. Adding context args all over and filling in a new eval-context for every ray-cast test isn't ideal either. Remove the context argument since the purpose of SnapObjectContext is to avoid this kind of confusion. Store the EvaluationContext once and re-use.
This commit is contained in:
parent
d1328feeb1
commit
317b8d9669
|
@ -1005,7 +1005,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
|
|||
if (ts->snap_mode == SCE_SNAP_MODE_VOLUME) {
|
||||
float size;
|
||||
if (peelObjectsSnapContext(
|
||||
C, snap_context, mvalf,
|
||||
snap_context, mvalf,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_NOT_SELECTED,
|
||||
.use_object_edit_cage = false,
|
||||
|
@ -1045,7 +1045,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
|
|||
/* try to snap to closer object */
|
||||
{
|
||||
if (ED_transform_snap_object_project_view3d(
|
||||
C, snap_context,
|
||||
snap_context,
|
||||
ts->snap_mode,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_NOT_SELECTED,
|
||||
|
|
|
@ -5021,7 +5021,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
vc.ar, vc.v3d);
|
||||
|
||||
ED_transform_snap_object_project_view3d_mixed(
|
||||
C, snap_context,
|
||||
snap_context,
|
||||
SCE_SELECT_FACE,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = (vc.scene->obedit != NULL) ? SNAP_NOT_ACTIVE : SNAP_ALL,
|
||||
|
|
|
@ -182,7 +182,7 @@ bool peelObjectsTransform(
|
|||
/* return args */
|
||||
float r_loc[3], float r_no[3], float *r_thickness);
|
||||
bool peelObjectsSnapContext(
|
||||
const struct bContext *C, struct SnapObjectContext *sctx,
|
||||
struct SnapObjectContext *sctx,
|
||||
const float mval[2],
|
||||
const struct SnapObjectParams *params,
|
||||
const bool use_peel_object,
|
||||
|
|
|
@ -85,34 +85,34 @@ void ED_transform_snap_object_context_set_editmesh_callbacks(
|
|||
void *user_data);
|
||||
|
||||
bool ED_transform_snap_object_project_ray_ex(
|
||||
const struct bContext *C, struct SnapObjectContext *sctx,
|
||||
struct SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float ray_start[3], const float ray_normal[3], float *ray_depth,
|
||||
/* return args */
|
||||
float r_loc[3], float r_no[3], int *r_index,
|
||||
struct Object **r_ob, float r_obmat[4][4]);
|
||||
bool ED_transform_snap_object_project_ray(
|
||||
const struct bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float ray_origin[3], const float ray_direction[3], float *ray_depth,
|
||||
float r_co[3], float r_no[3]);
|
||||
|
||||
bool ED_transform_snap_object_project_ray_all(
|
||||
const struct bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float ray_start[3], const float ray_normal[3],
|
||||
float ray_depth, bool sort,
|
||||
struct ListBase *r_hit_list);
|
||||
|
||||
bool ED_transform_snap_object_project_view3d_ex(
|
||||
const struct bContext *C, struct SnapObjectContext *sctx,
|
||||
struct SnapObjectContext *sctx,
|
||||
const unsigned short snap_to,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval[2], float *dist_px,
|
||||
float *ray_depth,
|
||||
float r_loc[3], float r_no[3], int *r_index);
|
||||
bool ED_transform_snap_object_project_view3d(
|
||||
const struct bContext *C, struct SnapObjectContext *sctx,
|
||||
struct SnapObjectContext *sctx,
|
||||
const unsigned short snap_to,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval[2], float *dist_px,
|
||||
|
@ -120,7 +120,7 @@ bool ED_transform_snap_object_project_view3d(
|
|||
/* return args */
|
||||
float r_loc[3], float r_no[3]);
|
||||
bool ED_transform_snap_object_project_view3d_mixed(
|
||||
const struct bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const unsigned short snap_to_flag,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval_fl[2], float *dist_px,
|
||||
|
@ -128,7 +128,7 @@ bool ED_transform_snap_object_project_view3d_mixed(
|
|||
float r_co[3], float r_no[3]);
|
||||
|
||||
bool ED_transform_snap_object_project_all_view3d_ex(
|
||||
const struct bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval[2],
|
||||
float ray_depth, bool sort,
|
||||
|
|
|
@ -317,7 +317,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
|
|||
float mval[2], co_proj[3];
|
||||
if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
|
||||
if (ED_transform_snap_object_project_view3d_mixed(
|
||||
C, snap_context,
|
||||
snap_context,
|
||||
SCE_SELECT_FACE,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_NOT_ACTIVE,
|
||||
|
|
|
@ -738,7 +738,7 @@ static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3],
|
|||
|
||||
/* use for mousemove events */
|
||||
static bool view3d_ruler_item_mousemove(
|
||||
const bContext *C, RulerInfo *ruler_info, const int mval[2],
|
||||
RulerInfo *ruler_info, const int mval[2],
|
||||
const bool do_thickness, const bool do_snap)
|
||||
{
|
||||
const float eps_bias = 0.0002f;
|
||||
|
@ -763,7 +763,7 @@ static bool view3d_ruler_item_mousemove(
|
|||
co_other = ruler_item->co[ruler_item->co_index == 0 ? 2 : 0];
|
||||
|
||||
if (ED_transform_snap_object_project_view3d_mixed(
|
||||
C, ruler_info->snap_context,
|
||||
ruler_info->snap_context,
|
||||
SCE_SELECT_FACE,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_ALL,
|
||||
|
@ -776,7 +776,7 @@ static bool view3d_ruler_item_mousemove(
|
|||
/* add some bias */
|
||||
madd_v3_v3v3fl(ray_start, co, ray_normal, eps_bias);
|
||||
ED_transform_snap_object_project_ray(
|
||||
C, ruler_info->snap_context,
|
||||
ruler_info->snap_context,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_ALL,
|
||||
.use_object_edit_cage = true,
|
||||
|
@ -792,7 +792,7 @@ static bool view3d_ruler_item_mousemove(
|
|||
bool use_depth = (v3d->drawtype >= OB_SOLID);
|
||||
|
||||
if (ED_transform_snap_object_project_view3d_mixed(
|
||||
C, ruler_info->snap_context,
|
||||
ruler_info->snap_context,
|
||||
(SCE_SELECT_VERTEX | SCE_SELECT_EDGE) | (use_depth ? SCE_SELECT_FACE : 0),
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_ALL,
|
||||
|
@ -924,7 +924,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
if (use_depth) {
|
||||
/* snap the first point added, not essential but handy */
|
||||
ruler_item->co_index = 0;
|
||||
view3d_ruler_item_mousemove(C, ruler_info, event->mval, false, true);
|
||||
view3d_ruler_item_mousemove(ruler_info, event->mval, false, true);
|
||||
copy_v3_v3(ruler_info->drag_start_co, ruler_item->co[ruler_item->co_index]);
|
||||
}
|
||||
else {
|
||||
|
@ -977,7 +977,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
}
|
||||
|
||||
/* update the new location */
|
||||
view3d_ruler_item_mousemove(C, ruler_info, event->mval,
|
||||
view3d_ruler_item_mousemove(ruler_info, event->mval,
|
||||
event->shift != 0, event->ctrl != 0);
|
||||
do_draw = true;
|
||||
}
|
||||
|
@ -1026,7 +1026,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
case MOUSEMOVE:
|
||||
{
|
||||
if (ruler_info->state == RULER_STATE_DRAG) {
|
||||
if (view3d_ruler_item_mousemove(C, ruler_info, event->mval,
|
||||
if (view3d_ruler_item_mousemove(ruler_info, event->mval,
|
||||
event->shift != 0, event->ctrl != 0))
|
||||
{
|
||||
do_draw = true;
|
||||
|
|
|
@ -423,7 +423,7 @@ static void walk_navigation_mode_set(bContext *C, wmOperator *op, WalkInfo *walk
|
|||
* \param r_distance Distance to the hit point
|
||||
*/
|
||||
static bool walk_floor_distance_get(
|
||||
const bContext *C, RegionView3D *rv3d, WalkInfo *walk, const float dvec[3],
|
||||
RegionView3D *rv3d, WalkInfo *walk, const float dvec[3],
|
||||
float *r_distance)
|
||||
{
|
||||
float ray_normal[3] = {0, 0, -1}; /* down */
|
||||
|
@ -441,7 +441,7 @@ static bool walk_floor_distance_get(
|
|||
add_v3_v3(ray_start, dvec_tmp);
|
||||
|
||||
ret = ED_transform_snap_object_project_ray(
|
||||
C, walk->snap_context,
|
||||
walk->snap_context,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_ALL,
|
||||
},
|
||||
|
@ -459,7 +459,7 @@ static bool walk_floor_distance_get(
|
|||
* \param r_normal Normal of the hit surface, transformed to always face the camera
|
||||
*/
|
||||
static bool walk_ray_cast(
|
||||
const bContext *C, RegionView3D *rv3d, WalkInfo *walk,
|
||||
RegionView3D *rv3d, WalkInfo *walk,
|
||||
float r_location[3], float r_normal[3], float *ray_distance)
|
||||
{
|
||||
float ray_normal[3] = {0, 0, -1}; /* forward */
|
||||
|
@ -475,7 +475,7 @@ static bool walk_ray_cast(
|
|||
normalize_v3(ray_normal);
|
||||
|
||||
ret = ED_transform_snap_object_project_ray(
|
||||
C, walk->snap_context,
|
||||
walk->snap_context,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_ALL,
|
||||
},
|
||||
|
@ -921,7 +921,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
|
|||
{
|
||||
float loc[3], nor[3];
|
||||
float distance;
|
||||
bool ret = walk_ray_cast(C, walk->rv3d, walk, loc, nor, &distance);
|
||||
bool ret = walk_ray_cast(walk->rv3d, walk, loc, nor, &distance);
|
||||
|
||||
/* in case we are teleporting middle way from a jump */
|
||||
walk->speed_jump = 0.0f;
|
||||
|
@ -1201,7 +1201,7 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
|
|||
float difference = -100.0f;
|
||||
float fall_distance;
|
||||
|
||||
ret = walk_floor_distance_get(C, rv3d, walk, dvec, &ray_distance);
|
||||
ret = walk_floor_distance_get(rv3d, walk, dvec, &ray_distance);
|
||||
|
||||
if (ret) {
|
||||
difference = walk->view_height - ray_distance;
|
||||
|
@ -1254,7 +1254,7 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
|
|||
if (t > walk->teleport.duration) {
|
||||
|
||||
/* check to see if we are landing */
|
||||
ret = walk_floor_distance_get(C, rv3d, walk, dvec, &ray_distance);
|
||||
ret = walk_floor_distance_get(rv3d, walk, dvec, &ray_distance);
|
||||
|
||||
if (ret) {
|
||||
difference = walk->view_height - ray_distance;
|
||||
|
|
|
@ -1197,7 +1197,7 @@ bool snapObjectsTransform(
|
|||
float r_loc[3], float r_no[3])
|
||||
{
|
||||
return ED_transform_snap_object_project_view3d_ex(
|
||||
t->context, t->tsnap.object_context,
|
||||
t->tsnap.object_context,
|
||||
t->scene->toolsettings->snap_mode,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = t->tsnap.modeSelect,
|
||||
|
@ -1211,7 +1211,7 @@ bool snapObjectsTransform(
|
|||
/******************** PEELING *********************************/
|
||||
|
||||
bool peelObjectsSnapContext(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const float mval[2],
|
||||
const struct SnapObjectParams *params,
|
||||
const bool use_peel_object,
|
||||
|
@ -1220,7 +1220,7 @@ bool peelObjectsSnapContext(
|
|||
{
|
||||
ListBase depths_peel = {0};
|
||||
ED_transform_snap_object_project_all_view3d_ex(
|
||||
C, sctx,
|
||||
sctx,
|
||||
params,
|
||||
mval, -1.0f, false,
|
||||
&depths_peel);
|
||||
|
@ -1287,7 +1287,7 @@ bool peelObjectsTransform(
|
|||
float r_loc[3], float r_no[3], float *r_thickness)
|
||||
{
|
||||
return peelObjectsSnapContext(
|
||||
t->context, t->tsnap.object_context,
|
||||
t->tsnap.object_context,
|
||||
mval,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = t->tsnap.modeSelect,
|
||||
|
|
|
@ -104,7 +104,8 @@ typedef struct SnapObjectData_EditMesh {
|
|||
struct SnapObjectContext {
|
||||
Main *bmain;
|
||||
Scene *scene;
|
||||
SceneLayer *scene_layer;
|
||||
EvaluationContext eval_ctx;
|
||||
|
||||
int flag;
|
||||
|
||||
/* Optional: when performing screen-space projection.
|
||||
|
@ -143,7 +144,7 @@ struct SnapObjectContext {
|
|||
* \{ */
|
||||
|
||||
|
||||
typedef void(*IterSnapObjsCallback)(const bContext *C, SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data);
|
||||
typedef void(*IterSnapObjsCallback)(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data);
|
||||
|
||||
/**
|
||||
* Walks through all objects in the scene to create the list of objets to snap.
|
||||
|
@ -153,24 +154,23 @@ typedef void(*IterSnapObjsCallback)(const bContext *C, SnapObjectContext *sctx,
|
|||
* \param obedit : Object Edited to use its coordinates of BMesh(if any) to do the snapping.
|
||||
*/
|
||||
static void iter_snap_objects(
|
||||
const bContext *C,
|
||||
SnapObjectContext *sctx,
|
||||
const SnapSelect snap_select,
|
||||
Object *obedit,
|
||||
IterSnapObjsCallback sob_callback,
|
||||
void *data)
|
||||
{
|
||||
Base *base_act = sctx->scene_layer->basact;
|
||||
Base *base_act = sctx->eval_ctx.scene_layer->basact;
|
||||
/* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA
|
||||
* which makes the loop skip it, even the derived mesh will never change
|
||||
*
|
||||
* To solve that problem, we do it first as an exception.
|
||||
* */
|
||||
if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) {
|
||||
sob_callback(C, sctx, false, base_act->object, base_act->object->obmat, data);
|
||||
sob_callback(sctx, false, base_act->object, base_act->object->obmat, data);
|
||||
}
|
||||
|
||||
for (Base *base = sctx->scene_layer->object_bases.first; base != NULL; base = base->next) {
|
||||
for (Base *base = sctx->eval_ctx.scene_layer->object_bases.first; base != NULL; base = base->next) {
|
||||
if ((BASE_VISIBLE_NEW(base)) && (base->flag_legacy & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
|
||||
!((snap_select == SNAP_NOT_SELECTED && ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL))) ||
|
||||
(snap_select == SNAP_NOT_ACTIVE && base == base_act)))
|
||||
|
@ -179,16 +179,16 @@ static void iter_snap_objects(
|
|||
Object *obj = base->object;
|
||||
if (obj->transflag & OB_DUPLI) {
|
||||
DupliObject *dupli_ob;
|
||||
ListBase *lb = object_duplilist(sctx->bmain->eval_ctx, sctx->scene, obj);
|
||||
ListBase *lb = object_duplilist(&sctx->eval_ctx, sctx->scene, obj);
|
||||
for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
|
||||
use_obedit = obedit && dupli_ob->ob->data == obedit->data;
|
||||
sob_callback(C, sctx, use_obedit, use_obedit ? obedit : dupli_ob->ob, dupli_ob->mat, data);
|
||||
sob_callback(sctx, use_obedit, use_obedit ? obedit : dupli_ob->ob, dupli_ob->mat, data);
|
||||
}
|
||||
free_object_duplilist(lb);
|
||||
}
|
||||
|
||||
use_obedit = obedit && obj->data == obedit->data;
|
||||
sob_callback(C, sctx, use_obedit, use_obedit ? obedit : obj, obj->obmat, data);
|
||||
sob_callback(sctx, use_obedit, use_obedit ? obedit : obj, obj->obmat, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ static bool raycastEditMesh(
|
|||
* \note Duplicate args here are documented at #snapObjectsRay
|
||||
*/
|
||||
static bool raycastObj(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const float ray_start[3], const float ray_dir[3],
|
||||
Object *ob, float obmat[4][4], const unsigned int ob_index,
|
||||
bool use_obedit,
|
||||
|
@ -722,11 +722,8 @@ static bool raycastObj(
|
|||
Object **r_ob, float r_obmat[4][4],
|
||||
ListBase *r_hit_list)
|
||||
{
|
||||
EvaluationContext eval_ctx;
|
||||
bool retval = false;
|
||||
|
||||
CTX_data_eval_ctx(C, &eval_ctx);
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
BMEditMesh *em;
|
||||
|
||||
|
@ -744,10 +741,10 @@ static bool raycastObj(
|
|||
DerivedMesh *dm;
|
||||
em = BKE_editmesh_from_object(ob);
|
||||
if (em) {
|
||||
editbmesh_get_derived_cage_and_final(&eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
|
||||
editbmesh_get_derived_cage_and_final(&sctx->eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
|
||||
}
|
||||
else {
|
||||
dm = mesh_get_derived_final(&eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH);
|
||||
dm = mesh_get_derived_final(&sctx->eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH);
|
||||
}
|
||||
retval = raycastDerivedMesh(
|
||||
sctx,
|
||||
|
@ -786,11 +783,11 @@ struct RaycastObjUserData {
|
|||
bool ret;
|
||||
};
|
||||
|
||||
static void raycast_obj_cb(const bContext *C, SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data)
|
||||
static void raycast_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data)
|
||||
{
|
||||
struct RaycastObjUserData *dt = data;
|
||||
dt->ret |= raycastObj(
|
||||
C, sctx,
|
||||
sctx,
|
||||
dt->ray_start, dt->ray_dir,
|
||||
ob, obmat, dt->ob_index++, is_obedit,
|
||||
dt->ray_depth,
|
||||
|
@ -829,7 +826,7 @@ static void raycast_obj_cb(const bContext *C, SnapObjectContext *sctx, bool is_o
|
|||
*
|
||||
*/
|
||||
static bool raycastObjects(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const float ray_start[3], const float ray_dir[3],
|
||||
const SnapSelect snap_select, const bool use_object_edit_cage,
|
||||
/* read/write args */
|
||||
|
@ -855,7 +852,7 @@ static bool raycastObjects(
|
|||
.ret = false,
|
||||
};
|
||||
|
||||
iter_snap_objects(C, sctx, snap_select, obedit, raycast_obj_cb, &data);
|
||||
iter_snap_objects(sctx, snap_select, obedit, raycast_obj_cb, &data);
|
||||
|
||||
return data.ret;
|
||||
}
|
||||
|
@ -1948,7 +1945,7 @@ static bool snapEditMesh(
|
|||
* \note Duplicate args here are documented at #snapObjectsRay
|
||||
*/
|
||||
static bool snapObject(
|
||||
const bContext *C, SnapObjectContext *sctx, SnapData *snapdata,
|
||||
SnapObjectContext *sctx, SnapData *snapdata,
|
||||
Object *ob, float obmat[4][4],
|
||||
bool use_obedit,
|
||||
/* read/write args */
|
||||
|
@ -1957,11 +1954,8 @@ static bool snapObject(
|
|||
float r_loc[3], float r_no[3],
|
||||
Object **r_ob, float r_obmat[4][4])
|
||||
{
|
||||
EvaluationContext eval_ctx;
|
||||
bool retval = false;
|
||||
|
||||
CTX_data_eval_ctx(C, &eval_ctx);
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
BMEditMesh *em;
|
||||
|
||||
|
@ -1978,10 +1972,10 @@ static bool snapObject(
|
|||
DerivedMesh *dm;
|
||||
em = BKE_editmesh_from_object(ob);
|
||||
if (em) {
|
||||
editbmesh_get_derived_cage_and_final(&eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
|
||||
editbmesh_get_derived_cage_and_final(&sctx->eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm);
|
||||
}
|
||||
else {
|
||||
dm = mesh_get_derived_final(&eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH);
|
||||
dm = mesh_get_derived_final(&sctx->eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH);
|
||||
}
|
||||
retval = snapDerivedMesh(
|
||||
sctx, snapdata, ob, dm, obmat,
|
||||
|
@ -2045,11 +2039,11 @@ struct SnapObjUserData {
|
|||
bool ret;
|
||||
};
|
||||
|
||||
static void sanp_obj_cb(const bContext *C, SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data)
|
||||
static void sanp_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data)
|
||||
{
|
||||
struct SnapObjUserData *dt = data;
|
||||
dt->ret |= snapObject(
|
||||
C, sctx, dt->snapdata,
|
||||
sctx, dt->snapdata,
|
||||
ob, obmat, is_obedit,
|
||||
/* read/write args */
|
||||
dt->ray_depth, dt->dist_px,
|
||||
|
@ -2088,7 +2082,7 @@ static void sanp_obj_cb(const bContext *C, SnapObjectContext *sctx, bool is_obed
|
|||
*
|
||||
*/
|
||||
static bool snapObjectsRay(
|
||||
const bContext *C, SnapObjectContext *sctx, SnapData *snapdata,
|
||||
SnapObjectContext *sctx, SnapData *snapdata,
|
||||
const SnapSelect snap_select, const bool use_object_edit_cage,
|
||||
/* read/write args */
|
||||
float *ray_depth, float *dist_px,
|
||||
|
@ -2109,7 +2103,7 @@ static bool snapObjectsRay(
|
|||
.ret = false,
|
||||
};
|
||||
|
||||
iter_snap_objects(C, sctx, snap_select, obedit, sanp_obj_cb, &data);
|
||||
iter_snap_objects(sctx, snap_select, obedit, sanp_obj_cb, &data);
|
||||
|
||||
return data.ret;
|
||||
}
|
||||
|
@ -2131,7 +2125,8 @@ SnapObjectContext *ED_transform_snap_object_context_create(
|
|||
|
||||
sctx->bmain = bmain;
|
||||
sctx->scene = scene;
|
||||
sctx->scene_layer = sl;
|
||||
|
||||
DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, sl, DAG_EVAL_VIEWPORT);
|
||||
|
||||
sctx->cache.object_map = BLI_ghash_ptr_new(__func__);
|
||||
sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
|
||||
|
@ -2205,7 +2200,7 @@ void ED_transform_snap_object_context_set_editmesh_callbacks(
|
|||
}
|
||||
|
||||
bool ED_transform_snap_object_project_ray_ex(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float ray_start[3], const float ray_normal[3],
|
||||
float *ray_depth,
|
||||
|
@ -2213,7 +2208,7 @@ bool ED_transform_snap_object_project_ray_ex(
|
|||
Object **r_ob, float r_obmat[4][4])
|
||||
{
|
||||
return raycastObjects(
|
||||
C, sctx,
|
||||
sctx,
|
||||
ray_start, ray_normal,
|
||||
params->snap_select, params->use_object_edit_cage,
|
||||
ray_depth, r_loc, r_no, r_index, r_ob, r_obmat, NULL);
|
||||
|
@ -2227,7 +2222,7 @@ bool ED_transform_snap_object_project_ray_ex(
|
|||
* \param r_hit_list: List of #SnapObjectHitDepth (caller must free).
|
||||
*/
|
||||
bool ED_transform_snap_object_project_ray_all(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float ray_start[3], const float ray_normal[3],
|
||||
float ray_depth, bool sort,
|
||||
|
@ -2242,7 +2237,7 @@ bool ED_transform_snap_object_project_ray_all(
|
|||
#endif
|
||||
|
||||
bool retval = raycastObjects(
|
||||
C, sctx,
|
||||
sctx,
|
||||
ray_start, ray_normal,
|
||||
params->snap_select, params->use_object_edit_cage,
|
||||
&ray_depth, NULL, NULL, NULL, NULL, NULL,
|
||||
|
@ -2268,7 +2263,7 @@ bool ED_transform_snap_object_project_ray_all(
|
|||
* \return Snap success
|
||||
*/
|
||||
static bool transform_snap_context_project_ray_impl(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float ray_start[3], const float ray_normal[3], float *ray_depth,
|
||||
float r_co[3], float r_no[3])
|
||||
|
@ -2277,7 +2272,7 @@ static bool transform_snap_context_project_ray_impl(
|
|||
|
||||
/* try snap edge, then face if it fails */
|
||||
ret = ED_transform_snap_object_project_ray_ex(
|
||||
C, sctx,
|
||||
sctx,
|
||||
params,
|
||||
ray_start, ray_normal, ray_depth,
|
||||
r_co, r_no, NULL,
|
||||
|
@ -2287,7 +2282,7 @@ static bool transform_snap_context_project_ray_impl(
|
|||
}
|
||||
|
||||
bool ED_transform_snap_object_project_ray(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float ray_origin[3], const float ray_direction[3], float *ray_depth,
|
||||
float r_co[3], float r_no[3])
|
||||
|
@ -2299,14 +2294,14 @@ bool ED_transform_snap_object_project_ray(
|
|||
}
|
||||
|
||||
return transform_snap_context_project_ray_impl(
|
||||
C, sctx,
|
||||
sctx,
|
||||
params,
|
||||
ray_origin, ray_direction, ray_depth,
|
||||
r_co, r_no);
|
||||
}
|
||||
|
||||
static bool transform_snap_context_project_view3d_mixed_impl(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const unsigned short snap_to_flag,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval[2], float *dist_px,
|
||||
|
@ -2330,7 +2325,7 @@ static bool transform_snap_context_project_view3d_mixed_impl(
|
|||
*dist_px = dist_px_orig;
|
||||
}
|
||||
if (ED_transform_snap_object_project_view3d(
|
||||
C, sctx,
|
||||
sctx,
|
||||
elem_type[i], params,
|
||||
mval, dist_px, &ray_depth,
|
||||
r_co, r_no))
|
||||
|
@ -2347,7 +2342,7 @@ static bool transform_snap_context_project_view3d_mixed_impl(
|
|||
for (int i = 0; i < 3; i++) {
|
||||
if (snap_to_flag & (1 << i)) {
|
||||
if (ED_transform_snap_object_project_view3d(
|
||||
C, sctx,
|
||||
sctx,
|
||||
elem_type[i], params,
|
||||
mval, dist_px, &ray_depth,
|
||||
r_co, r_no))
|
||||
|
@ -2376,7 +2371,7 @@ static bool transform_snap_context_project_view3d_mixed_impl(
|
|||
* \return Snap success
|
||||
*/
|
||||
bool ED_transform_snap_object_project_view3d_mixed(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const unsigned short snap_to_flag,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval_fl[2], float *dist_px,
|
||||
|
@ -2384,14 +2379,14 @@ bool ED_transform_snap_object_project_view3d_mixed(
|
|||
float r_co[3], float r_no[3])
|
||||
{
|
||||
return transform_snap_context_project_view3d_mixed_impl(
|
||||
C, sctx,
|
||||
sctx,
|
||||
snap_to_flag, params,
|
||||
mval_fl, dist_px, use_depth,
|
||||
r_co, r_no);
|
||||
}
|
||||
|
||||
bool ED_transform_snap_object_project_view3d_ex(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const unsigned short snap_to,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval[2], float *dist_px,
|
||||
|
@ -2425,7 +2420,7 @@ bool ED_transform_snap_object_project_view3d_ex(
|
|||
|
||||
if (snap_to == SCE_SNAP_MODE_FACE) {
|
||||
return raycastObjects(
|
||||
C, sctx,
|
||||
sctx,
|
||||
ray_start, ray_normal,
|
||||
params->snap_select, params->use_object_edit_cage,
|
||||
ray_depth, r_loc, r_no, r_index, NULL, NULL, NULL);
|
||||
|
@ -2437,14 +2432,14 @@ bool ED_transform_snap_object_project_view3d_ex(
|
|||
ray_origin, ray_start, ray_normal, depth_range);
|
||||
|
||||
return snapObjectsRay(
|
||||
C, sctx, &snapdata,
|
||||
sctx, &snapdata,
|
||||
params->snap_select, params->use_object_edit_cage,
|
||||
ray_depth, dist_px, r_loc, r_no, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
bool ED_transform_snap_object_project_view3d(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const unsigned short snap_to,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval[2], float *dist_px,
|
||||
|
@ -2452,7 +2447,7 @@ bool ED_transform_snap_object_project_view3d(
|
|||
float r_loc[3], float r_no[3])
|
||||
{
|
||||
return ED_transform_snap_object_project_view3d_ex(
|
||||
C, sctx,
|
||||
sctx,
|
||||
snap_to,
|
||||
params,
|
||||
mval, dist_px,
|
||||
|
@ -2464,7 +2459,7 @@ bool ED_transform_snap_object_project_view3d(
|
|||
* see: #ED_transform_snap_object_project_ray_all
|
||||
*/
|
||||
bool ED_transform_snap_object_project_all_view3d_ex(
|
||||
const bContext *C, SnapObjectContext *sctx,
|
||||
SnapObjectContext *sctx,
|
||||
const struct SnapObjectParams *params,
|
||||
const float mval[2],
|
||||
float ray_depth, bool sort,
|
||||
|
@ -2480,7 +2475,7 @@ bool ED_transform_snap_object_project_all_view3d_ex(
|
|||
}
|
||||
|
||||
return ED_transform_snap_object_project_ray_all(
|
||||
C, sctx,
|
||||
sctx,
|
||||
params,
|
||||
ray_start, ray_normal, ray_depth, sort,
|
||||
r_hit_list);
|
||||
|
|
|
@ -151,7 +151,7 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, int previe
|
|||
}
|
||||
|
||||
static void rna_Scene_ray_cast(
|
||||
Scene *scene, bContext *C, SceneLayer *sl, float origin[3], float direction[3], float ray_dist,
|
||||
Scene *scene, SceneLayer *sl, float origin[3], float direction[3], float ray_dist,
|
||||
int *r_success, float r_location[3], float r_normal[3], int *r_index,
|
||||
Object **r_ob, float r_obmat[16])
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ static void rna_Scene_ray_cast(
|
|||
G.main, scene, sl, 0);
|
||||
|
||||
bool ret = ED_transform_snap_object_project_ray_ex(
|
||||
C, sctx,
|
||||
sctx,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_ALL,
|
||||
},
|
||||
|
@ -352,7 +352,6 @@ void RNA_api_scene(StructRNA *srna)
|
|||
/* Ray Cast */
|
||||
func = RNA_def_function(srna, "ray_cast", "rna_Scene_ray_cast");
|
||||
RNA_def_function_ui_description(func, "Cast a ray onto in object space");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
parm = RNA_def_pointer(func, "scene_layer", "SceneLayer", "", "Scene Layer");
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
||||
/* ray start and end */
|
||||
|
|
Loading…
Reference in New Issue