Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/drawobject.c
| Show First 20 Lines • Show All 3,688 Lines • ▼ Show 20 Lines | if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { | ||||
| return DM_DRAW_OPTION_NORMAL; | return DM_DRAW_OPTION_NORMAL; | ||||
| } | } | ||||
| else { | else { | ||||
| return DM_DRAW_OPTION_SKIP; | return DM_DRAW_OPTION_SKIP; | ||||
| } | } | ||||
| } | } | ||||
| static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d, | static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d, | ||||
| Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt) | Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt, DupliObject *dob) | ||||
| { | { | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, true); /* annoying but active faces is stored differently */ | BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, true); /* annoying but active faces is stored differently */ | ||||
| BMEdge *eed_act = NULL; | BMEdge *eed_act = NULL; | ||||
| BMVert *eve_act = NULL; | BMVert *eve_act = NULL; | ||||
| bool use_occlude_wire = (v3d->flag2 & V3D_OCCLUDE_WIRE) && (dt > OB_WIRE); | bool use_occlude_wire = (v3d->flag2 & V3D_OCCLUDE_WIRE) && (dt > OB_WIRE); | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | else if (check_object_draw_texture(scene, v3d, dt)) { | ||||
| finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material, | finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material, | ||||
| draw_em_fancy__setGLSLFaceOpts, em); | draw_em_fancy__setGLSLFaceOpts, em); | ||||
| GPU_disable_material(); | GPU_disable_material(); | ||||
| glFrontFace(GL_CCW); | glFrontFace(GL_CCW); | ||||
| } | } | ||||
| else { | else { | ||||
| draw_mesh_textured(scene, v3d, rv3d, ob, finalDM, 0); | draw_mesh_textured(scene, v3d, rv3d, ob, finalDM, 0, dob); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* 3 floats for position, | /* 3 floats for position, | ||||
| * 3 for normal and times two because the faces may actually be quads instead of triangles */ | * 3 for normal and times two because the faces may actually be quads instead of triangles */ | ||||
| glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE); | glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE); | ||||
| glEnable(GL_LIGHTING); | glEnable(GL_LIGHTING); | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
| static bool object_is_halo(Scene *scene, Object *ob) | static bool object_is_halo(Scene *scene, Object *ob) | ||||
| { | { | ||||
| const Material *ma = give_current_material(ob, 1); | const Material *ma = give_current_material(ob, 1); | ||||
| return (ma && (ma->material_type == MA_TYPE_HALO) && !BKE_scene_use_new_shading_nodes(scene)); | return (ma && (ma->material_type == MA_TYPE_HALO) && !BKE_scene_use_new_shading_nodes(scene)); | ||||
| } | } | ||||
| static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, | static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, | ||||
| const char dt, const unsigned char ob_wire_col[4], const short dflag) | const char dt, const unsigned char ob_wire_col[4], const short dflag, DupliObject *dob) | ||||
| { | { | ||||
| #ifdef WITH_GAMEENGINE | #ifdef WITH_GAMEENGINE | ||||
| Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, scene) : base->object; | Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, scene) : base->object; | ||||
| #else | #else | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| #endif | #endif | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| eWireDrawMode draw_wire = OBDRAW_WIRE_OFF; | eWireDrawMode draw_wire = OBDRAW_WIRE_OFF; | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | #endif | ||||
| GPU_disable_material(); | GPU_disable_material(); | ||||
| glFrontFace(GL_CCW); | glFrontFace(GL_CCW); | ||||
| if (draw_flags & DRAW_FACE_SELECT) | if (draw_flags & DRAW_FACE_SELECT) | ||||
| draw_mesh_face_select(rv3d, me, dm, false); | draw_mesh_face_select(rv3d, me, dm, false); | ||||
| } | } | ||||
| else { | else { | ||||
| draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags); | draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags, dob); | ||||
| } | } | ||||
| if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) { | if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) { | ||||
| if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| glColor3ubv(ob_wire_col); | glColor3ubv(ob_wire_col); | ||||
| } | } | ||||
| dm->drawLooseEdges(dm); | dm->drawLooseEdges(dm); | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | if (is_obact && BKE_paint_select_vert_test(ob)) { | ||||
| glPointSize(1.0f); | glPointSize(1.0f); | ||||
| } | } | ||||
| dm->release(dm); | dm->release(dm); | ||||
| } | } | ||||
| /* returns true if nothing was drawn, for detecting to draw an object center */ | /* returns true if nothing was drawn, for detecting to draw an object center */ | ||||
| static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, | static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, | ||||
| const char dt, const unsigned char ob_wire_col[4], const short dflag) | const char dt, const unsigned char ob_wire_col[4], const short dflag, DupliObject *dob) | ||||
| { | { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| Object *obedit = scene->obedit; | Object *obedit = scene->obedit; | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| BMEditMesh *em = me->edit_btmesh; | BMEditMesh *em = me->edit_btmesh; | ||||
| int i; | int i; | ||||
| bool do_alpha_after = false, drawlinked = false, retval = false; | bool do_alpha_after = false, drawlinked = false, retval = false; | ||||
| Show All 32 Lines | if (ob == obedit || drawlinked) { | ||||
| DM_update_materials(finalDM, ob); | DM_update_materials(finalDM, ob); | ||||
| if (cageDM != finalDM) { | if (cageDM != finalDM) { | ||||
| DM_update_materials(cageDM, ob); | DM_update_materials(cageDM, ob); | ||||
| } | } | ||||
| if (dt > OB_WIRE) { | if (dt > OB_WIRE) { | ||||
| const bool glsl = draw_glsl_material(scene, ob, v3d, dt); | const bool glsl = draw_glsl_material(scene, ob, v3d, dt); | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL, dob); | ||||
| } | } | ||||
| draw_em_fancy(scene, ar, v3d, ob, em, cageDM, finalDM, dt); | draw_em_fancy(scene, ar, v3d, ob, em, cageDM, finalDM, dt, dob); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| if (obedit != ob && finalDM) | if (obedit != ob && finalDM) | ||||
| finalDM->release(finalDM); | finalDM->release(finalDM); | ||||
| } | } | ||||
| else { | else { | ||||
| /* ob->bb was set by derived mesh system, do NULL check just to be sure */ | /* ob->bb was set by derived mesh system, do NULL check just to be sure */ | ||||
| if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) { | if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) { | ||||
| if (dt > OB_WIRE) { | if (dt > OB_WIRE) { | ||||
| const bool glsl = draw_glsl_material(scene, ob, v3d, dt); | const bool glsl = draw_glsl_material(scene, ob, v3d, dt); | ||||
| if (dt == OB_SOLID || glsl) { | if (dt == OB_SOLID || glsl) { | ||||
| const bool check_alpha = check_alpha_pass(base); | const bool check_alpha = check_alpha_pass(base); | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, | GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, | ||||
| (check_alpha) ? &do_alpha_after : NULL); | (check_alpha) ? &do_alpha_after : NULL, dob); | ||||
| } | } | ||||
| } | } | ||||
| draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); | draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag, dob); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| if (me->totvert == 0) retval = true; | if (me->totvert == 0) retval = true; | ||||
| } | } | ||||
| } | } | ||||
| if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) { | if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) { | ||||
| ▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | |||||
| static void drawCurveDMWired(Object *ob) | static void drawCurveDMWired(Object *ob) | ||||
| { | { | ||||
| DerivedMesh *dm = ob->derivedFinal; | DerivedMesh *dm = ob->derivedFinal; | ||||
| dm->drawEdges(dm, 1, 0); | dm->drawEdges(dm, 1, 0); | ||||
| } | } | ||||
| /* return true when nothing was drawn */ | /* return true when nothing was drawn */ | ||||
| static bool drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt) | static bool drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt, DupliObject *dob) | ||||
| { | { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| DerivedMesh *dm = ob->derivedFinal; | DerivedMesh *dm = ob->derivedFinal; | ||||
| if (!dm) { | if (!dm) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| DM_update_materials(dm, ob); | DM_update_materials(dm, ob); | ||||
| glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); | glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); | ||||
| if (dt > OB_WIRE && dm->getNumTessFaces(dm)) { | if (dt > OB_WIRE && dm->getNumTessFaces(dm)) { | ||||
| int glsl = draw_glsl_material(scene, ob, v3d, dt); | int glsl = draw_glsl_material(scene, ob, v3d, dt); | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL, dob); | ||||
| if (!glsl) { | if (!glsl) { | ||||
| glEnable(GL_LIGHTING); | glEnable(GL_LIGHTING); | ||||
| dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); | dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); | ||||
| glDisable(GL_LIGHTING); | glDisable(GL_LIGHTING); | ||||
| } | } | ||||
| else | else | ||||
| dm->drawFacesGLSL(dm, GPU_enable_material); | dm->drawFacesGLSL(dm, GPU_enable_material); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| } | } | ||||
| else { | else { | ||||
| if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0) | if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0) | ||||
| drawCurveDMWired(ob); | drawCurveDMWired(ob); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /** | /** | ||||
| * Only called by #drawDispList | * Only called by #drawDispList | ||||
| * \return true when nothing was drawn | * \return true when nothing was drawn | ||||
| */ | */ | ||||
| static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, | static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, | ||||
| const char dt, const short dflag, const unsigned char ob_wire_col[4]) | const char dt, const short dflag, const unsigned char ob_wire_col[4], DupliObject *dob) | ||||
| { | { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| ListBase *lb = NULL; | ListBase *lb = NULL; | ||||
| DispList *dl; | DispList *dl; | ||||
| Curve *cu; | Curve *cu; | ||||
| const bool render_only = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0; | const bool render_only = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0; | ||||
| const bool solid = (dt > OB_WIRE); | const bool solid = (dt > OB_WIRE); | ||||
| Show All 24 Lines | case OB_CURVE: | ||||
| } | } | ||||
| } | } | ||||
| if (has_faces == false) { | if (has_faces == false) { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| else { | else { | ||||
| if (draw_glsl_material(scene, ob, v3d, dt)) { | if (draw_glsl_material(scene, ob, v3d, dt)) { | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL, dob); | ||||
| drawDispListsolid(lb, ob, dflag, ob_wire_col, true); | drawDispListsolid(lb, ob, dflag, ob_wire_col, true); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| } | } | ||||
| else { | else { | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL, dob); | ||||
| drawDispListsolid(lb, ob, dflag, ob_wire_col, false); | drawDispListsolid(lb, ob, dflag, ob_wire_col, false); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| } | } | ||||
| if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) { | if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) { | ||||
| cpack(0); | cpack(0); | ||||
| drawDispListwire(lb, ob->type); | drawDispListwire(lb, ob->type); | ||||
| } | } | ||||
| } | } | ||||
| Show All 13 Lines | case OB_SURF: | ||||
| dl = lb->first; | dl = lb->first; | ||||
| if (dl == NULL) { | if (dl == NULL) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| if (dl->nors == NULL) BKE_displist_normals_add(lb); | if (dl->nors == NULL) BKE_displist_normals_add(lb); | ||||
| if (draw_glsl_material(scene, ob, v3d, dt)) { | if (draw_glsl_material(scene, ob, v3d, dt)) { | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL, dob); | ||||
| drawDispListsolid(lb, ob, dflag, ob_wire_col, true); | drawDispListsolid(lb, ob, dflag, ob_wire_col, true); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| } | } | ||||
| else { | else { | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL, dob); | ||||
| drawDispListsolid(lb, ob, dflag, ob_wire_col, false); | drawDispListsolid(lb, ob, dflag, ob_wire_col, false); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| return drawDispListwire(lb, ob->type); | return drawDispListwire(lb, ob->type); | ||||
| } | } | ||||
| break; | break; | ||||
| case OB_MBALL: | case OB_MBALL: | ||||
| if (BKE_mball_is_basis(ob)) { | if (BKE_mball_is_basis(ob)) { | ||||
| lb = &ob->curve_cache->disp; | lb = &ob->curve_cache->disp; | ||||
| if (BLI_listbase_is_empty(lb)) { | if (BLI_listbase_is_empty(lb)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| if (solid) { | if (solid) { | ||||
| if (draw_glsl_material(scene, ob, v3d, dt)) { | if (draw_glsl_material(scene, ob, v3d, dt)) { | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL, dob); | ||||
| drawDispListsolid(lb, ob, dflag, ob_wire_col, true); | drawDispListsolid(lb, ob, dflag, ob_wire_col, true); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| } | } | ||||
| else { | else { | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL, dob); | ||||
| drawDispListsolid(lb, ob, dflag, ob_wire_col, false); | drawDispListsolid(lb, ob, dflag, ob_wire_col, false); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| return drawDispListwire(lb, ob->type); | return drawDispListwire(lb, ob->type); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, | static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, | ||||
| const char dt, const short dflag, const unsigned char ob_wire_col[4]) | const char dt, const short dflag, const unsigned char ob_wire_col[4], DupliObject *dob) | ||||
| { | { | ||||
| bool retval; | bool retval; | ||||
| /* backface culling */ | /* backface culling */ | ||||
| if (v3d->flag2 & V3D_BACKFACE_CULLING) { | if (v3d->flag2 & V3D_BACKFACE_CULLING) { | ||||
| /* not all displists use same in/out normal direction convention */ | /* not all displists use same in/out normal direction convention */ | ||||
| glEnable(GL_CULL_FACE); | glEnable(GL_CULL_FACE); | ||||
| glCullFace(GL_BACK); | glCullFace(GL_BACK); | ||||
| } | } | ||||
| #ifdef SEQUENCER_DAG_WORKAROUND | #ifdef SEQUENCER_DAG_WORKAROUND | ||||
| ensure_curve_cache(scene, base->object); | ensure_curve_cache(scene, base->object); | ||||
| #endif | #endif | ||||
| if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == false) { | if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt, dob) == false) { | ||||
| retval = false; | retval = false; | ||||
| } | } | ||||
| else { | else { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| GLenum mode; | GLenum mode; | ||||
| if (ob->type == OB_MBALL) { | if (ob->type == OB_MBALL) { | ||||
| mode = (ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW; | mode = (ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW; | ||||
| } | } | ||||
| else { | else { | ||||
| mode = (ob->transflag & OB_NEG_SCALE) ? GL_CCW : GL_CW; | mode = (ob->transflag & OB_NEG_SCALE) ? GL_CCW : GL_CW; | ||||
| } | } | ||||
| glFrontFace(mode); | glFrontFace(mode); | ||||
| retval = drawDispList_nobackface(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | retval = drawDispList_nobackface(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| if (mode != GL_CCW) { | if (mode != GL_CCW) { | ||||
| glFrontFace(GL_CCW); | glFrontFace(GL_CCW); | ||||
| } | } | ||||
| } | } | ||||
| if (v3d->flag2 & V3D_BACKFACE_CULLING) { | if (v3d->flag2 & V3D_BACKFACE_CULLING) { | ||||
| glDisable(GL_CULL_FACE); | glDisable(GL_CULL_FACE); | ||||
| ▲ Show 20 Lines • Show All 1,658 Lines • ▼ Show 20 Lines | while (nu) { | ||||
| index++; | index++; | ||||
| nu = nu->next; | nu = nu->next; | ||||
| } | } | ||||
| } | } | ||||
| static void draw_editnurb( | static void draw_editnurb( | ||||
| Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb, | Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb, | ||||
| const char dt, const short dflag, const unsigned char ob_wire_col[4]) | const char dt, const short dflag, const unsigned char ob_wire_col[4], DupliObject *dob) | ||||
| { | { | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| Curve *cu = ob->data; | Curve *cu = ob->data; | ||||
| Nurb *nu; | Nurb *nu; | ||||
| BevList *bl; | BevList *bl; | ||||
| const void *vert = BKE_curve_vert_active_get(cu); | const void *vert = BKE_curve_vert_active_get(cu); | ||||
| const bool hide_handles = (cu->drawflag & CU_HIDE_HANDLES) != 0; | const bool hide_handles = (cu->drawflag & CU_HIDE_HANDLES) != 0; | ||||
| int index; | int index; | ||||
| unsigned char wire_col[3]; | unsigned char wire_col[3]; | ||||
| /* DispList */ | /* DispList */ | ||||
| UI_GetThemeColor3ubv(TH_WIRE_EDIT, wire_col); | UI_GetThemeColor3ubv(TH_WIRE_EDIT, wire_col); | ||||
| glColor3ubv(wire_col); | glColor3ubv(wire_col); | ||||
| drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| /* for shadows only show solid faces */ | /* for shadows only show solid faces */ | ||||
| if (v3d->flag2 & V3D_RENDER_SHADOW) { | if (v3d->flag2 & V3D_RENDER_SHADOW) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (v3d->zbuf) glDepthFunc(GL_ALWAYS); | if (v3d->zbuf) glDepthFunc(GL_ALWAYS); | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | static void draw_editfont_textcurs(RegionView3D *rv3d, float textcurs[4][2]) | ||||
| glVertex2fv(textcurs[2]); | glVertex2fv(textcurs[2]); | ||||
| glVertex2fv(textcurs[3]); | glVertex2fv(textcurs[3]); | ||||
| glEnd(); | glEnd(); | ||||
| set_inverted_drawing(0); | set_inverted_drawing(0); | ||||
| ED_view3d_polygon_offset(rv3d, 0.0); | ED_view3d_polygon_offset(rv3d, 0.0); | ||||
| } | } | ||||
| static void draw_editfont(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, | static void draw_editfont(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, | ||||
| const char dt, const short dflag, const unsigned char ob_wire_col[4]) | const char dt, const short dflag, const unsigned char ob_wire_col[4], DupliObject *dob) | ||||
| { | { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| Curve *cu = ob->data; | Curve *cu = ob->data; | ||||
| EditFont *ef = cu->editfont; | EditFont *ef = cu->editfont; | ||||
| float vec1[3], vec2[3]; | float vec1[3], vec2[3]; | ||||
| int i, selstart, selend; | int i, selstart, selend; | ||||
| draw_editfont_textcurs(rv3d, ef->textcurs); | draw_editfont_textcurs(rv3d, ef->textcurs); | ||||
| if (cu->flag & CU_FAST) { | if (cu->flag & CU_FAST) { | ||||
| cpack(0xFFFFFF); | cpack(0xFFFFFF); | ||||
| set_inverted_drawing(1); | set_inverted_drawing(1); | ||||
| drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col); | drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col, dob); | ||||
| set_inverted_drawing(0); | set_inverted_drawing(0); | ||||
| } | } | ||||
| else { | else { | ||||
| drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| } | } | ||||
| if (cu->linewidth != 0.0f) { | if (cu->linewidth != 0.0f) { | ||||
| UI_ThemeColor(TH_WIRE_EDIT); | UI_ThemeColor(TH_WIRE_EDIT); | ||||
| copy_v3_v3(vec1, ob->orig); | copy_v3_v3(vec1, ob->orig); | ||||
| copy_v3_v3(vec2, ob->orig); | copy_v3_v3(vec2, ob->orig); | ||||
| vec1[0] += cu->linewidth; | vec1[0] += cu->linewidth; | ||||
| vec2[0] += cu->linewidth; | vec2[0] += cu->linewidth; | ||||
| ▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | static void drawcone(const float vec[3], float radius, float height, float tmat[4][4]) | ||||
| glVertex3f(cur[0], cur[1] + radius, cur[2]); | glVertex3f(cur[0], cur[1] + radius, cur[2]); | ||||
| glVertex3f(vec[0], vec[1], vec[2]); | glVertex3f(vec[0], vec[1], vec[2]); | ||||
| glVertex3f(cur[0], cur[1] - radius, cur[2]); | glVertex3f(cur[0], cur[1] - radius, cur[2]); | ||||
| glEnd(); | glEnd(); | ||||
| } | } | ||||
| /* return true if nothing was drawn */ | /* return true if nothing was drawn */ | ||||
| static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, | static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, | ||||
| const char dt, const short dflag, const unsigned char ob_wire_col[4]) | const char dt, const short dflag, const unsigned char ob_wire_col[4], DupliObject *dob) | ||||
| { | { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| MetaBall *mb; | MetaBall *mb; | ||||
| MetaElem *ml; | MetaElem *ml; | ||||
| float imat[4][4]; | float imat[4][4]; | ||||
| int code = 1; | int code = 1; | ||||
| mb = ob->data; | mb = ob->data; | ||||
| if (mb->editelems) { | if (mb->editelems) { | ||||
| if ((G.f & G_PICKSEL) == 0) { | if ((G.f & G_PICKSEL) == 0) { | ||||
| unsigned char wire_col[4]; | unsigned char wire_col[4]; | ||||
| UI_GetThemeColor4ubv(TH_WIRE_EDIT, wire_col); | UI_GetThemeColor4ubv(TH_WIRE_EDIT, wire_col); | ||||
| glColor3ubv(wire_col); | glColor3ubv(wire_col); | ||||
| drawDispList(scene, v3d, rv3d, base, dt, dflag, wire_col); | drawDispList(scene, v3d, rv3d, base, dt, dflag, wire_col, dob); | ||||
| } | } | ||||
| ml = mb->editelems->first; | ml = mb->editelems->first; | ||||
| } | } | ||||
| else { | else { | ||||
| if ((base->flag & OB_FROMDUPLI) == 0) { | if ((base->flag & OB_FROMDUPLI) == 0) { | ||||
| drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| } | } | ||||
| ml = mb->elems.first; | ml = mb->elems.first; | ||||
| } | } | ||||
| if (ml == NULL) { | if (ml == NULL) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 649 Lines • ▼ Show 20 Lines | case RB_SHAPE_CAPSULE: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * main object drawing function, draws in selection | * main object drawing function, draws in selection | ||||
| * \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET | * \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET | ||||
| */ | */ | ||||
| void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag) | void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag, DupliObject *dob) | ||||
| { | { | ||||
| ModifierData *md = NULL; | ModifierData *md = NULL; | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| Curve *cu; | Curve *cu; | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| unsigned int col = 0; | unsigned int col = 0; | ||||
| unsigned char _ob_wire_col[4]; /* dont initialize this */ | unsigned char _ob_wire_col[4]; /* dont initialize this */ | ||||
| const unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */ | const unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */ | ||||
| ▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) { | ||||
| if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) { | if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) { | ||||
| drawObjectSelect(scene, v3d, ar, base, ob_wire_col); | drawObjectSelect(scene, v3d, ar, base, ob_wire_col); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| switch (ob->type) { | switch (ob->type) { | ||||
| case OB_MESH: | case OB_MESH: | ||||
| empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); | empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag, dob); | ||||
| if ((dflag & DRAW_CONSTCOLOR) == 0) { | if ((dflag & DRAW_CONSTCOLOR) == 0) { | ||||
| /* mesh draws wire itself */ | /* mesh draws wire itself */ | ||||
| dtx &= ~OB_DRAWWIRE; | dtx &= ~OB_DRAWWIRE; | ||||
| } | } | ||||
| break; | break; | ||||
| case OB_FONT: | case OB_FONT: | ||||
| cu = ob->data; | cu = ob->data; | ||||
| if (cu->editfont) { | if (cu->editfont) { | ||||
| draw_editfont(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | draw_editfont(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| } | } | ||||
| else if (dt == OB_BOUNDBOX) { | else if (dt == OB_BOUNDBOX) { | ||||
| if ((render_override && v3d->drawtype >= OB_WIRE) == 0) { | if ((render_override && v3d->drawtype >= OB_WIRE) == 0) { | ||||
| #ifdef SEQUENCER_DAG_WORKAROUND | #ifdef SEQUENCER_DAG_WORKAROUND | ||||
| ensure_curve_cache(scene, base->object); | ensure_curve_cache(scene, base->object); | ||||
| #endif | #endif | ||||
| draw_bounding_volume(ob, ob->boundtype); | draw_bounding_volume(ob, ob->boundtype); | ||||
| } | } | ||||
| } | } | ||||
| else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) { | else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) { | ||||
| empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| } | } | ||||
| break; | break; | ||||
| case OB_CURVE: | case OB_CURVE: | ||||
| case OB_SURF: | case OB_SURF: | ||||
| cu = ob->data; | cu = ob->data; | ||||
| if (cu->editnurb) { | if (cu->editnurb) { | ||||
| ListBase *nurbs = BKE_curve_editNurbs_get(cu); | ListBase *nurbs = BKE_curve_editNurbs_get(cu); | ||||
| draw_editnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col); | draw_editnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col, dob); | ||||
| } | } | ||||
| else if (dt == OB_BOUNDBOX) { | else if (dt == OB_BOUNDBOX) { | ||||
| if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) { | if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) { | ||||
| #ifdef SEQUENCER_DAG_WORKAROUND | #ifdef SEQUENCER_DAG_WORKAROUND | ||||
| ensure_curve_cache(scene, base->object); | ensure_curve_cache(scene, base->object); | ||||
| #endif | #endif | ||||
| draw_bounding_volume(ob, ob->boundtype); | draw_bounding_volume(ob, ob->boundtype); | ||||
| } | } | ||||
| } | } | ||||
| else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) { | else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) { | ||||
| empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| } | } | ||||
| break; | break; | ||||
| case OB_MBALL: | case OB_MBALL: | ||||
| { | { | ||||
| MetaBall *mb = ob->data; | MetaBall *mb = ob->data; | ||||
| if (mb->editelems) | if (mb->editelems) | ||||
| drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| else if (dt == OB_BOUNDBOX) { | else if (dt == OB_BOUNDBOX) { | ||||
| if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) { | if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) { | ||||
| #ifdef SEQUENCER_DAG_WORKAROUND | #ifdef SEQUENCER_DAG_WORKAROUND | ||||
| ensure_curve_cache(scene, base->object); | ensure_curve_cache(scene, base->object); | ||||
| #endif | #endif | ||||
| draw_bounding_volume(ob, ob->boundtype); | draw_bounding_volume(ob, ob->boundtype); | ||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); | empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col, dob); | ||||
| break; | break; | ||||
| } | } | ||||
| case OB_EMPTY: | case OB_EMPTY: | ||||
| if (!render_override) { | if (!render_override) { | ||||
| if (ob->empty_drawtype == OB_EMPTY_IMAGE) { | if (ob->empty_drawtype == OB_EMPTY_IMAGE) { | ||||
| draw_empty_image(ob, dflag, ob_wire_col); | draw_empty_image(ob, dflag, ob_wire_col); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 740 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ************* draw object instances for bones, for example ****************** */ | /* ************* draw object instances for bones, for example ****************** */ | ||||
| /* assumes all matrices/etc set OK */ | /* assumes all matrices/etc set OK */ | ||||
| /* helper function for drawing object instances - meshes */ | /* helper function for drawing object instances - meshes */ | ||||
| static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, | static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, | ||||
| Object *ob, const short dt, int outline) | Object *ob, const short dt, int outline, DupliObject *dob) | ||||
| { | { | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| DerivedMesh *dm = NULL, *edm = NULL; | DerivedMesh *dm = NULL, *edm = NULL; | ||||
| int glsl; | int glsl; | ||||
| if (ob->mode & OB_MODE_EDIT) { | if (ob->mode & OB_MODE_EDIT) { | ||||
| edm = editbmesh_get_derived_base(ob, me->edit_btmesh); | edm = editbmesh_get_derived_base(ob, me->edit_btmesh); | ||||
| DM_update_materials(edm, ob); | DM_update_materials(edm, ob); | ||||
| Show All 10 Lines | else if (edm) | ||||
| edm->drawEdges(edm, 1, 0); | edm->drawEdges(edm, 1, 0); | ||||
| } | } | ||||
| else { | else { | ||||
| if (outline) | if (outline) | ||||
| draw_mesh_object_outline(v3d, ob, dm ? dm : edm); | draw_mesh_object_outline(v3d, ob, dm ? dm : edm); | ||||
| if (dm) { | if (dm) { | ||||
| glsl = draw_glsl_material(scene, ob, v3d, dt); | glsl = draw_glsl_material(scene, ob, v3d, dt); | ||||
| GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); | GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL, dob); | ||||
| } | } | ||||
| else { | else { | ||||
| glEnable(GL_COLOR_MATERIAL); | glEnable(GL_COLOR_MATERIAL); | ||||
| UI_ThemeColor(TH_BONE_SOLID); | UI_ThemeColor(TH_BONE_SOLID); | ||||
| glDisable(GL_COLOR_MATERIAL); | glDisable(GL_COLOR_MATERIAL); | ||||
| } | } | ||||
| glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); | glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); | ||||
| glEnable(GL_LIGHTING); | glEnable(GL_LIGHTING); | ||||
| if (dm) { | if (dm) { | ||||
| dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); | dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); | ||||
| GPU_end_object_materials(); | GPU_end_object_materials(); | ||||
| } | } | ||||
| else if (edm) | else if (edm) | ||||
| edm->drawMappedFaces(edm, NULL, GPU_enable_material, NULL, NULL, 0); | edm->drawMappedFaces(edm, NULL, GPU_enable_material, NULL, NULL, 0); | ||||
| glDisable(GL_LIGHTING); | glDisable(GL_LIGHTING); | ||||
| } | } | ||||
| if (edm) edm->release(edm); | if (edm) edm->release(edm); | ||||
| if (dm) dm->release(dm); | if (dm) dm->release(dm); | ||||
| } | } | ||||
| void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, const char dt, int outline) | void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, const char dt, int outline, DupliObject *dob) | ||||
| { | { | ||||
| if (ob == NULL) | if (ob == NULL) | ||||
| return; | return; | ||||
| switch (ob->type) { | switch (ob->type) { | ||||
| case OB_MESH: | case OB_MESH: | ||||
| draw_object_mesh_instance(scene, v3d, rv3d, ob, dt, outline); | draw_object_mesh_instance(scene, v3d, rv3d, ob, dt, outline, dob); | ||||
| break; | break; | ||||
| case OB_EMPTY: | case OB_EMPTY: | ||||
| if (ob->empty_drawtype == OB_EMPTY_IMAGE) { | if (ob->empty_drawtype == OB_EMPTY_IMAGE) { | ||||
| /* CONSTCOLOR == no wire outline */ | /* CONSTCOLOR == no wire outline */ | ||||
| draw_empty_image(ob, DRAW_CONSTCOLOR, NULL); | draw_empty_image(ob, DRAW_CONSTCOLOR, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| drawaxes(ob->empty_drawsize, ob->empty_drawtype); | drawaxes(ob->empty_drawsize, ob->empty_drawtype); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||