diff options
-rw-r--r-- | release/ui/space_image.py | 836 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 41 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 27 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 20 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_meshdata_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 1 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp | 412 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h | 89 |
12 files changed, 866 insertions, 585 deletions
diff --git a/release/ui/space_image.py b/release/ui/space_image.py new file mode 100644 index 00000000000..3623b914942 --- /dev/null +++ b/release/ui/space_image.py @@ -0,0 +1,836 @@ + +import bpy + +class IMAGE_MT_view(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "View" + + def draw(self, context): + layout = self.layout + sima = context.space_data + uv = sima.uv_editor + + show_uvedit = sima.show_uvedit + + layout.itemO("IMAGE_OT_properties") # icon + + layout.itemS() + + layout.itemR(sima, "update_automatically") + # XXX if show_uvedit: + # XXX layout.itemR(uv, "local_view") # "UV Local View", Numpad / + + layout.itemS() + + layout.itemO("IMAGE_OT_view_zoom_in") + layout.itemO("IMAGE_OT_view_zoom_out") + + layout.itemS() + + ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]]; + + for a, b in ratios: + text = "Zoom %d:%d" % (a, b) + layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text) + + layout.itemS() + + if show_uvedit: + layout.itemO("IMAGE_OT_view_selected") + + layout.itemO("IMAGE_OT_view_all") + layout.itemO("SCREEN_OT_screen_full_area") + +class IMAGE_MT_select(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_select_border") + layout.item_booleanO("UV_OT_select_border", "pinned", True) + + layout.itemS() + + layout.itemO("UV_OT_select_all_toggle") + layout.itemO("UV_OT_select_invert") + layout.itemO("UV_OT_unlink_selection") + + layout.itemS() + + layout.itemO("UV_OT_select_pinned") + layout.itemO("UV_OT_select_linked") + +class IMAGE_MT_image(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Image" + + def draw(self, context): + layout = self.layout + sima = context.space_data + ima = sima.image + + layout.itemO("IMAGE_OT_new") + layout.itemO("IMAGE_OT_open") + + show_render = sima.show_render + + if ima: + if show_render: + layout.itemO("IMAGE_OT_replace") + layout.itemO("IMAGE_OT_reload") + + layout.itemO("IMAGE_OT_save") + layout.itemO("IMAGE_OT_save_as") + + if ima.source == "SEQUENCE": + layout.itemO("IMAGE_OT_save_sequence") + + if not show_render: + layout.itemS() + + if ima.packed_file: + layout.itemO("IMAGE_OT_unpack") + else: + layout.itemO("IMAGE_OT_pack") + + # only for dirty && specific image types : XXX poll? + #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + if False: + if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER": + layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG") + + layout.itemS() + + layout.itemR(sima, "image_painting") + +class IMAGE_MT_uvs_showhide(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Show/Hide Faces" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_reveal") + layout.itemO("UV_OT_hide") + layout.item_booleanO("UV_OT_hide", "unselected", True) + +class IMAGE_MT_uvs_transform(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Transform" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION") + layout.item_enumO("TFM_OT_transform", "mode", "ROTATION") + layout.item_enumO("TFM_OT_transform", "mode", "RESIZE") + +class IMAGE_MT_uvs_mirror(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Mirror" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M, + layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M, + +class IMAGE_MT_uvs_weldalign(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Weld/Align" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_weld") # W, 1 + layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4 + + +class IMAGE_MT_uvs(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "UVs" + + def draw(self, context): + layout = self.layout + sima = context.space_data + uv = sima.uv_editor + scene = context.scene + + layout.itemR(uv, "snap_to_pixels") + layout.itemR(uv, "constrain_to_image_bounds") + + layout.itemS() + + layout.itemR(uv, "live_unwrap") + layout.itemO("UV_OT_unwrap") + layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin") + layout.itemO("UV_OT_pin") + + layout.itemS() + + layout.itemO("UV_OT_pack_islands") + layout.itemO("UV_OT_average_islands_scale") + layout.itemO("UV_OT_minimize_stretch") + layout.itemO("UV_OT_stitch") + + layout.itemS() + + layout.itemM(context, "IMAGE_MT_uvs_transform") + layout.itemM(context, "IMAGE_MT_uvs_mirror") + layout.itemM(context, "IMAGE_MT_uvs_weldalign") + + layout.itemS() + + # XXX layout.itemR(scene, "proportional_editing") + layout.item_menu_enumR(scene, "proportional_editing_falloff") + + layout.itemS() + + layout.itemM(context, "IMAGE_MT_uvs_showhide") + +class IMAGE_HT_header(bpy.types.Header): + __space_type__ = "IMAGE_EDITOR" + + def draw(self, context): + sima = context.space_data + ima = sima.image + layout = self.layout + + show_render = sima.show_render + show_paint = sima.show_paint + show_uvedit = sima.show_uvedit + + layout.template_header(context) + + # menus + if context.area.show_menus: + row = layout.row() + row.itemM(context, "IMAGE_MT_view") + + if show_uvedit: + row.itemM(context, "IMAGE_MT_select") + + # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image"; + row.itemM(context, "IMAGE_MT_image") + + if show_uvedit: + row.itemM(context, "IMAGE_MT_uvs") + + layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open") + + """ + /* image select */ + + pinflag= (show_render)? 0: UI_ID_PIN; + xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco, + sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag); + xco += 8; + """ + + """ + if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) { + /* XXX this should not be a static var */ + static int headerbuttons_packdummy; + + headerbuttons_packdummy = 0; + + if (ima->packedfile) { + headerbuttons_packdummy = 1; + } + if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG"); + else + uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image"); + + xco+= XIC+8; + } + """ + + # uv editing + if show_uvedit: + pass + + """ + /* uv editing */ + if(show_uvedit) { + /* pivot */ + uiDefIconTextButS(block, ICONTEXTROW, B_NOP, ICON_ROTATE, + "Pivot: %t|Bounding Box Center %x0|Median Point %x3|2D Cursor %x1", + xco,yco,XIC+10,YIC, &ar->v2d.around, 0, 3.0, 0, 0, + "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)"); + xco+= XIC + 18; + + /* selection modes */ + uiDefIconButBitS(block, TOG, UV_SYNC_SELECTION, B_REDR, ICON_EDIT, xco,yco,XIC,YIC, &scene->toolsettings->uv_flag, 0, 0, 0, 0, "Sync UV and Mesh Selection"); + xco+= XIC+8; + + if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { + uiBlockBeginAlign(block); + + uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_REDR, ICON_VERTEXSEL, + xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode"); + uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_REDR, ICON_EDGESEL, + xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode"); + uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_REDR, ICON_FACESEL, + xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode"); + + uiBlockEndAlign(block); + } + else { + uiBlockBeginAlign(block); + + uiDefIconButS(block, ROW, B_REDR, ICON_VERTEXSEL, + xco,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_VERTEX, 0, 0, "Vertex select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_EDGESEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode"); + + uiBlockEndAlign(block); + + /* would use these if const's could go in strings + * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */ + but = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC, + "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2", + xco+=XIC+10,yco,XIC+10,YIC, &(sima->sticky), 0, 3.0, 0, 0, + "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)"); + } + + xco+= XIC + 16; + + /* snap options, identical to options in 3d view header */ + uiBlockBeginAlign(block); + + if (scene->snap_flag & SCE_SNAP) { + uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab)."); + xco+= XIC; + uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,yco,70,YIC, &scene->snap_target, 0, 0, 0, 0, "Snap Target Mode."); + xco+= 70; + } + else { + uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)."); + xco+= XIC; + } + + uiBlockEndAlign(block); + xco+= 8; + + /* uv layers */ + { + Object *obedit= CTX_data_edit_object(C); + char menustr[34*MAX_MTFACE]; + static int act; + + image_menu_uvlayers(obedit, menustr, &act); + + but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing."); + // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL); + + xco+= 85; + } + + xco+= 8; + } + """ + + if ima: + """ + RenderResult *rr; + + /* render layers and passes */ + rr= BKE_image_get_renderresult(scene, ima); + if(rr) { + uiBlockBeginAlign(block); +#if 0 + uiblock_layer_pass_buttons(block, rr, &sima->iuser, B_REDR, xco, 0, 160); +#endif + uiBlockEndAlign(block); + xco+= 166; + } + """ + + # painting + layout.itemR(sima, "image_painting", text="") + + # draw options + row = layout.row(align=True) + row.itemR(sima, "draw_channels", text="", expand=True) + + row = layout.row(align=True) + if ima.type == "COMPOSITE": + row.itemO("IMAGE_OT_record_composite", icon="ICON_REC") + if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"): + row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY") + + layout.itemR(sima, "update_automatically", text="") + +class IMAGE_PT_game_properties(bpy.types.Panel): + __space_type__ = "IMAGE_EDITOR" + __region_type__ = "UI" + __label__ = "Game Properties" + + def draw(self, context): + sima = context.space_data + layout = self.layout + + ima = sima.image + + if ima: + split = layout.split() + + col = split.column(align=True) + col.itemR(ima, "animated") + + subcol = col.column() + subcol.itemR(ima, "animation_start", text="Start") + subcol.itemR(ima, "animation_end", text="End") + subcol.itemR(ima, "animation_speed", text="Speed") + subcol.active = ima.animated + + col = split.column() + col.itemR(ima, "tiles") + + subrow = col.row(align=True) + subrow.itemR(ima, "tiles_x", text="X") + subrow.itemR(ima, "tiles_y", text="Y") + subrow.active = ima.tiles + + col.itemS() + col.itemR(ima, "clamp_x") + col.itemR(ima, "clamp_y") + + col.itemR(ima, "mapping", expand=True) + +bpy.types.register(IMAGE_MT_view) +bpy.types.register(IMAGE_MT_select) +bpy.types.register(IMAGE_MT_image) +bpy.types.register(IMAGE_MT_uvs_showhide) +bpy.types.register(IMAGE_MT_uvs_transform) +bpy.types.register(IMAGE_MT_uvs_mirror) +bpy.types.register(IMAGE_MT_uvs_weldalign) +bpy.types.register(IMAGE_MT_uvs) +bpy.types.register(IMAGE_HT_header) +bpy.types.register(IMAGE_PT_game_properties) + + +import bpy + +class IMAGE_MT_view(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "View" + + def draw(self, context): + layout = self.layout + sima = context.space_data + uv = sima.uv_editor + + show_uvedit = sima.show_uvedit + + layout.itemO("IMAGE_OT_properties") # icon + + layout.itemS() + + layout.itemR(sima, "update_automatically") + # XXX if show_uvedit: + # XXX layout.itemR(uv, "local_view") # "UV Local View", Numpad / + + layout.itemS() + + layout.itemO("IMAGE_OT_view_zoom_in") + layout.itemO("IMAGE_OT_view_zoom_out") + + layout.itemS() + + ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]]; + + for a, b in ratios: + text = "Zoom %d:%d" % (a, b) + layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text) + + layout.itemS() + + if show_uvedit: + layout.itemO("IMAGE_OT_view_selected") + + layout.itemO("IMAGE_OT_view_all") + layout.itemO("SCREEN_OT_screen_full_area") + +class IMAGE_MT_select(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_select_border") + layout.item_booleanO("UV_OT_select_border", "pinned", True) + + layout.itemS() + + layout.itemO("UV_OT_select_all_toggle") + layout.itemO("UV_OT_select_invert") + layout.itemO("UV_OT_unlink_selection") + + layout.itemS() + + layout.itemO("UV_OT_select_pinned") + layout.itemO("UV_OT_select_linked") + +class IMAGE_MT_image(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Image" + + def draw(self, context): + layout = self.layout + sima = context.space_data + ima = sima.image + + layout.itemO("IMAGE_OT_new") + layout.itemO("IMAGE_OT_open") + + show_render = sima.show_render + + if ima: + if show_render: + layout.itemO("IMAGE_OT_replace") + layout.itemO("IMAGE_OT_reload") + + layout.itemO("IMAGE_OT_save") + layout.itemO("IMAGE_OT_save_as") + + if ima.source == "SEQUENCE": + layout.itemO("IMAGE_OT_save_sequence") + + if not show_render: + layout.itemS() + + if ima.packed_file: + layout.itemO("IMAGE_OT_unpack") + else: + layout.itemO("IMAGE_OT_pack") + + # only for dirty && specific image types : XXX poll? + #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + if False: + if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER": + layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG") + + layout.itemS() + + layout.itemR(sima, "image_painting") + +class IMAGE_MT_uvs_showhide(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Show/Hide Faces" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_reveal") + layout.itemO("UV_OT_hide") + layout.item_booleanO("UV_OT_hide", "unselected", True) + +class IMAGE_MT_uvs_transform(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Transform" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION") + layout.item_enumO("TFM_OT_transform", "mode", "ROTATION") + layout.item_enumO("TFM_OT_transform", "mode", "RESIZE") + +class IMAGE_MT_uvs_mirror(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Mirror" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M, + layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M, + +class IMAGE_MT_uvs_weldalign(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Weld/Align" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_weld") # W, 1 + layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4 + + +class IMAGE_MT_uvs(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "UVs" + + def draw(self, context): + layout = self.layout + sima = context.space_data + uv = sima.uv_editor + scene = context.scene + + layout.itemR(uv, "snap_to_pixels") + layout.itemR(uv, "constrain_to_image_bounds") + + layout.itemS() + + layout.itemR(uv, "live_unwrap") + layout.itemO("UV_OT_unwrap") + layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin") + layout.itemO("UV_OT_pin") + + layout.itemS() + + layout.itemO("UV_OT_pack_islands") + layout.itemO("UV_OT_average_islands_scale") + layout.itemO("UV_OT_minimize_stretch") + layout.itemO("UV_OT_stitch") + + layout.itemS() + + layout.itemM(context, "IMAGE_MT_uvs_transform") + layout.itemM(context, "IMAGE_MT_uvs_mirror") + layout.itemM(context, "IMAGE_MT_uvs_weldalign") + + layout.itemS() + + # XXX layout.itemR(scene, "proportional_editing") + layout.item_menu_enumR(scene, "proportional_editing_falloff") + + layout.itemS() + + layout.itemM(context, "IMAGE_MT_uvs_showhide") + +class IMAGE_HT_header(bpy.types.Header): + __space_type__ = "IMAGE_EDITOR" + + def draw(self, context): + sima = context.space_data + ima = sima.image + layout = self.layout + + show_render = sima.show_render + show_paint = sima.show_paint + show_uvedit = sima.show_uvedit + + layout.template_header(context) + + # menus + if context.area.show_menus: + row = layout.row() + row.itemM(context, "IMAGE_MT_view") + + if show_uvedit: + row.itemM(context, "IMAGE_MT_select") + + # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image"; + row.itemM(context, "IMAGE_MT_image") + + if show_uvedit: + row.itemM(context, "IMAGE_MT_uvs") + + layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open") + + """ + /* image select */ + + pinflag= (show_render)? 0: UI_ID_PIN; + xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco, + sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag); + xco += 8; + """ + + """ + if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) { + /* XXX this should not be a static var */ + static int headerbuttons_packdummy; + + headerbuttons_packdummy = 0; + + if (ima->packedfile) { + headerbuttons_packdummy = 1; + } + if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG"); + else + uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image"); + + xco+= XIC+8; + } + """ + + # uv editing + if show_uvedit: + pass + + """ + /* uv editing */ + if(show_uvedit) { + /* pivot */ + uiDefIconTextButS(block, ICONTEXTROW, B_NOP, ICON_ROTATE, + "Pivot: %t|Bounding Box Center %x0|Median Point %x3|2D Cursor %x1", + xco,yco,XIC+10,YIC, &ar->v2d.around, 0, 3.0, 0, 0, + "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)"); + xco+= XIC + 18; + + /* selection modes */ + uiDefIconButBitS(block, TOG, UV_SYNC_SELECTION, B_REDR, ICON_EDIT, xco,yco,XIC,YIC, &scene->toolsettings->uv_flag, 0, 0, 0, 0, "Sync UV and Mesh Selection"); + xco+= XIC+8; + + if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { + uiBlockBeginAlign(block); + + uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_REDR, ICON_VERTEXSEL, + xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode"); + uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_REDR, ICON_EDGESEL, + xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode"); + uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_REDR, ICON_FACESEL, + xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode"); + + uiBlockEndAlign(block); + } + else { + uiBlockBeginAlign(block); + + uiDefIconButS(block, ROW, B_REDR, ICON_VERTEXSEL, + xco,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_VERTEX, 0, 0, "Vertex select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_EDGESEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode"); + + uiBlockEndAlign(block); + + /* would use these if const's could go in strings + * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */ + but = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC, + "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2", + xco+=XIC+10,yco,XIC+10,YIC, &(sima->sticky), 0, 3.0, 0, 0, + "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)"); + } + + xco+= XIC + 16; + + /* snap options, identical to options in 3d view header */ + uiBlockBeginAlign(block); + + if (scene->snap_flag & SCE_SNAP) { + uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab)."); + xco+= XIC; + uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,yco,70,YIC, &scene->snap_target, 0, 0, 0, 0, "Snap Target Mode."); + xco+= 70; + } + else { + uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)."); + xco+= XIC; + } + + uiBlockEndAlign(block); + xco+= 8; + + /* uv layers */ + { + Object *obedit= CTX_data_edit_object(C); + char menustr[34*MAX_MTFACE]; + static int act; + + image_menu_uvlayers(obedit, menustr, &act); + + but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing."); + // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL); + + xco+= 85; + } + + xco+= 8; + } + """ + + if ima: + """ + RenderResult *rr; + + /* render layers and passes */ + rr= BKE_image_get_renderresult(scene, ima); + if(rr) { + uiBlockBeginAlign(block); +#if 0 + uiblock_layer_pass_buttons(block, rr, &sima->iuser, B_REDR, xco, 0, 160); +#endif + uiBlockEndAlign(block); + xco+= 166; + } + """ + + # painting + layout.itemR(sima, "image_painting", text="") + + # draw options + row = layout.row(align=True) + row.itemR(sima, "draw_channels", text="", expand=True) + + row = layout.row(align=True) + if ima.type == "COMPOSITE": + row.itemO("IMAGE_OT_record_composite", icon="ICON_REC") + if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"): + row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY") + + layout.itemR(sima, "update_automatically", text="") + +class IMAGE_PT_game_properties(bpy.types.Panel): + __space_type__ = "IMAGE_EDITOR" + __region_type__ = "UI" + __label__ = "Game Properties" + + def draw(self, context): + sima = context.space_data + layout = self.layout + + ima = sima.image + + if ima: + split = layout.split() + + col = split.column(align=True) + col.itemR(ima, "animated") + + subcol = col.column() + subcol.itemR(ima, "animation_start", text="Start") + subcol.itemR(ima, "animation_end", text="End") + subcol.itemR(ima, "animation_speed", text="Speed") + subcol.active = ima.animated + + col = split.column() + col.itemR(ima, "tiles") + + subrow = col.row(align=True) + subrow.itemR(ima, "tiles_x", text="X") + subrow.itemR(ima, "tiles_y", text="Y") + subrow.active = ima.tiles + + col.itemS() + col.itemR(ima, "clamp_x") + col.itemR(ima, "clamp_y") + + col.itemR(ima, "mapping", expand=True) + +bpy.types.register(IMAGE_MT_view) +bpy.types.register(IMAGE_MT_select) +bpy.types.register(IMAGE_MT_image) +bpy.types.register(IMAGE_MT_uvs_showhide) +bpy.types.register(IMAGE_MT_uvs_transform) +bpy.types.register(IMAGE_MT_uvs_mirror) +bpy.types.register(IMAGE_MT_uvs_weldalign) +bpy.types.register(IMAGE_MT_uvs) +bpy.types.register(IMAGE_HT_header) +bpy.types.register(IMAGE_PT_game_properties) + diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 45cf67de17e..83ef88a48a3 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4656,7 +4656,7 @@ void mesh_set_face_flags(EditMesh *em, short mode) { EditFace *efa; MTFace *tface; - short m_tex=0, m_tiles=0, m_shared=0, + short m_tex=0, m_shared=0, m_light=0, m_invis=0, m_collision=0, m_twoside=0, m_obcolor=0, m_halo=0, m_billboard=0, m_shadow=0, m_text=0, @@ -4669,7 +4669,6 @@ void mesh_set_face_flags(EditMesh *em, short mode) // } add_numbut(0, TOG|SHO, "Texture", 0, 0, &m_tex, NULL); - add_numbut(1, TOG|SHO, "Tiles", 0, 0, &m_tiles, NULL); add_numbut(2, TOG|SHO, "Light", 0, 0, &m_light, NULL); add_numbut(3, TOG|SHO, "Invisible", 0, 0, &m_invis, NULL); add_numbut(4, TOG|SHO, "Collision", 0, 0, &m_collision, NULL); @@ -4691,7 +4690,6 @@ void mesh_set_face_flags(EditMesh *em, short mode) m_billboard = 0; if (m_tex) flag |= TF_TEX; - if (m_tiles) flag |= TF_TILES; if (m_shared) flag |= TF_SHAREDCOL; if (m_light) flag |= TF_LIGHT; if (m_invis) flag |= TF_INVISIBLE; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 1effd8fd377..a163ef5f8e2 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4517,6 +4517,9 @@ static int paint_init(bContext *C, wmOperator *op) pop->ps.ar= CTX_wm_region(C); /* intialize brush */ + if(!settings->imapaint.brush) + return 0; + pop->s.brush = settings->imapaint.brush; pop->s.tool = settings->imapaint.tool; if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) @@ -4536,6 +4539,10 @@ static int paint_init(bContext *C, wmOperator *op) if (!pop->s.ob || !(pop->s.ob->lay & pop->ps.v3d->lay)) return 0; pop->s.me = get_mesh(pop->s.ob); if (!pop->s.me) return 0; + + /* Dont allow brush size below 2 */ + if (pop->ps.brush && pop->ps.brush->size<=1) + pop->ps.brush->size = 2; } else { pop->s.image = pop->s.sima->image; @@ -4548,10 +4555,6 @@ static int paint_init(bContext *C, wmOperator *op) return 0; } - - /* Dont allow brush size below 2 */ - if (pop->ps.brush->size<=1) - pop->ps.brush->size = 2; } /* note, if we have no UVs on the derived mesh, then we must return here */ diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 35004a4bdef..b5df0257e71 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -383,41 +383,6 @@ static void image_editcursor_buts(const bContext *C, View2D *v2d, uiBlock *block } } -static void image_panel_game_properties(const bContext *C, Panel *pa) -{ - SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); - ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); - uiBlock *block; - - block= uiLayoutFreeBlock(pa->layout); - uiBlockSetHandleFunc(block, do_image_panel_events, NULL); - - if (ibuf) { - char str[128]; - - image_info(sima->image, ibuf, str); - uiDefBut(block, LABEL, B_NOP, str, 10,180,300,19, 0, 0, 0, 0, 0, ""); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_TWINANIM, B_TWINANIM, "Anim", 10,150,140,19, &sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of animated texture"); - uiDefButS(block, NUM, B_TWINANIM, "Start:", 10,130,140,19, &sima->image->twsta, 0.0, 128.0, 0, 0, "Displays the start frame of an animated texture"); - uiDefButS(block, NUM, B_TWINANIM, "End:", 10,110,140,19, &sima->image->twend, 0.0, 128.0, 0, 0, "Displays the end frame of an animated texture"); - uiDefButS(block, NUM, B_NOP, "Speed", 10,90,140,19, &sima->image->animspeed, 1.0, 100.0, 0, 0, "Displays Speed of the animation in frames per second"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_TILES, B_SIMAGETILE, "Tiles", 160,150,140,19, &sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of tilemode for faces (Shift LMB to pick the tile for selected faces)"); - uiDefButS(block, NUM, B_REDR, "X:", 160,130,70,19, &sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction"); - uiDefButS(block, NUM, B_REDR, "Y:", 230,130,70,19, &sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction"); - uiBlockBeginAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_CLAMP_U, B_REDR, "ClampX", 160,100,70,19, &sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating horizontaly"); - uiDefButBitS(block, TOG, IMA_CLAMP_V, B_REDR, "ClampY", 230,100,70,19, &sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating vertically"); - uiBlockEndAlign(block); - } -} - static void image_panel_view_properties(const bContext *C, Panel *pa) { SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); @@ -1412,12 +1377,6 @@ void image_buttons_register(ARegionType *art) pt->draw= image_panel_properties; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype image panel game properties"); - strcpy(pt->idname, "IMAGE_PT_game_properties"); - strcpy(pt->label, "Game Properties"); - pt->draw= image_panel_game_properties; - BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype image view properties"); strcpy(pt->idname, "IMAGE_PT_view_properties"); strcpy(pt->label, "View Properties"); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 73a7f570c44..537996601b8 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -132,10 +132,10 @@ static int space_image_file_exists_poll(bContext *C) int space_image_main_area_poll(bContext *C) { SpaceLink *slink= CTX_wm_space_data(C); - ARegion *ar= CTX_wm_region(C); + // XXX ARegion *ar= CTX_wm_region(C); if(slink && (slink->spacetype == SPACE_IMAGE)) - return (ar && ar->type->regionid == RGN_TYPE_WINDOW); + return 1; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW); return 0; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index c82018a3aac..e12f3bfe357 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -270,13 +270,6 @@ static void image_refresh(const bContext *C, ScrArea *sa) if(sima->flag & SI_EDITTILE); else sima->curtile= tf->tile; - - if(ima) { - if(tf->mode & TF_TILES) - ima->tpageflag |= IMA_TILES; - else - ima->tpageflag &= ~IMA_TILES; - } } } @@ -286,8 +279,6 @@ static void image_refresh(const bContext *C, ScrArea *sa) static void image_listener(ScrArea *sa, wmNotifier *wmn) { - SpaceImage *sima= sa->spacedata.first; - /* context changes */ switch(wmn->category) { case NC_SCENE: @@ -301,8 +292,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_IMAGE: - if(!wmn->reference || wmn->reference == sima->image) - ED_area_tag_redraw(sa); + ED_area_tag_redraw(sa); break; } } @@ -508,11 +498,17 @@ static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn) /* add handlers, stuff you only do once or on area/region changes */ static void image_header_area_init(wmWindowManager *wm, ARegion *ar) { +#if 0 UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); +#else + ED_region_header_init(ar); +#endif } static void image_header_area_draw(const bContext *C, ARegion *ar) { + ED_region_header(C, ar); +#if 0 float col[3]; /* clear */ @@ -531,6 +527,7 @@ static void image_header_area_draw(const bContext *C, ARegion *ar) /* restore view matrix? */ UI_view2d_view_restore(C); +#endif } /**************************** spacetype *****************************/ @@ -616,10 +613,12 @@ void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obe if(sima->image && sima->image->id.us==0) sima->image->id.us= 1; - if(obedit) - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); + if(C) { + if(obedit) + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); - ED_area_tag_redraw(CTX_wm_area(C)); + ED_area_tag_redraw(CTX_wm_area(C)); + } } ImBuf *ED_space_image_buffer(SpaceImage *sima) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index a42008bef0c..7dca4d34c48 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -126,9 +126,6 @@ void ED_uvedit_assign_image(Scene *scene, Object *obedit, Image *ima, Image *pre tf->tpage= ima; tf->mode |= TF_TEX; - if(ima->tpageflag & IMA_TILES) tf->mode |= TF_TILES; - else tf->mode &= ~TF_TILES; - if(ima->id.us==0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); } @@ -150,7 +147,7 @@ void ED_uvedit_assign_image(Scene *scene, Object *obedit, Image *ima, Image *pre /* dotile - 1, set the tile flag (from the space image) * 2, set the tile index for the faces. */ -void ED_uvedit_set_tile(bContext *C, Scene *scene, Object *obedit, Image *ima, int curtile, int dotile) +void ED_uvedit_set_tile(bContext *C, Scene *scene, Object *obedit, Image *ima, int curtile) { EditMesh *em; EditFace *efa; @@ -169,17 +166,8 @@ void ED_uvedit_set_tile(bContext *C, Scene *scene, Object *obedit, Image *ima, i for(efa= em->faces.first; efa; efa= efa->next) { tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if(efa->h==0 && efa->f & SELECT) { - if(dotile==1) { - /* set tile flag */ - if(ima->tpageflag & IMA_TILES) - tf->mode |= TF_TILES; - else - tf->mode &= ~TF_TILES; - } - else if(dotile==2) - tf->tile= curtile; /* set tile index */ - } + if(efa->h==0 && efa->f & SELECT) + tf->tile= curtile; /* set tile index */ } DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); @@ -3005,7 +2993,7 @@ static int set_tile_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; RNA_int_get_array(op->ptr, "tile", tile); - ED_uvedit_set_tile(C, CTX_data_scene(C), CTX_data_edit_object(C), ima, tile[0] + ima->xrep*tile[1], 1); + ED_uvedit_set_tile(C, CTX_data_scene(C), CTX_data_edit_object(C), ima, tile[0] + ima->xrep*tile[1]); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index f8d0957f70d..5edb619f7e5 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -393,7 +393,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) /* initialize tile mode and number of repeats */ GTS.ima = ima; - GTS.tilemode= (tfmode & TF_TILES) || (ima && (ima->tpageflag & IMA_TWINANIM)); + GTS.tilemode= (ima && (ima->tpageflag & (IMA_TILES|IMA_TWINANIM))); GTS.tileXRep = 0; GTS.tileYRep = 0; @@ -423,7 +423,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) glMatrixMode(GL_TEXTURE); glLoadIdentity(); - if((tfmode & TF_TILES) && ima!=NULL) + if(ima && (ima->tpageflag & IMA_TILES)) glScalef(ima->xrep, ima->yrep, 1.0); glMatrixMode(GL_MODELVIEW); diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index c07989b2ce6..cec27b85b23 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -239,7 +239,7 @@ typedef struct PartialVisibility { #define TF_LIGHT 16 #define TF_SHAREDCOL 64 -#define TF_TILES 128 +#define TF_TILES 128 /* deprecated */ #define TF_BILLBOARD 256 #define TF_TWOSIDE 512 #define TF_INVISIBLE 1024 diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index e045c76057b..252cd633b69 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -217,7 +217,6 @@ static void rna_def_image(BlenderRNA *brna) prop= RNA_def_property(srna, "tiles", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_tile_set */ RNA_def_property_ui_text(prop, "Tiles", "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)."); prop= RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE); diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp deleted file mode 100644 index b1e2b5af0e6..00000000000 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "GL/glew.h" - -#include "GPC_PolygonMaterial.h" -#include "MT_Vector3.h" -#include "RAS_IRasterizer.h" -#include "RAS_GLExtensionManager.h" - -/* This list includes only data type definitions */ -#include "DNA_object_types.h" -#include "DNA_material_types.h" -#include "DNA_image_types.h" -#include "DNA_lamp_types.h" -#include "DNA_group_types.h" -#include "DNA_scene_types.h" -#include "DNA_camera_types.h" -#include "DNA_property_types.h" -#include "DNA_text_types.h" -#include "DNA_sensor_types.h" -#include "DNA_controller_types.h" -#include "DNA_actuator_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_view3d_types.h" -#include "DNA_world_types.h" - -#include "BKE_global.h" -#include "BKE_image.h" -#include "BKE_mesh.h" - -#include "MEM_guardedalloc.h" - -#include "IMB_imbuf_types.h" -/* end of blender include block */ - -static Image *fCurpage=0; -static int fCurtile=0, fCurmode=0, fCurTileXRep=0, fCurTileYRep=0; -static short fTexWindx, fTexWindy, fTexWinsx, fTexWinsy; -static int fDoMipMap = 1; -static int fLinearMipMap=1; -static int fAlphamode= -1; - - /* (n&(n-1)) zeros the least significant bit of n */ -static int is_pow2(int num) { - return ((num)&(num-1))==0; -} -static int smaller_pow2(int num) { - while (!is_pow2(num)) - num= num&(num-1); - return num; -} - -static void my_make_repbind(Image *ima) -{ - if(ima==0 || ima->ibufs.first==0) return; - - if(ima->repbind) { - glDeleteTextures(ima->totbind, (GLuint*)ima->repbind); - delete (ima->repbind); - ima->repbind= 0; - } - ima->totbind= ima->xrep*ima->yrep; - if(ima->totbind>1) { - ima->repbind= (unsigned int *) malloc(sizeof(int)*ima->totbind); - for (int i=0;i<ima->totbind;i++) - ((int*)ima->repbind)[i] = 0; - } -} - -extern "C" int set_tpage(MTFace *tface); - -int set_tpage(MTFace *tface) -{ - static MTFace *lasttface= 0; - Image *ima; - unsigned int *rect, *bind; - int tpx, tpy, tilemode, tileXRep,tileYRep; - - /* disable */ - if(tface==0) { - if(lasttface==0) return 0; - - lasttface= 0; - fCurtile= 0; - fCurpage= 0; - if(fCurmode!=0) { - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - } - fCurmode= 0; - fCurTileXRep=0; - fCurTileYRep=0; - fAlphamode= -1; - - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - return 0; - } - lasttface= tface; - - if( fAlphamode != tface->transp) { - fAlphamode= tface->transp; - - if(fAlphamode) { - if(fAlphamode==TF_ADD) { - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE); - glDisable ( GL_ALPHA_TEST ); - /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */ - } - else if(fAlphamode==TF_ALPHA) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable ( GL_ALPHA_TEST ); - /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */ - } - else if (fAlphamode==TF_CLIP){ - glDisable(GL_BLEND); - glEnable ( GL_ALPHA_TEST ); - glAlphaFunc(GL_GREATER, 0.5f); - } - /* else { */ - /* glBlendFunc(GL_ONE, GL_ONE); */ - /* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */ - /* } */ - } - else glDisable(GL_BLEND); - } - - ima= (struct Image *) tface->tpage; - - /* Enable or disable environment mapping */ - if (ima && (ima->flag & IMA_REFLECT)){ - - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - } - else{ - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - } - - tilemode= tface->mode & TF_TILES; - tileXRep = 0; - tileYRep = 0; - if (ima) - { - tileXRep = ima->xrep; - tileYRep = ima->yrep; - } - - - if(ima==fCurpage && fCurtile==tface->tile && tilemode==fCurmode && fCurTileXRep==tileXRep && fCurTileYRep == tileYRep) return ima!=0; - - if(tilemode!=fCurmode || fCurTileXRep!=tileXRep || fCurTileYRep != tileYRep) - { - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - - if(tilemode && ima!=0) - glScalef(ima->xrep, ima->yrep, 1.0); - - glMatrixMode(GL_MODELVIEW); - } - - if(ima==0 || ima->ok==0) { - glDisable(GL_TEXTURE_2D); - - fCurtile= tface->tile; - fCurpage= 0; - fCurmode= tilemode; - fCurTileXRep = tileXRep; - fCurTileYRep = tileYRep; - - return 0; - } - - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - - if(ibuf==0) { - ima->ok= 0; - - fCurtile= tface->tile; - fCurpage= 0; - fCurmode= tilemode; - fCurTileXRep = tileXRep; - fCurTileYRep = tileYRep; - - glDisable(GL_TEXTURE_2D); - return 0; - } - - if(ima->tpageflag & IMA_TWINANIM) fCurtile= ima->lastframe; - else fCurtile= tface->tile; - - if(tilemode) { - - if(ima->repbind==0) my_make_repbind(ima); - - if(fCurtile>=ima->totbind) fCurtile= 0; - - /* this happens when you change repeat buttons */ - if(ima->repbind) bind= ima->repbind+fCurtile; - else bind= &ima->bindcode; - - if(*bind==0) { - - fTexWindx= ibuf->x/ima->xrep; - fTexWindy= ibuf->y/ima->yrep; - - if(fCurtile>=ima->xrep*ima->yrep) fCurtile= ima->xrep*ima->yrep-1; - - fTexWinsy= fCurtile / ima->xrep; - fTexWinsx= fCurtile - fTexWinsy*ima->xrep; - - fTexWinsx*= fTexWindx; - fTexWinsy*= fTexWindy; - - tpx= fTexWindx; - tpy= fTexWindy; - - rect= ibuf->rect + fTexWinsy*ibuf->x + fTexWinsx; - } - } - else { - bind= &ima->bindcode; - - if(*bind==0) { - tpx= ibuf->x; - tpy= ibuf->y; - rect= ibuf->rect; - } - } - - if(*bind==0) { - int rectw= tpx, recth= tpy; - unsigned int *tilerect= NULL, *scalerect= NULL; - - /* - * Maarten: - * According to Ton this code is not needed anymore. It was used only - * in really old Blenders. - * Reevan: - * Actually it is needed for backwards compatibility. Simpledemo 6 does not display correctly without it. - */ -#if 1 - if (tilemode) { - int y; - - tilerect= (unsigned int*)MEM_mallocN(rectw*recth*sizeof(*tilerect), "tilerect"); - for (y=0; y<recth; y++) { - unsigned int *rectrow= &rect[y*ibuf->x]; - unsigned int *tilerectrow= &tilerect[y*rectw]; - - memcpy(tilerectrow, rectrow, tpx*sizeof(*rectrow)); - } - - rect= tilerect; - } -#endif - if (!is_pow2(rectw) || !is_pow2(recth)) { - rectw= smaller_pow2(rectw); - recth= smaller_pow2(recth); - - scalerect= (unsigned int *)MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect"); - gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect); - rect= scalerect; - } - - glGenTextures(1, (GLuint*)bind); - - /* - if(G.f & G_DEBUG) { - printf("var1: %s\n", ima->id.name+2); - printf("var1: %d, var2: %d\n", *bind, tpx); - printf("var1: %d, var2: %d\n", fCurtile, tilemode); - } - */ - glBindTexture( GL_TEXTURE_2D, *bind); - - if (!fDoMipMap) - { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } else - { - int minfilter= fLinearMipMap?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST; - - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - if (tilerect) - MEM_freeN(tilerect); - if (scalerect) - MEM_freeN(scalerect); - } - else glBindTexture( GL_TEXTURE_2D, *bind); - - - - glEnable(GL_TEXTURE_2D); - - fCurpage= ima; - fCurmode= tilemode; - fCurTileXRep = tileXRep; - fCurTileYRep = tileYRep; - - return 1; -} - -#if 0 -GPC_PolygonMaterial::GPC_PolygonMaterial(const STR_String& texname, bool ba, const STR_String& matname, - int tile, int tileXrep, int tileYrep, int mode, bool transparant, bool zsort, - int lightlayer, bool bIsTriangle, void* clientobject, void* tpage) : - RAS_IPolyMaterial(texname, ba, matname, tile, tileXrep, tileYrep, mode, - transparant, zsort, lightlayer, bIsTriangle, clientobject), m_tface((struct MTFace*)tpage) -{ - // clear local caching info - my_set_tpage(0); -} - - -GPC_PolygonMaterial::~GPC_PolygonMaterial(void) -{ -} - - -void GPC_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const -{ - if (GetCachingInfo() != cachingInfo) - { - if (!cachingInfo) - { - my_set_tpage(0); - } - cachingInfo = GetCachingInfo(); - - if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) ) - { - update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime()); - my_set_tpage(m_tface); - rasty->EnableTextures(true); - } else - { - my_set_tpage(0); - rasty->EnableTextures(false); - } - - //TF_TWOSIDE == 512, todo, make this a ketsji enum - if(m_drawingmode & 512) { - rasty->SetCullFace(false); - } - - else - { - rasty->SetCullFace(true);//glEnable(GL_CULL_FACE); - //else glDisable(GL_CULL_FACE); - } - } - rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity); - rasty->SetShinyness(m_shininess); - rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0); -} - -#endif -void GPC_PolygonMaterial::SetMipMappingEnabled(bool enabled) -{ - fDoMipMap = enabled ? 1 : 0; -} diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h deleted file mode 100644 index 212decd078c..00000000000 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __GPC_POLYGONMATERIAL -#define __GPC_POLYGONMATERIAL - -#include "RAS_IPolygonMaterial.h" - -namespace GPC_PolygonMaterial -{ - void SetMipMappingEnabled(bool enabled = false); -}; - -#if 0 -class GPC_PolygonMaterial : public RAS_IPolyMaterial -{ - struct MTFace* m_tface; - -public: - GPC_PolygonMaterial(const STR_String& texname, bool ba, const STR_String& matname, - int tile, int tileXrep, int tileYrep, int mode, bool transparant, bool zsort, - int lightlayer, bool bIsTriangle, void* clientobject, void* tpage); - - virtual ~GPC_PolygonMaterial(void); - - /** - * Returns the caching information for this material, - * This can be used to speed up the rasterizing process. - * @return The caching information. - */ - virtual TCachingInfo GetCachingInfo(void) const; - - /** - * Activates the material in the (OpenGL) rasterizer. - * On entry, the cachingInfo contains info about the last activated material. - * On exit, the cachingInfo should contain updated info about this material. - * @param rasty The rasterizer in which the material should be active. - * @param cachingInfo The information about the material used to speed up rasterizing. - */ - virtual void Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const; - - /** - * Returns the Blender texture face structure that is used for this material. - * @return The material's texture face. - */ - MTFace* GetMTFace(void) const; - - static void SetMipMappingEnabled(bool enabled = false); -}; - - -inline MTFace* GPC_PolygonMaterial::GetMTFace(void) const -{ - return m_tface; -} - -inline GPC_PolygonMaterial::TCachingInfo GPC_PolygonMaterial::GetCachingInfo(void) const -{ - return GetMTFace(); -} -#endif -#endif // __GPC_POLYGONMATERIAL_H - |