Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/drawobject.c
| Context not available. | |||||
| } | } | ||||
| 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; | ||||
| Context not available. | |||||
| 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 { | ||||
| Context not available. | |||||
| } | } | ||||
| 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; | ||||
| Context not available. | |||||
| 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)) { | ||||
| Context not available. | |||||
| /* 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; | ||||
| Context not available. | |||||
| 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(); | ||||
| Context not available. | |||||
| 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(); | ||||
| Context not available. | |||||
| } | } | ||||
| /* 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; | ||||
| Context not available. | |||||
| 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); | ||||
| Context not available. | |||||
| * \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; | ||||
| Context not available. | |||||
| } | } | ||||
| 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(); | ||||
| } | } | ||||
| Context not available. | |||||
| 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(); | ||||
| } | } | ||||
| Context not available. | |||||
| 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(); | ||||
| } | } | ||||
| Context not available. | |||||
| 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; | ||||
| Context not available. | |||||
| 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 { | ||||
| Context not available. | |||||
| 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); | ||||
| Context not available. | |||||
| 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; | ||||
| Context not available. | |||||
| 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) { | ||||
| Context not available. | |||||
| } | } | ||||
| 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; | ||||
| Context not available. | |||||
| 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) { | ||||
| Context not available. | |||||
| /* 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; | ||||
| Context not available. | |||||
| 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; | ||||
| } | } | ||||
| Context not available. | |||||
| * 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; | ||||
| Context not available. | |||||
| 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; | ||||
| Context not available. | |||||
| 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) { | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| 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; | ||||
| Context not available. | |||||
| 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) { | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| 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: | ||||
| Context not available. | |||||
| 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 | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| 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: | ||||
| Context not available. | |||||
| /* 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; | ||||
| Context not available. | |||||
| 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); | ||||
| Context not available. | |||||
| 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) { | ||||
| Context not available. | |||||