From 9d3157eed000e7c543d04f5ad3efc5990675903b Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 29 May 2010 21:22:24 +0000 Subject: Reversing the last merge because I botched it. --- .../blender/editors/interface/interface_handlers.c | 29 ++--- source/blender/editors/sound/sound_ops.c | 42 +------ source/blender/editors/space_view3d/view3d_edit.c | 4 +- source/blender/makesdna/DNA_object_types.h | 1 + source/blender/makesrna/intern/rna_object.c | 3 + source/blender/python/generic/blf_api.c | 2 +- source/blender/windowmanager/wm_event_types.h | 2 +- .../Converter/BL_BlenderDataConversion.cpp | 9 +- .../Converter/KX_BlenderSceneConverter.cpp | 118 ++++++++++--------- .../Converter/KX_BlenderSceneConverter.h | 2 +- .../GamePlayer/ghost/GPG_Application.cpp | 23 ++-- .../gameengine/GamePlayer/ghost/GPG_Application.h | 10 +- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 19 ++- source/gameengine/Ketsji/CMakeLists.txt | 4 + source/gameengine/Ketsji/KX_ConvertPhysicsObject.h | 3 +- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 8 ++ source/gameengine/Ketsji/KX_PythonInit.cpp | 5 +- source/gameengine/Ketsji/SConscript | 3 + .../Physics/Bullet/CcdPhysicsController.cpp | 5 + .../gameengine/Physics/common/PHY_DynamicTypes.h | 1 + .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 129 ++++++++++++++++++++- source/gameengine/Rasterizer/RAS_2DFilterManager.h | 8 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 2 + 23 files changed, 289 insertions(+), 143 deletions(-) (limited to 'source') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4e3ffad48ae..fb0822de677 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1659,7 +1659,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if (ui_mouse_inside_button(data->region, but, mx, my)) { + if ((but->y1 <= my) && (my <= but->y2) && (but->x1 <= mx) && (mx <= but->x2)) { ui_textedit_set_cursor_pos(but, data, mx); but->selsta = but->selend = but->pos; data->selstartx= mx; @@ -1999,17 +1999,14 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data if(event->type == MOUSEMOVE) return WM_UI_HANDLER_CONTINUE; - if(event->type == LEFTMOUSE && event->val==KM_PRESS) { - /* only cancel if click outside the button */ - if(ui_mouse_inside_button(but->active->region, but, event->x, event->y) == 0) { - /* data->cancel doesnt work, this button opens immediate */ - if(but->flag & UI_BUT_IMMEDIATE) - ui_set_but_val(but, 0); - else - data->cancel= 1; - button_activate_state(C, but, BUTTON_STATE_EXIT); - return WM_UI_HANDLER_BREAK; - } + if(event->type == ESCKEY) { + /* data->cancel doesnt work, this button opens immediate */ + if(but->flag & UI_BUT_IMMEDIATE) + ui_set_but_val(but, 0); + else + data->cancel= 1; + button_activate_state(C, but, BUTTON_STATE_EXIT); + return WM_UI_HANDLER_BREAK; } /* always set */ @@ -2043,11 +2040,15 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data return WM_UI_HANDLER_CONTINUE; } + static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { if(data->state == BUTTON_STATE_HIGHLIGHT) { if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { - button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); + short event= (short)ui_get_but_val(but); + /* hardcoded prevention from editing or assigning ESC */ + if(event!=ESCKEY) + button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); return WM_UI_HANDLER_BREAK; } } @@ -2056,7 +2057,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w return WM_UI_HANDLER_CONTINUE; if(event->val==KM_PRESS) { - if(WM_key_event_string(event->type)[0]) + if(event->type!=ESCKEY && WM_key_event_string(event->type)[0]) ui_set_but_val(but, event->type); else data->cancel= 1; diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index be4f6ff0570..376db0d3d58 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -30,13 +30,10 @@ #include #include -#include "MEM_guardedalloc.h" - #include "DNA_packedFile_types.h" #include "DNA_scene_types.h" #include "DNA_space_types.h" #include "DNA_sequence_types.h" -#include "DNA_userdef_types.h" #include "BKE_context.h" #include "BKE_global.h" @@ -64,30 +61,17 @@ /******************** open sound operator ********************/ -static void open_init(bContext *C, wmOperator *op) -{ - PropertyPointerRNA *pprop; - - op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); - uiIDContextProperty(C, &pprop->ptr, &pprop->prop); -} - static int open_exec(bContext *C, wmOperator *op) { char path[FILE_MAX]; bSound *sound; - PropertyPointerRNA *pprop; - PointerRNA idptr; AUD_SoundInfo info; RNA_string_get(op->ptr, "path", path); + sound = sound_new_file(CTX_data_main(C), path); - if(!op->customdata) - open_init(C, op); - if (sound==NULL || sound->playback_handle == NULL) { - if(op->customdata) MEM_freeN(op->customdata); BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; } @@ -96,7 +80,6 @@ static int open_exec(bContext *C, wmOperator *op) if (info.specs.channels == AUD_CHANNELS_INVALID) { sound_delete(C, sound); - if(op->customdata) MEM_freeN(op->customdata); BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; } @@ -104,34 +87,12 @@ static int open_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "cache")) { sound_cache(sound, 0); } - - /* hook into UI */ - pprop= op->customdata; - - if(pprop->prop) { - /* when creating new ID blocks, use is already 1, but RNA - * pointer se also increases user, so this compensates it */ - sound->id.us--; - - RNA_id_pointer_create(&sound->id, &idptr); - RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); - RNA_property_update(C, &pprop->ptr, pprop->prop); - } - MEM_freeN(op->customdata); return OPERATOR_FINISHED; } static int open_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!RNA_property_is_set(op->ptr, "relative_path")) - RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); - - if(RNA_property_is_set(op->ptr, "path")) - return open_exec(C, op); - - open_init(C, op); - return WM_operator_filesel(C, op, event); } @@ -152,7 +113,6 @@ void SOUND_OT_open(wmOperatorType *ot) /* properties */ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE); RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); - RNA_def_boolean(ot->srna, "relative_path", FALSE, "Relative Path", "Load image with relative path to current .blend file"); } /* ******************************************************* */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 5c2fe184d65..3d039f07a65 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1157,8 +1157,8 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) else { /* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */ - vod->origy = vod->oldy = vod->origy + event->x - event->prevx; - viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY); + vod->origy = vod->oldy = event->x; + viewzoom_apply(vod, event->x, event->prevx, USER_ZOOM_DOLLY); } request_depth_update(CTX_wm_region_view3d(C)); diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 9649b8351a6..e6b2e9a056c 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -402,6 +402,7 @@ extern Object workob; #define OB_BOUND_POLYH 4 #define OB_BOUND_POLYT 5 #define OB_BOUND_DYN_MESH 6 +#define OB_BOUND_CAPSULE 7 /* **************** BASE ********************* */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 12c4bb79e37..6e7a06af3ab 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -73,6 +73,7 @@ static EnumPropertyItem collision_bounds_items[] = { {OB_BOUND_CONE, "CONE", 0, "Cone", ""}, {OB_BOUND_POLYT, "CONVEX_HULL", 0, "Convex Hull", ""}, {OB_BOUND_POLYH, "TRIANGLE_MESH", 0, "Triangle Mesh", ""}, + {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""}, //{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, {0, NULL, 0, NULL, NULL}}; @@ -329,6 +330,7 @@ static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *C, PointerR RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER); RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE); RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX); + RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CAPSULE); } RNA_enum_item_end(&item, &totitem); @@ -1443,6 +1445,7 @@ static void rna_def_object(BlenderRNA *brna) {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""}, {OB_BOUND_CONE, "CONE", 0, "Cone", ""}, + {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""}, {OB_BOUND_POLYH, "POLYHEDER", 0, "Polyheder", ""}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/python/generic/blf_api.c b/source/blender/python/generic/blf_api.c index 67f07ad8378..3e19bbeb569 100644 --- a/source/blender/python/generic/blf_api.c +++ b/source/blender/python/generic/blf_api.c @@ -402,4 +402,4 @@ PyObject *BLF_Init(void) PyModule_AddIntConstant(submodule, "KERNING_DEFAULT", BLF_KERNING_DEFAULT); return (submodule); -} +} \ No newline at end of file diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index a93214e9a54..7b83e1d4179 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -226,7 +226,7 @@ #define ISTWEAK(event) (event >= EVT_TWEAK_L && event <= EVT_GESTURE) /* test whether event type is acceptable as hotkey, excluding modifiers */ -#define ISHOTKEY(event) ((ISKEYBOARD(event) || ISMOUSE(event)) && !(event>=LEFTCTRLKEY && event<=LEFTSHIFTKEY) && !(event>=UNKNOWNKEY && event<=GRLESSKEY)) +#define ISHOTKEY(event) ((ISKEYBOARD(event) || ISMOUSE(event)) && !(event>=LEFTCTRLKEY && event<=ESCKEY) && !(event>=UNKNOWNKEY && event<=GRLESSKEY)) /* **************** BLENDER GESTURE EVENTS ********************* */ diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 2f0f70ed9fe..efd93eb3102 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1570,6 +1570,13 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_boundobject.c.m_height = 2.f*bb.m_extends[2]; break; } + case OB_BOUND_CAPSULE: + { + objprop.m_boundclass = KX_BOUNDCAPSULE; + objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], bb.m_extends[1]); + objprop.m_boundobject.c.m_height = bb.m_extends[2]; + break; + } } } @@ -2691,4 +2698,4 @@ void BL_ConvertBlenderObjects(struct Main* maggie, MT_Scalar distance = (activecam)? activecam->GetCameraFar() - activecam->GetCameraNear(): 100.0f; RAS_BucketManager *bucketmanager = kxscene->GetBucketManager(); bucketmanager->OptimizeBuckets(distance); -} +} \ No newline at end of file diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 3a5bb92b4fa..4792ead8be2 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -932,7 +932,7 @@ Main* KX_BlenderSceneConverter::GetMainDynamicPath(const char *path) return NULL; } -bool KX_BlenderSceneConverter::LinkBlendFile(const char *path, char *group, KX_Scene *scene_merge, char **err_str) +bool KX_BlenderSceneConverter::LinkBlendFile(const char *path, char *group, char *filter, KX_Scene *scene_merge, char **err_str) { bContext *C; Main *main_newlib; /* stored as a dynamic 'main' until we free it */ @@ -941,6 +941,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(const char *path, char *group, KX_S BlendHandle *bpy_openlib = NULL; /* ptr to the open .blend file */ int idcode= BLO_idcode_from_name(group); short flag= 0; /* dont need any special options */ + bool found = false; /* used for error reporting when using item */ ReportList reports; static char err_local[255]; @@ -949,50 +950,48 @@ bool KX_BlenderSceneConverter::LinkBlendFile(const char *path, char *group, KX_S snprintf(err_local, sizeof(err_local), "invalid ID type given \"%s\"\n", group); return false; } - - if(GetMainDynamicPath(path)) { - snprintf(err_local, sizeof(err_local), "blend file already open \"%s\"\n", path); - *err_str= err_local; - return false; - } - bpy_openlib = BLO_blendhandle_from_file( (char *)path ); - if(bpy_openlib==NULL) { - snprintf(err_local, sizeof(err_local), "could not open blendfile \"%s\"\n", path); - *err_str= err_local; - return false; - } - - main_newlib= (Main *)MEM_callocN( sizeof(Main), "BgeMain"); - C= CTX_create(); - CTX_data_main_set(C, main_newlib); - BKE_reports_init(&reports, RPT_STORE); + main_newlib = GetMainDynamicPath(path); - /* here appending/linking starts */ - main_tmp = BLO_library_append_begin(C, &bpy_openlib, (char *)path); - - names = BLO_blendhandle_get_datablock_names( bpy_openlib, idcode); - - int i=0; - LinkNode *n= names; - while(n) { - BLO_library_append_named_part(C, main_tmp, &bpy_openlib, (char *)n->link, idcode, 0); - n= (LinkNode *)n->next; - i++; + if (main_newlib == NULL) + { + bpy_openlib = BLO_blendhandle_from_file( (char *)path ); + if(bpy_openlib==NULL) { + snprintf(err_local, sizeof(err_local), "could not open blendfile \"%s\"\n", path); + *err_str= err_local; + return false; + } + + main_newlib= (Main *)MEM_callocN( sizeof(Main), "BgeMain"); + C= CTX_create(); + CTX_data_main_set(C, main_newlib); + BKE_reports_init(&reports, RPT_STORE); + + /* here appending/linking starts */ + main_tmp = BLO_library_append_begin(C, &bpy_openlib, (char *)path); + + names = BLO_blendhandle_get_datablock_names( bpy_openlib, idcode); + + int i=0; + LinkNode *n= names; + while(n) { + BLO_library_append_named_part(C, main_tmp, &bpy_openlib, (char *)n->link, idcode, 0); + n= (LinkNode *)n->next; + i++; + } + BLI_linklist_free(names, free); /* free linklist *and* each node's data */ + + BLO_library_append_end(C, main_tmp, &bpy_openlib, idcode, flag); + BLO_blendhandle_close(bpy_openlib); + + CTX_free(C); + BKE_reports_clear(&reports); + /* done linking */ + + /* needed for lookups*/ + GetMainDynamic().push_back(main_newlib); + strncpy(main_newlib->name, path, sizeof(main_newlib->name)); } - BLI_linklist_free(names, free); /* free linklist *and* each node's data */ - - BLO_library_append_end(C, main_tmp, &bpy_openlib, idcode, flag); - BLO_blendhandle_close(bpy_openlib); - - CTX_free(C); - BKE_reports_clear(&reports); - /* done linking */ - - /* needed for lookups*/ - GetMainDynamic().push_back(main_newlib); - strncpy(main_newlib->name, path, sizeof(main_newlib->name)); - if(idcode==ID_ME) { /* Convert all new meshes into BGE meshes */ @@ -1000,24 +999,39 @@ bool KX_BlenderSceneConverter::LinkBlendFile(const char *path, char *group, KX_S KX_Scene *kx_scene= m_currentScene; for(mesh= (ID *)main_newlib->mesh.first; mesh; mesh= (ID *)mesh->next ) { - RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)mesh, NULL, scene_merge, this); - kx_scene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj); + /* If item is defined, use it to filter meshes */ + if (!strcmp(filter, "") || !strcmp(filter, mesh->name+2)) + { + found = true; + RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)mesh, NULL, scene_merge, this); + kx_scene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj); + } } } else if(idcode==ID_SCE) { /* Merge all new linked in scene into the existing one */ ID *scene; for(scene= (ID *)main_newlib->scene.first; scene; scene= (ID *)scene->next ) { - printf("SceneName: %s\n", scene->name); - - /* merge into the base scene */ - KX_Scene* other= m_ketsjiEngine->CreateScene((Scene *)scene); - scene_merge->MergeScene(other); - - // RemoveScene(other); // Dont run this, it frees the entire scene converter data, just delete the scene - delete other; + /* If item is defined, use it to filter scenes */ + if (!strcmp(filter, "") || !strcmp(filter, scene->name+2)) + { + found = true; + printf("Loading scene: %s\n", scene->name+2); + /* merge into the base scene */ + KX_Scene* other= m_ketsjiEngine->CreateScene((Scene *)scene); + scene_merge->MergeScene(other); + + // RemoveScene(other); // Dont run this, it frees the entire scene converter data, just delete the scene + delete other; + } } } + + if (found == false) + { + printf("Item not found: %s\n", filter); + return false; + } return true; } diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index 3dd3afb5662..341e4546430 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -142,7 +142,7 @@ public: struct Main* GetMainDynamicPath(const char *path); vector &GetMainDynamic(); - bool LinkBlendFile(const char *path, char *group, KX_Scene *scene_merge, char **err_str); + bool LinkBlendFile(const char *path, char *group, char *filter, KX_Scene *scene_merge, char **err_str); bool MergeScene(KX_Scene *to, KX_Scene *from); RAS_MeshObject *ConvertMeshSpecial(KX_Scene* kx_scene, Main *maggie, const char *name); bool FreeBlendFile(struct Main *maggie); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 71507642226..bde4bf3892b 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -228,7 +228,8 @@ static HWND findGhostWindowHWND(GHOST_IWindow* window) bool GPG_Application::startScreenSaverPreview( HWND parentWindow, const bool stereoVisual, - const int stereoMode) + const int stereoMode, + const GHOST_TUns16 samples) { bool success = false; @@ -240,7 +241,7 @@ bool GPG_Application::startScreenSaverPreview( STR_String title = ""; m_mainWindow = fSystem->createWindow(title, 0, 0, windowWidth, windowHeight, GHOST_kWindowStateMinimized, - GHOST_kDrawingContextTypeOpenGL, stereoVisual); + GHOST_kDrawingContextTypeOpenGL, stereoVisual, samples); if (!m_mainWindow) { printf("error: could not create main window\n"); exit(-1); @@ -282,9 +283,10 @@ bool GPG_Application::startScreenSaverFullScreen( int height, int bpp,int frequency, const bool stereoVisual, - const int stereoMode) + const int stereoMode, + const GHOST_TUns16 samples) { - bool ret = startFullScreen(width, height, bpp, frequency, stereoVisual, stereoMode); + bool ret = startFullScreen(width, height, bpp, frequency, stereoVisual, stereoMode, samples); if (ret) { HWND ghost_hwnd = findGhostWindowHWND(m_mainWindow); @@ -306,13 +308,14 @@ bool GPG_Application::startWindow(STR_String& title, int windowWidth, int windowHeight, const bool stereoVisual, - const int stereoMode) + const int stereoMode, + const GHOST_TUns16 samples) { bool success; // Create the main window //STR_String title ("Blender Player - GHOST"); m_mainWindow = fSystem->createWindow(title, windowLeft, windowTop, windowWidth, windowHeight, GHOST_kWindowStateNormal, - GHOST_kDrawingContextTypeOpenGL, stereoVisual); + GHOST_kDrawingContextTypeOpenGL, stereoVisual, samples); if (!m_mainWindow) { printf("error: could not create main window\n"); exit(-1); @@ -334,10 +337,11 @@ bool GPG_Application::startWindow(STR_String& title, bool GPG_Application::startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parentWindow, const bool stereoVisual, - const int stereoMode) { + const int stereoMode, + const GHOST_TUns16 samples) { m_mainWindow = fSystem->createWindow(title, 0, 0, 0, 0, GHOST_kWindowStateNormal, - GHOST_kDrawingContextTypeOpenGL, stereoVisual, parentWindow); + GHOST_kDrawingContextTypeOpenGL, stereoVisual,samples, parentWindow); if (!m_mainWindow) { printf("error: could not create main window\n"); @@ -358,7 +362,8 @@ bool GPG_Application::startFullScreen( int height, int bpp,int frequency, const bool stereoVisual, - const int stereoMode) + const int stereoMode, + const GHOST_TUns16 samples) { bool success; // Create the main window diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 48a6c8e78ec..e6a47628923 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -59,12 +59,12 @@ public: bool SetGameEngineData(struct Main* maggie, struct Scene* scene, int argc, char** argv); bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight, - const bool stereoVisual, const int stereoMode); - bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode); - bool startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parent_window, const bool stereoVisual, const int stereoMode); + const bool stereoVisual, const int stereoMode, const GHOST_TUns16 numOfAASamples = 0); + bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0); + bool startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parent_window, const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0); #ifdef WIN32 - bool startScreenSaverFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode); - bool startScreenSaverPreview(HWND parentWindow, const bool stereoVisual, const int stereoMode); + bool startScreenSaverFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0); + bool startScreenSaverPreview(HWND parentWindow, const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0); #endif virtual bool processEvent(GHOST_IEvent* event); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index b7ed8666325..69df00949a8 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -214,6 +214,7 @@ void usage(const char* program) printf(" -c: keep console window open\n\n"); #endif printf(" -d: turn debugging on\n\n"); + printf(" -m: sets the number of samples to request for multisampling"); printf(" -g: game engine options:\n\n"); printf(" Name Default Description\n"); printf(" ------------------------------------------------------------------------\n"); @@ -229,6 +230,7 @@ void usage(const char* program) printf("\n"); printf("example: %s -w 320 200 10 10 -g noaudio c:\\loadtest.blend\n", program); printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program); + printf("example: %s -m 4 game.blend", program); } static void get_filename(int argc, char **argv, char *filename) @@ -334,6 +336,7 @@ int main(int argc, char** argv) int windowHeight = 480; GHOST_TUns32 fullScreenWidth = 0; GHOST_TUns32 fullScreenHeight= 0; + GHOST_TUns16 aaSamples = 4; int fullScreenBpp = 32; int fullScreenFrequency = 60; GHOST_TEmbedderWindowID parentWindow = 0; @@ -508,6 +511,12 @@ int main(int argc, char** argv) } } break; + case 'm': + i++; + + if ((i+1) < argc) + aaSamples = atoi(argv[i++]); + break; case 'h': usage(argv[0]); @@ -810,13 +819,13 @@ int main(int argc, char** argv) if (scr_saver_mode == SCREEN_SAVER_MODE_SAVER) { app.startScreenSaverFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency, - stereoWindow, stereomode); + stereoWindow, stereomode, aaSamples); } else #endif { app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency, - stereoWindow, stereomode); + stereoWindow, stereomode, aaSamples); } } else @@ -856,16 +865,16 @@ int main(int argc, char** argv) #ifdef WIN32 if (scr_saver_mode == SCREEN_SAVER_MODE_PREVIEW) { - app.startScreenSaverPreview(scr_saver_hwnd, stereoWindow, stereomode); + app.startScreenSaverPreview(scr_saver_hwnd, stereoWindow, stereomode, aaSamples); } else #endif { if (parentWindow != 0) - app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode); + app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode, aaSamples); else app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight, - stereoWindow, stereomode); + stereoWindow, stereomode, aaSamples); } } } diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index c4af701f87b..1d41a7bcddb 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -69,6 +69,10 @@ ELSE(WITH_SDL) ADD_DEFINITIONS(-DDISABLE_SDL) ENDIF(WITH_SDL) +if(WITH_DDS) + ADD_DEFINITIONS(-DWITH_DDS) +ENDIF(WITH_DDS) + IF(WITH_PYTHON) SET(INC ${INC} ${PYTHON_INC}) ELSE(WITH_PYTHON) diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h index 879bcd472c6..850bf4b4ad4 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h @@ -53,7 +53,8 @@ typedef enum { KX_BOUNDCONE, KX_BOUNDMESH, KX_BOUNDPOLYTOPE, - KX_BOUND_DYN_MESH + KX_BOUND_DYN_MESH, + KX_BOUNDCAPSULE } KX_BoundBoxClass; struct KX_BoxBounds diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 44ae032179b..e793f9d5966 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -184,6 +184,14 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, bm = shapeInfo->CreateBulletShape(ci.m_margin); break; } + case KX_BOUNDCAPSULE: + { + shapeInfo->m_radius = objprop->m_boundobject.c.m_radius; + shapeInfo->m_height = objprop->m_boundobject.c.m_height; + shapeInfo->m_shapeType = PHY_SHAPE_CAPSULE; + bm = shapeInfo->CreateBulletShape(ci.m_margin); + break; + } case KX_BOUNDMESH: { // mesh shapes can be shared, check first if we already have a shape on that mesh diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 0198555753e..7b0283a2efd 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -628,12 +628,13 @@ static PyObject *gLibLoad(PyObject*, PyObject* args) KX_Scene *kx_scene= gp_KetsjiScene; char *path; char *group; + char *filter= ""; char *err_str= NULL; - if (!PyArg_ParseTuple(args,"ss:LibLoad",&path, &group)) + if (!PyArg_ParseTuple(args,"ss|s:LibLoad",&path, &group, &filter)) return NULL; - if(kx_scene->GetSceneConverter()->LinkBlendFile(path, group, kx_scene, &err_str)) { + if(kx_scene->GetSceneConverter()->LinkBlendFile(path, group, filter, kx_scene, &err_str)) { Py_RETURN_TRUE; } diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 58dc8a314bf..505d3fa10a0 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -23,6 +23,9 @@ incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include # incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] +if env['WITH_BF_DDS']: + defs.append('WITH_DDS') + if env['WITH_BF_SDL']: incs += ' ' + env['BF_SDL_INC'] else: diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index fe429200dd4..ac0f61857f5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -2027,6 +2027,11 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, b collisionShape->setMargin(margin); break; + case PHY_SHAPE_CAPSULE: + collisionShape = new btCapsuleShapeZ(m_radius, m_height); + collisionShape->setMargin(margin); + break; + case PHY_SHAPE_MESH: // Let's use the latest btScaledBvhTriangleMeshShape: it allows true sharing of // triangle mesh information between duplicates => drastic performance increase when diff --git a/source/gameengine/Physics/common/PHY_DynamicTypes.h b/source/gameengine/Physics/common/PHY_DynamicTypes.h index 08d94a2850a..4b5cdd41b9a 100644 --- a/source/gameengine/Physics/common/PHY_DynamicTypes.h +++ b/source/gameengine/Physics/common/PHY_DynamicTypes.h @@ -138,6 +138,7 @@ typedef enum PHY_ShapeType { PHY_SHAPE_SPHERE, PHY_SHAPE_CYLINDER, PHY_SHAPE_CONE, + PHY_SHAPE_CAPSULE, PHY_SHAPE_MESH, PHY_SHAPE_POLYTOPE, PHY_SHAPE_COMPOUND, diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 4527850a8e9..c0e08dba992 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -194,6 +194,15 @@ void RAS_2DFilterManager::AnalyseShader(int passindex, vector& propN { texflag[passindex] |= 0x2; } + if(glGetUniformLocationARB(m_filters[passindex], "bgl_QuarteredRenderTexture") != -1) + { + texflag[passindex] |= 0x4; + } + if(glGetUniformLocationARB(m_filters[passindex], "bgl_QuartedDepthTexture") != -1) + { + if(GLEW_ARB_depth_texture) + texflag[passindex] |= 0x8; + } if(m_gameObjects[passindex]) { @@ -241,6 +250,29 @@ void RAS_2DFilterManager::StartShaderProgram(int passindex) glUniform1iARB(uniformLoc, 2); } } + + /* Send the quartered render texture to glsl program if it needs */ + if(texflag[passindex] & 0x4){ + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_QuarteredRenderTexture"); + glActiveTextureARB(GL_TEXTURE3); + glBindTexture(GL_TEXTURE_2D, texname[3]); + + if (uniformLoc != -1) + { + glUniform1iARB(uniformLoc, 3); + } + } + + if(texflag[passindex] & 0x5){ + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_QuarteredDepthTexture"); + glActiveTextureARB(GL_TEXTURE4); + glBindTexture(GL_TEXTURE_2D, texname[4]); + + if (uniformLoc != -1) + { + glUniform1iARB(uniformLoc, 4); + } + } uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_TextureCoordinateOffset"); if (uniformLoc != -1) @@ -277,15 +309,24 @@ void RAS_2DFilterManager::EndShaderProgram() void RAS_2DFilterManager::FreeTextures() { - if(texname[0]!=(unsigned int)-1) + // Update this when adding new textures! + for (int i=0; i<5; i++) + { + if(texname[i]!=(unsigned int)-1) + glDeleteTextures(1, (GLuint*)&texname[i]); + } + + if(fbo != (unsigned int)-1) + glDeleteFramebuffersEXT(1, &fbo); + /*if(texname[0]!=(unsigned int)-1) glDeleteTextures(1, (GLuint*)&texname[0]); if(texname[1]!=(unsigned int)-1) glDeleteTextures(1, (GLuint*)&texname[1]); if(texname[2]!=(unsigned int)-1) - glDeleteTextures(1, (GLuint*)&texname[2]); + glDeleteTextures(1, (GLuint*)&texname[2]);*/ } -void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) +void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance, bool qrender, bool qdepth) { FreeTextures(); @@ -321,6 +362,25 @@ void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); } + + if(qrender){ + glGenTextures(1, (GLuint*)&texname[3]); + glBindTexture(GL_TEXTURE_2D, texname[3]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texturewidth/2, textureheight/2, 0, GL_RGBA8, + GL_UNSIGNED_BYTE, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + + glGenFramebuffersEXT(1, &fbo); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texname[3], 0); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } + } void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas) @@ -377,6 +437,8 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) { bool need_depth=false; bool need_luminance=false; + bool need_qrender=false; + bool need_qdepth=false; int num_filters = 0; int passindex; @@ -392,7 +454,11 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) need_depth = true; if(texflag[passindex] & 0x2) need_luminance = true; - if(need_depth && need_luminance) + if(texflag[passindex] & 0x4) + need_qrender = true; + if(texflag[passindex] & 0x8) + need_qdepth = true; + if(need_depth && need_luminance && need_qrender && need_qdepth) break; } } @@ -412,7 +478,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) if(need_tex_update) { - SetupTextures(need_depth, need_luminance); + SetupTextures(need_depth, need_luminance, need_qrender, need_qdepth); need_tex_update = false; } @@ -428,6 +494,12 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0, 0, texturewidth,textureheight, 0); } + if(need_qdepth){ + glActiveTextureARB(GL_TEXTURE4); + glBindTexture(GL_TEXTURE_2D, texname[4]); + glCopyTexImage2D(GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT, 0, 0, texturewidth, textureheight, 0); + } + glViewport(0,0, texturewidth, textureheight); glDisable(GL_DEPTH_TEST); @@ -448,6 +520,53 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glActiveTextureARB(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texname[0]); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, texturewidth, textureheight, 0); + //glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, im_buff); + + if(need_qrender){ + //glActiveTextureARB(GL_TEXTURE3); + //glBindTexture(GL_TEXTURE_2D, texname[3]); + //glReadPixels(0, 0, texturewidth, textureheight, GL_RGB, GL_UNSIGNED_BYTE, im_buff); + //gluScaleImage(GL_RGB, texturewidth, textureheight, GL_UNSIGNED_BYTE, im_buff, + // texturewidth/2, textureheight/2, GL_UNSIGNED_BYTE, scaled_buff); + //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texturewidth, textureheight, GL_RGBA, GL_UNSIGNED_BYTE, im_buff); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); + if(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT) { + glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT); + glViewport(0, 0, texturewidth/2, textureheight/2); + + /* glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + gluOrtho2D(0, texturewidth/2, 0, textureheight/2); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity();*/ + glClearColor(0, 0, 0, 1); + + glClear(GL_COLOR_BUFFER_BIT); + /*glBindTexture(GL_TEXTURE_2D, texname[0]); + glBegin(GL_QUADS); + glColor4f(0.f, 1.f, 1.f, 1.f); + glTexCoord2f(1.f, 1.f); glVertex2f(1,1); + glTexCoord2f(0.f, 1.f); glVertex2f(-1,1); + glTexCoord2f(0.f, 0.f); glVertex2f(-1,-1); + glTexCoord2f(1.f, 0.f); glVertex2f(1,-1); + glEnd();*/ + + glFlush(); + //glPopMatrix(); + //glMatrixMode(GL_PROJECTION); + //glPopMatrix(); + + glPopAttrib(); + } else { + printf("Could not use the framebuffer\n"); + } + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + + } + + glClearColor(1, 0, 1, 1); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_QUADS); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index 7ff7cde7882..2519473520a 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -45,7 +45,7 @@ private: void EndShaderProgram(); void PrintShaderErrors(unsigned int shader, const char *task, const char *code); - void SetupTextures(bool depth, bool luminance); + void SetupTextures(bool depth, bool luminance, bool qrender, bool qdepth); void FreeTextures(); void UpdateOffsetMatrix(RAS_ICanvas* canvas); @@ -54,13 +54,15 @@ private: float canvascoord[4]; float textureoffsets[18]; float view[4]; - /* texname[0] contains render to texture, texname[1] contains depth texture, texname[2] contains luminance texture*/ - unsigned int texname[3]; + /* texname[0] contains render to texture, texname[1] contains depth texture, texname[2] contains luminance texture + * texname[3] contains quartered render to texture, texname[4] contains quartered depth texture*/ + unsigned int texname[5]; int texturewidth; int textureheight; int canvaswidth; int canvasheight; int numberoffilters; + unsigned int fbo; /* bit 0: enable/disable depth texture * bit 1: enable/disable luminance texture*/ short texflag[MAX_RENDER_PASS]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 122a738e4f3..ec5f4c4ac6d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -297,6 +297,7 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time) m_last_frontface = true; glShadeModel(GL_SMOOTH); + glEnable(GL_MULTISAMPLE_ARB); m_2DCanvas->BeginFrame(); @@ -382,6 +383,7 @@ void RAS_OpenGLRasterizer::EndFrame() FlushDebugLines(); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glDisable(GL_MULTISAMPLE_ARB); m_2DCanvas->EndFrame(); } -- cgit v1.2.3