Sorted BaseLegacy > Base convertions

Including bring back UV Edit show other objects
This commit is contained in:
Dalai Felinto
2017-02-14 16:33:13 +01:00
parent a76d45cf72
commit 7e3d2a8baa
9 changed files with 69 additions and 62 deletions

View File

@@ -41,6 +41,7 @@ struct MTexPoly;
struct Main;
struct Object;
struct Scene;
struct SceneLayer;
struct SpaceImage;
struct bNode;
struct wmKeyConfig;
@@ -109,7 +110,7 @@ void ED_unwrap_lscm(struct Scene *scene, struct Object *obedit, const short sel)
/* uvedit_draw.c */
void ED_image_draw_cursor(struct ARegion *ar, const float cursor[2]);
void ED_uvedit_draw_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene, struct Object *obedit, struct Object *obact);
void ED_uvedit_draw_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene, struct SceneLayer *sl, struct Object *obedit, struct Object *obact);
/* uvedit_buttons.c */
void ED_uvedit_buttons_register(struct ARegionType *art);

View File

@@ -59,6 +59,7 @@
#include "BKE_depsgraph.h"
#include "BKE_mesh_mapping.h"
#include "BKE_editmesh.h"
#include "BKE_layer.h"
#include "BKE_modifier.h"
#include "BKE_report.h"
#include "BKE_DerivedMesh.h"
@@ -3300,25 +3301,26 @@ void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot)
static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
BaseLegacy *base;
Object *ob_active = ED_object_context(C);
int retval = OPERATOR_CANCELLED;
for (base = scene->base.first; base; base = base->next) {
if (base->object->type == ob->type) {
if (base->object != ob && base->object->data == ob->data) {
BLI_freelistN(&base->object->defbase);
BLI_duplicatelist(&base->object->defbase, &ob->defbase);
base->object->actdef = ob->actdef;
FOREACH_SCENE_OBJECT(scene, ob_iter)
{
if (ob_iter->type == ob_active->type) {
if (ob_iter != ob_active && ob_iter->data == ob_active->data) {
BLI_freelistN(&ob_iter->defbase);
BLI_duplicatelist(&ob_iter->defbase, &ob_active->defbase);
ob_iter->actdef = ob_active->actdef;
DAG_id_tag_update(&base->object->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, base->object);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, base->object->data);
DAG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob_iter->data);
retval = OPERATOR_FINISHED;
}
}
}
FOREACH_SCENE_OBJECT_END
return retval;
}

View File

@@ -42,6 +42,7 @@
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
@@ -253,22 +254,23 @@ static void ptcache_bake_cancel(bContext *C, wmOperator *op)
static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
BaseLegacy *base;
Scene *scene = CTX_data_scene(C);
PTCacheID *pid;
ListBase pidlist;
for (base=scene->base.first; base; base= base->next) {
BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
FOREACH_SCENE_OBJECT(scene, ob)
{
BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
for (pid=pidlist.first; pid; pid=pid->next) {
for (pid = pidlist.first; pid; pid = pid->next) {
ptcache_free_bake(pid->cache);
}
BLI_freelistN(&pidlist);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, base->object);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
}
FOREACH_SCENE_OBJECT_END
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);

View File

@@ -69,6 +69,7 @@
#include "BKE_image.h"
#include "BKE_icons.h"
#include "BKE_lamp.h"
#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_library_remap.h"
#include "BKE_main.h"
@@ -358,29 +359,33 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
/* this only works in a specific case where the preview.blend contains
* an object starting with 'c' which has a material linked to it (not the obdata)
* and that material has a fake shadow texture in the active texture slot */
for (base = sce->base.first; base; base = base->next) {
if (base->object->id.name[2] == 'c') {
Material *shadmat = give_current_material(base->object, base->object->actcol);
FOREACH_SCENE_OBJECT(sce, ob)
{
if (ob->id.name[2] == 'c') {
Material *shadmat = give_current_material(ob, ob->actcol);
if (shadmat) {
if (mat->mode2 & MA_CASTSHADOW) shadmat->septex = 0;
else shadmat->septex |= 1;
}
}
}
FOREACH_SCENE_OBJECT_END
/* turn off bounce lights for volume,
* doesn't make much visual difference and slows it down too */
for (base = sce->base.first; base; base = base->next) {
if (base->object->type == OB_LAMP) {
FOREACH_SCENE_OBJECT(sce, ob)
{
if (ob->type == OB_LAMP) {
/* if doesn't match 'Lamp.002' --> main key light */
if (!STREQ(base->object->id.name + 2, "Lamp.002")) {
if (!STREQ(ob->id.name + 2, "Lamp.002")) {
if (mat->material_type == MA_TYPE_VOLUME)
base->object->restrictflag |= OB_RESTRICT_RENDER;
ob->restrictflag |= OB_RESTRICT_RENDER;
else
base->object->restrictflag &= ~OB_RESTRICT_RENDER;
ob->restrictflag &= ~OB_RESTRICT_RENDER;
}
}
}
FOREACH_SCENE_OBJECT_END
}
else {
/* use current scene world to light sphere */

View File

@@ -687,6 +687,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
Mask *mask = NULL;
bool curve = false;
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
View2D *v2d = &ar->v2d;
//View2DScrollers *scrollers;
float col[3];
@@ -722,7 +723,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
ED_uvedit_draw_main(sima, ar, scene, obedit, obact);
ED_uvedit_draw_main(sima, ar, scene, sl, obedit, obact);
/* check for mask (delay draw) */
if (ED_space_image_show_uvedit(sima, obedit)) {

View File

@@ -346,7 +346,7 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel, cons
BLI_dlrbTree_free(&keys);
}
static void time_draw_caches_keyframes(Main *bmain, Scene *scene, View2D *v2d, bool onlysel, const unsigned char color[3])
static void time_draw_caches_keyframes(Main *bmain, SceneLayer *sl, View2D *v2d, bool onlysel, const unsigned char color[3])
{
CacheFile *cache_file;
@@ -357,7 +357,7 @@ static void time_draw_caches_keyframes(Main *bmain, Scene *scene, View2D *v2d, b
cache_file->draw_flag &= ~CACHEFILE_KEYFRAME_DRAWN;
}
for (BaseLegacy *base = scene->base.first; base; base = base->next) {
for (Base *base = sl->object_bases.first; base; base = base->next) {
Object *ob = base->object;
ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);
@@ -400,6 +400,7 @@ static void time_draw_caches_keyframes(Main *bmain, Scene *scene, View2D *v2d, b
static void time_draw_keyframes(const bContext *C, ARegion *ar)
{
Scene *scene = CTX_data_scene(C);
SceneLayer *sl = CTX_data_scene_layer(C);
Object *ob = CTX_data_active_object(C);
View2D *v2d = &ar->v2d;
bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0);
@@ -410,7 +411,7 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar)
/* draw cache files keyframes (if available) */
UI_GetThemeColor3ubv(TH_TIME_KEYFRAME, color);
time_draw_caches_keyframes(CTX_data_main(C), scene, v2d, onlysel, color);
time_draw_caches_keyframes(CTX_data_main(C), sl, v2d, onlysel, color);
/* draw grease pencil keyframes (if available) */
UI_GetThemeColor3ubv(TH_TIME_GP_KEYFRAME, color);

View File

@@ -532,33 +532,29 @@ static void draw_uvs_other_mesh(Object *ob, const Image *curimage, const bool ne
}
}
static void draw_uvs_other(Scene *scene, Object *obedit, const Image *curimage, const bool new_shading_nodes,
static void draw_uvs_other(SceneLayer *sl, Object *obedit, const Image *curimage, const bool new_shading_nodes,
const int other_uv_filter)
{
BaseLegacy *base;
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_UV_OTHERS);
for (base = scene->base.first; base; base = base->next) {
Object *ob = base->object;
if (!(base->flag_legacy & SELECT)) continue;
if (!(base->lay & scene->lay)) continue;
if (ob->restrictflag & OB_RESTRICT_VIEW) continue;
if ((ob->type == OB_MESH) && (ob != obedit) && ((Mesh *)ob->data)->mloopuv) {
draw_uvs_other_mesh(ob, curimage, new_shading_nodes, other_uv_filter, pos);
for (Base *base = sl->object_bases.first; base; base = base->next) {
if (((base->flag & BASE_SELECTED) != 0) &&
((base->flag & BASE_VISIBLED) != 0))
{
Object *ob = base->object;
if ((ob->type == OB_MESH) && (ob != obedit) && ((Mesh *)ob->data)->mloopuv) {
draw_uvs_other_mesh(ob, curimage, new_shading_nodes, other_uv_filter, pos);
}
}
}
immUnbindProgram();
}
static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob)
static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *ob)
{
const bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
Image *curimage = ED_space_image(sima);
@@ -566,7 +562,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob)
Material *ma;
if (sima->flag & SI_DRAW_OTHER) {
draw_uvs_other(scene, ob, curimage, new_shading_nodes, sima->other_uv_filter);
draw_uvs_other(sl, ob, curimage, new_shading_nodes, sima->other_uv_filter);
}
ma = give_current_material(ob, ob->actcol);
@@ -625,7 +621,7 @@ static void draw_uvs_looptri(BMEditMesh *em, unsigned int *r_loop_index, const i
#endif
/* draws uv's in the image space */
static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obedit)
{
const bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
ToolSettings *ts;
@@ -679,7 +675,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
curimage = (activetf) ? activetf->tpage : ima;
}
draw_uvs_other(scene, obedit, curimage, new_shading_nodes, sima->other_uv_filter);
draw_uvs_other(sl, obedit, curimage, new_shading_nodes, sima->other_uv_filter);
}
/* 1. draw shadow mesh */
@@ -1140,7 +1136,7 @@ static void draw_uv_shadows_get(SpaceImage *sima, Object *ob, Object *obedit, bo
*show_texpaint = (ob && ob->type == OB_MESH && ob->mode == OB_MODE_TEXTURE_PAINT);
}
void ED_uvedit_draw_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedit, Object *obact)
void ED_uvedit_draw_main(SpaceImage *sima, ARegion *ar, Scene *scene, SceneLayer *sl, Object *obedit, Object *obact)
{
ToolSettings *toolsettings = scene->toolsettings;
bool show_uvedit, show_uvshadow, show_texpaint_uvshadow;
@@ -1152,9 +1148,9 @@ void ED_uvedit_draw_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *ob
if (show_uvshadow)
draw_uvs_shadow(obedit);
else if (show_uvedit)
draw_uvs(sima, scene, obedit);
draw_uvs(sima, scene, sl, obedit);
else
draw_uvs_texpaint(sima, scene, obact);
draw_uvs_texpaint(sima, scene, sl, obact);
if (show_uvedit && !(toolsettings->use_uv_sculpt))
ED_image_draw_cursor(ar, sima->cursor);

View File

@@ -41,6 +41,7 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_layer.h"
#include "BKE_modifier.h"
#include "depsgraph_private.h"
@@ -109,9 +110,8 @@ static void updateDepsgraph(ModifierData *md,
FluidsimModifierData *fluidmd = (FluidsimModifierData *) md;
if (fluidmd && fluidmd->fss) {
if (fluidmd->fss->type == OB_FLUIDSIM_DOMAIN) {
BaseLegacy *base;
for (base = scene->base.first; base; base = base->next) {
Object *ob1 = base->object;
FOREACH_SCENE_OBJECT(scene, ob1)
{
if (ob1 != ob) {
FluidsimModifierData *fluidmdtmp =
(FluidsimModifierData *)modifiers_findByType(ob1, eModifierType_Fluidsim);
@@ -122,6 +122,7 @@ static void updateDepsgraph(ModifierData *md,
}
}
}
FOREACH_SCENE_OBJECT_END
}
}
}

View File

@@ -51,6 +51,7 @@
#include "BKE_main.h"
#include "BKE_image.h" /* BKE_imbuf_write */
#include "BKE_layer.h"
#include "BKE_texture.h"
#include "BKE_scene.h"
@@ -247,17 +248,14 @@ static void envmap_transmatrix(float mat[4][4], int part)
static void env_set_imats(Render *re)
{
BaseLegacy *base;
float mat[4][4];
base = re->scene->base.first;
while (base) {
mul_m4_m4m4(mat, re->viewmat, base->object->obmat);
invert_m4_m4(base->object->imat, mat);
base = base->next;
FOREACH_SCENE_OBJECT(re->scene, ob)
{
mul_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat);
}
FOREACH_SCENE_OBJECT_END
}
/* ------------------------------------------------------------------------- */