svn merge -r36603:36628 https://svn.blender.org/svnroot/bf-blender/trunk/blender
authorCampbell Barton <ideasman42@gmail.com>
Thu, 12 May 2011 05:35:19 +0000 (05:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 12 May 2011 05:35:19 +0000 (05:35 +0000)
38 files changed:
doc/doxygen/doxygen.source
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_SystemWin32.h
source/blender/CMakeLists.txt
source/blender/SConscript
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/intern/brush.c
source/blender/blenloader/BLO_runtime.h [moved from source/blender/readblenfile/test/test.c with 70% similarity]
source/blender/blenloader/CMakeLists.txt
source/blender/blenloader/SConscript
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/runtime.c [moved from source/blender/readblenfile/intern/BLO_readblenfile.c with 63% similarity]
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/physics_intern.h
source/blender/editors/physics/physics_ops.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/makesrna/intern/rna_sculpt_paint.c
source/blender/makesrna/intern/rna_smoke.c
source/blender/makesrna/intern/rna_space.c
source/blender/readblenfile/BLO_readblenfile.h [deleted file]
source/blender/readblenfile/CMakeLists.txt [deleted file]
source/blender/readblenfile/SConscript [deleted file]
source/blender/readblenfile/stub/BLO_readblenfileSTUB.c [deleted file]
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_operators.c
source/blenderplayer/CMakeLists.txt
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/CMakeLists.txt
source/gameengine/GamePlayer/ghost/CMakeLists.txt
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
source/gameengine/GamePlayer/ghost/SConscript

index ccdf3448f180c8c7f60eeb2004c42366dcd13f11..375234d26a3c53f531271cfd4fbaf19946d6a103 100644 (file)
  *   merged in docs.
  */
 
-/** \defgroup blo readblenfile
- *  \ingroup blender data
- */
-
 /** \defgroup quicktime quicktime
  *  \ingroup blender
 
index 455a166ece0926f72f962b7df25d43faefe65799..ee8ec9e801831c5d30411a92f6d457e99db78560 100644 (file)
@@ -42,7 +42,7 @@
 #include <iostream>
 
 #ifdef FREE_WINDOWS
-#  define _WIN32_WINNT 0x0500 /* GetConsoleWindow() for MinGW */
+#  define WINVER 0x0501 /* GetConsoleWindow() for MinGW */
 #endif
 
 #include "GHOST_SystemWin32.h"
index 2dad3a6f44d768e94c90c1e97ac1d74804bd7ffa..8faf9bef4d6909dab65053c95beb9d94cca3b7ef 100644 (file)
@@ -127,8 +127,6 @@ DECLARE_HANDLE(HRAWINPUT);
 #ifdef FREE_WINDOWS
 #define NEED_RAW_PROC
 typedef BOOL (WINAPI * LPFNDLLRRID)(RAWINPUTDEVICE*,UINT, UINT);
-#define RegisterRawInputDevices(pRawInputDevices, uiNumDevices, cbSize) ((pRegisterRawInputDevices)?pRegisterRawInputDevices(pRawInputDevices, uiNumDevices, cbSize):0)
-
 
 typedef UINT (WINAPI * LPFNDLLGRID)(HRAWINPUT, UINT, LPVOID, PUINT, UINT);
 #define GetRawInputData(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader) ((pGetRawInputData)?pGetRawInputData(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader):(UINT)-1)
index 995b5fe725560e310b8eb19ba10484cd20b7958c..899eef2b3127eb363e91e9163b2c2a171e761dc1 100644 (file)
@@ -92,7 +92,6 @@ add_subdirectory(bmesh)
 add_subdirectory(render)
 add_subdirectory(blenfont)
 add_subdirectory(blenloader)
-add_subdirectory(readblenfile)
 add_subdirectory(blenpluginapi)
 add_subdirectory(ikplugin)
 add_subdirectory(gpu)
index 24514f1660c152626c3544432af890a92b959059..e6cd6b09c2084a8a9f7aa6f36cb074f42b75f80f 100644 (file)
@@ -13,7 +13,6 @@ SConscript(['avi/SConscript',
             'imbuf/SConscript',
             'makesdna/SConscript',
             'makesrna/SConscript',
-            'readblenfile/SConscript',
             'render/SConscript',
             'nodes/SConscript',
             'modifiers/SConscript',
index a9d379e6c694ec8d559f0ca6a634e7944987b85b..ad736cd07bf47c81a79623bd5597ac89f9d6b9da 100644 (file)
@@ -90,8 +90,7 @@ void brush_painter_free(BrushPainter *painter);
 unsigned int *brush_gen_texture_cache(struct Brush *br, int half_side);
 
 /* radial control */
-void brush_radial_control_invoke(struct wmOperator *op, struct Brush *br, float size_weight);
-int brush_radial_control_exec(struct wmOperator *op, struct Brush *br, float size_weight);
+struct ImBuf *brush_gen_radial_control_imbuf(struct Brush *br);
 
 /* unified strength and size */
 
index fa3b756ae27980eb6e98cb5d0b02a1919c468a56..98c540f53b72ff1680b4d03b40c715c8bbf32362 100644 (file)
@@ -426,13 +426,6 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset)
        curvemapping_changed(b->curve, 0);
 }
 
-static MTex *brush_active_texture(Brush *brush)
-{
-       if(brush)
-               return &brush->mtex;
-       return NULL;
-}
-
 int brush_texture_set_nr(Brush *brush, int nr)
 {
        ID *idtest, *id=NULL;
@@ -1185,7 +1178,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side)
 }
 
 /**** Radial Control ****/
-static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
+struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
 {
        ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture");
        unsigned int *texcache;
@@ -1219,50 +1212,6 @@ static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
        return im;
 }
 
-void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight)
-{
-       int mode = RNA_enum_get(op->ptr, "mode");
-       float original_value= 0;
-
-       if(mode == WM_RADIALCONTROL_SIZE)
-               original_value = brush_size(br) * size_weight;
-       else if(mode == WM_RADIALCONTROL_STRENGTH)
-               original_value = brush_alpha(br);
-       else if(mode == WM_RADIALCONTROL_ANGLE) {
-               MTex *mtex = brush_active_texture(br);
-               if(mtex)
-                       original_value = mtex->rot;
-       }
-
-       RNA_float_set(op->ptr, "initial_value", original_value);
-       op->customdata = brush_gen_radial_control_imbuf(br);
-}
-
-int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight)
-{
-       int mode = RNA_enum_get(op->ptr, "mode");
-       float new_value = RNA_float_get(op->ptr, "new_value");
-       const float conv = 0.017453293;
-
-       if(mode == WM_RADIALCONTROL_SIZE)
-               if (brush_use_locked_size(br)) {
-                       float initial_value = RNA_float_get(op->ptr, "initial_value");
-                       const float unprojected_radius = brush_unprojected_radius(br);
-                       brush_set_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight);
-               }
-               else
-                       brush_set_size(br, new_value * size_weight);
-       else if(mode == WM_RADIALCONTROL_STRENGTH)
-               brush_set_alpha(br, new_value);
-       else if(mode == WM_RADIALCONTROL_ANGLE) {
-               MTex *mtex = brush_active_texture(br);
-               if(mtex)
-                       mtex->rot = new_value * conv;
-       }
-
-       return OPERATOR_FINISHED;
-}
-
 /* Unified Size and Strength */
 
 static void set_unified_settings(Brush *brush, short flag, int value)
similarity index 70%
rename from source/blender/readblenfile/test/test.c
rename to source/blender/blenloader/BLO_runtime.h
index 647df053c389a0eafa95bd509ef616a2a314e17d..920b14e92fa70bab393d64320dcab5544221290f 100644 (file)
  * Contributor(s): none yet.
  *
  * ***** END GPL LICENSE BLOCK *****
+ * 
+ */
+
+#ifndef BLO_RUNTIME_H
+#define BLO_RUNTIME_H
+
+/** \file BLO_runtime.h
+ *  \ingroup blenloader
  */
-#include <string.h>    // strlen
-#include "BLO_readblenfile.h"
-
-struct streamGlueControlStruct *Global_streamGlueControl;
-
-               int
-streamGlueWrite(
-               struct streamGlueControlStruct *streamGlueControl,
-               struct streamGlueStruct **streamGlue,
-               unsigned char *data,
-               unsigned int dataIn,
-               int finishUp)
-{
-       printf("called with %d bytes in buffer [%s]\n", dataIn, data);
-       return (0);
-}
 
-main()
-{
-       int err;
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-       err = BLO_readblenfile();
+struct BlendFileData;
+struct ReportList;
+
+int BLO_is_a_runtime(char *file);
+struct BlendFileData *BLO_read_runtime(char *file, struct ReportList *reports);
+
+#ifdef __cplusplus
 }
+#endif
+
+#endif /* BLO_RUNTIME_H */
+
index 4d8ac9bc4b648a3b8a1d97be64a02b291bb07cc6..888cf3148e3b1a3b57a71f8b494ef8a16f4ff4ca 100644 (file)
@@ -29,7 +29,6 @@ set(INC
        ../blenlib
        ../blenkernel
        ../makesdna
-       ../readblenfile
        ../makesrna
        ../render/extern/include
        ../../../intern/guardedalloc
@@ -39,10 +38,12 @@ set(INC
 set(SRC
        intern/readblenentry.c
        intern/readfile.c
+       intern/runtime.c
        intern/undofile.c
        intern/writefile.c
 
        BLO_readfile.h
+       BLO_runtime.h
        BLO_soundfile.h
        BLO_sys_types.h
        BLO_undofile.h
index b3cb98abb9bfdf709985d4303fc4fb216b3fcf8d..f00f765bba431bdc1444cba838b4959ba8a17693 100644 (file)
@@ -4,7 +4,7 @@ Import ('env')
 sources = env.Glob('intern/*.c')
 
 incs = '. #/intern/guardedalloc ../blenlib ../blenkernel'
-incs += ' ../makesdna ../readblenfile ../editors/include'
+incs += ' ../makesdna ../editors/include'
 incs += ' ../render/extern/include ../makesrna ../bmesh'
 
 incs += ' ' + env['BF_ZLIB_INC']
index 39fab1929da6b8eb7fc3206ff1aaa929c10dcba0..214f637ea6c8ed9b9afa3b92f02dfa8b7cc8a317 100644 (file)
@@ -62,8 +62,6 @@
 
 #include "readfile.h"
 
-#include "BLO_readblenfile.h"
-
 #include "BLO_sys_types.h" // needed for intptr_t
 
 #ifdef _WIN32
index ddbbf64241f5b7acc0e24a03460e39b6deecb6d5..fb4d99b95bcb4805d200c05d18cf7ec3f4f630e4 100644 (file)
 //XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo
 #include "BLO_readfile.h"
 #include "BLO_undofile.h"
-#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
 
 #include "readfile.h"
 
similarity index 63%
rename from source/blender/readblenfile/intern/BLO_readblenfile.c
rename to source/blender/blenloader/intern/runtime.c
index 351de4bd2153a16f7905b959a1dfd90d72397c1b..f5308b5ea5c6c4b1d67d37cd1fb6b1e3eed733b4 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  *
  */
+
 /**
- * \file BLO_readblenfile.c
- * \brief This file handles the loading if .blend files
- * \ingroup blo
+ * \file runtime.c
+ * \brief This file handles the loading of .blend files embedded in runtimes
+ * \ingroup blenloader
  */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #endif
 
 #include "BLO_readfile.h"
-#include "BLO_readblenfile.h"
+#include "BLO_runtime.h"
 
 #include "BKE_blender.h"
 #include "BKE_report.h"
+#include "BKE_utildefines.h"
 
 #include "BLI_blenlib.h"
 
-/** Magic number for the file header */
-const char *headerMagic = "BLENDFI";
-
-/**
- * \brief Set the version number into the array.
- *
- * version contains the integer number of the version
- * i.e. 227
- * array[1] gets set to the div of the number by 100 i.e. 2
- * array[2] gets the remainder i.e. 27
- */
-void BLO_setversionnumber(char array[4], int version)
-{
-       memset(array, 0, sizeof(char)*4);
-
-       array[1] = version / 100;
-       array[2] = version % 100;
-}
-
-/**
- * Sets version number using BLENDER_VERSION
- * Function that calls the setversionnumber(char[],int) with 
- * the BLENDER_VERSION constant and sets the resultant array
- * with the version parts.  
- * see BLO_setversionnumber(char[],int).
- */
-void BLO_setcurrentversionnumber(char array[4])
-{
-       BLO_setversionnumber(array, BLENDER_VERSION);
-}
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
 /* Runtime reading */
 
-static int handle_read_msb_int(int handle) {
+static int handle_read_msb_int(int handle)
+{
        unsigned char buf[4];
 
-       if (read(handle, buf, 4)!=4)
+       if(read(handle, buf, 4) != 4)
                return -1;
-       else
-               return (buf[0]<<24) + (buf[1]<<16) + (buf[2]<<8) + (buf[3]<<0);
+
+       return (buf[0]<<24) + (buf[1]<<16) + (buf[2]<<8) + (buf[3]<<0);
 }
 
-int blo_is_a_runtime(char *path) {
+int BLO_is_a_runtime(char *path)
+{
        int res= 0, fd= open(path, O_BINARY|O_RDONLY, 0);
        int datastart;
        char buf[8];
 
-       if (fd==-1)
+       if(fd==-1)
                goto cleanup;
        
        lseek(fd, -12, SEEK_END);
        
        datastart= handle_read_msb_int(fd);
-       if (datastart==-1)
+
+       if(datastart==-1)
                goto cleanup;
-       else if (read(fd, buf, 8)!=8)
+       else if(read(fd, buf, 8)!=8)
                goto cleanup;
-       else if (memcmp(buf, "BRUNTIME", 8)!=0)
+       else if(memcmp(buf, "BRUNTIME", 8)!=0)
                goto cleanup;
        else
                res= 1;
 
 cleanup:
-       if (fd!=-1)
+       if(fd!=-1)
                close(fd);
 
        return res;     
 }
 
-BlendFileData *
-blo_read_runtime(
-       char *path, 
-       ReportList *reports)
+BlendFileData *BLO_read_runtime(char *path, ReportList *reports)
 {
        BlendFileData *bfd= NULL;
        size_t actualsize;
@@ -137,7 +105,8 @@ blo_read_runtime(
        char buf[8];
 
        fd= open(path, O_BINARY|O_RDONLY, 0);
-       if (fd==-1) {
+
+       if(fd==-1) {
                BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", path, strerror(errno));
                goto cleanup;
        }
@@ -147,16 +116,20 @@ blo_read_runtime(
        lseek(fd, -12, SEEK_END);
 
        datastart= handle_read_msb_int(fd);
-       if (datastart==-1) {
+
+       if(datastart==-1) {
                BKE_reportf(reports, RPT_ERROR, "Unable to read  \"%s\" (problem seeking)", path);
                goto cleanup;
-       } else if (read(fd, buf, 8)!=8) {
+       }
+       else if(read(fd, buf, 8)!=8) {
                BKE_reportf(reports, RPT_ERROR, "Unable to read  \"%s\" (truncated header)", path);
                goto cleanup;
-       } else if (memcmp(buf, "BRUNTIME", 8)!=0) {
+       }
+       else if(memcmp(buf, "BRUNTIME", 8)!=0) {
                BKE_reportf(reports, RPT_ERROR, "Unable to read  \"%s\" (not a blend file)", path);
                goto cleanup;
-       } else {        
+       }
+       else {  
                //printf("starting to read runtime from %s at datastart %d\n", path, datastart);
                lseek(fd, datastart, SEEK_SET);
                bfd = blo_read_blendafterruntime(fd, path, actualsize-datastart, reports);
@@ -164,7 +137,7 @@ blo_read_runtime(
        }
        
 cleanup:
-       if (fd!=-1)
+       if(fd!=-1)
                close(fd);
        
        return bfd;
index 1d235f83186ac37fd70df7d72cae12f3e7387839..ee39e0fff2698ebe08b4c93a9362f49873828c14 100644 (file)
@@ -2521,80 +2521,6 @@ static void toggle_particle_cursor(bContext *C, int enable)
                pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_view3d, brush_drawcursor, NULL);
 }
 
-/********************* radial control operator *********************/
-
-static int brush_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       ParticleEditSettings *pset= PE_settings(CTX_data_scene(C));
-       ParticleBrushData *brush;
-       int mode = RNA_enum_get(op->ptr, "mode");
-       float original_value=1.0f;
-
-       if(pset->brushtype < 0)
-               return OPERATOR_CANCELLED;
-
-       brush= &pset->brush[pset->brushtype];
-
-       toggle_particle_cursor(C, 0);
-
-       if(mode == WM_RADIALCONTROL_SIZE)
-               original_value = brush->size;
-       else if(mode == WM_RADIALCONTROL_STRENGTH)
-               original_value = brush->strength;
-
-       RNA_float_set(op->ptr, "initial_value", original_value);
-
-       return WM_radial_control_invoke(C, op, event);
-}
-
-static int brush_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
-{
-       int ret = WM_radial_control_modal(C, op, event);
-
-       if(ret != OPERATOR_RUNNING_MODAL)
-               toggle_particle_cursor(C, 1);
-
-       return ret;
-}
-
-static int brush_radial_control_exec(bContext *C, wmOperator *op)
-{
-       ParticleEditSettings *pset= PE_settings(CTX_data_scene(C));
-       ParticleBrushData *brush;
-       int mode = RNA_enum_get(op->ptr, "mode");
-       float new_value = RNA_float_get(op->ptr, "new_value");
-
-       if(pset->brushtype < 0)
-               return OPERATOR_CANCELLED;
-
-       brush= &pset->brush[pset->brushtype];
-
-       if(mode == WM_RADIALCONTROL_SIZE)
-               brush->size= new_value;
-       else if(mode == WM_RADIALCONTROL_STRENGTH)
-               brush->strength= new_value;
-
-       WM_event_add_notifier(C, NC_WINDOW, NULL);
-
-       return OPERATOR_FINISHED;
-}
-
-void PARTICLE_OT_brush_radial_control(wmOperatorType *ot)
-{
-       WM_OT_radial_control_partial(ot);
-
-       ot->name= "Brush Radial Control";
-       ot->idname= "PARTICLE_OT_brush_radial_control";
-
-       ot->invoke= brush_radial_control_invoke;
-       ot->modal= brush_radial_control_modal;
-       ot->exec= brush_radial_control_exec;
-       ot->poll= PE_poll;
-       
-       /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
-}
-
 /*************************** delete operator **************************/
 
 enum { DEL_PARTICLE, DEL_KEY };
index d447da3f8c4af513e1fbdd6b29e5fa4f06dd5cd0..71f1128baf0a1669fdb8942a0c7b35c39702a5aa 100644 (file)
@@ -60,7 +60,6 @@ void PARTICLE_OT_delete(struct wmOperatorType *ot);
 void PARTICLE_OT_mirror(struct wmOperatorType *ot);
 
 void PARTICLE_OT_brush_edit(struct wmOperatorType *ot);
-void PARTICLE_OT_brush_radial_control(struct wmOperatorType *ot);
 
 void PARTICLE_OT_particle_edit_toggle(struct wmOperatorType *ot);
 void PARTICLE_OT_edited_clear(struct wmOperatorType *ot);
index 02b2fad7a00cd7e5600e9dad7d3269d818315e68..aafa5a185edb0a37886ad221ca908189ddcaeb34 100644 (file)
@@ -66,7 +66,6 @@ static void operatortypes_particle(void)
        WM_operatortype_append(PARTICLE_OT_mirror);
 
        WM_operatortype_append(PARTICLE_OT_brush_edit);
-       WM_operatortype_append(PARTICLE_OT_brush_radial_control);
 
        WM_operatortype_append(PARTICLE_OT_particle_edit_toggle);
        WM_operatortype_append(PARTICLE_OT_edited_clear);
@@ -91,6 +90,7 @@ static void operatortypes_particle(void)
 
 static void keymap_particle(wmKeyConfig *keyconf)
 {
+       wmKeyMapItem *kmi;
        wmKeyMap *keymap;
        
        keymap= WM_keymap_find(keyconf, "Particle", 0, 0);
@@ -112,8 +112,14 @@ static void keymap_particle(wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
-       RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
-       RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+
+       /* size radial control */
+       kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
+       RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.size");
+
+       /* size radial control */
+       kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
+       RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.strength");
 
        WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0);
        
index 717d77e65b8d921116fa2b585365e43619c32fa5..2b8f4e6f3081d872261a213d49830d60f48009d1 100644 (file)
@@ -5092,56 +5092,6 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
        }
 }
 
-/* ************ image paint radial control *************/
-static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       float zoom;
-       ToolSettings *ts = CTX_data_scene(C)->toolsettings;
-       get_imapaint_zoom(C, &zoom, &zoom);
-       toggle_paint_cursor(C, 0);
-       brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), zoom);
-       return WM_radial_control_invoke(C, op, event);
-}
-
-static int paint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
-{
-       int ret = WM_radial_control_modal(C, op, event);
-       if(ret != OPERATOR_RUNNING_MODAL)
-               toggle_paint_cursor(C, 1);
-       return ret;
-}
-
-static int paint_radial_control_exec(bContext *C, wmOperator *op)
-{
-       Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint);
-       float zoom;
-       int ret;
-       char str[64];
-       get_imapaint_zoom(C, &zoom, &zoom);
-       ret = brush_radial_control_exec(op, brush, 1.0f / zoom);
-       WM_radial_control_string(op, str, sizeof(str));
-       
-       WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
-
-       return ret;
-}
-
-void PAINT_OT_image_paint_radial_control(wmOperatorType *ot)
-{
-       WM_OT_radial_control_partial(ot);
-
-       ot->name= "Image Paint Radial Control";
-       ot->idname= "PAINT_OT_image_paint_radial_control";
-
-       ot->invoke= paint_radial_control_invoke;
-       ot->modal= paint_radial_control_modal;
-       ot->exec= paint_radial_control_exec;
-       ot->poll= image_paint_poll;
-       
-       /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
-}
-
 /************************ grab clone operator ************************/
 
 typedef struct GrabClone {
@@ -5469,28 +5419,6 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-/************* texture paint radial control *************/
-
-static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       ToolSettings *ts = CTX_data_scene(C)->toolsettings;
-       toggle_paint_cursor(C, !ts->imapaint.paintcursor);
-       brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 1);
-       return WM_radial_control_invoke(C, op, event);
-}
-
-static int texture_paint_radial_control_exec(bContext *C, wmOperator *op)
-{
-       Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint);
-       int ret = brush_radial_control_exec(op, brush, 1);
-       char str[64];
-       WM_radial_control_string(op, str, sizeof(str));
-
-       WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
-
-       return ret;
-}
-
 static int texture_paint_poll(bContext *C)
 {
        if(texture_paint_toggle_poll(C))
@@ -5505,23 +5433,6 @@ int image_texture_paint_poll(bContext *C)
        return (texture_paint_poll(C) || image_paint_poll(C));
 }
 
-void PAINT_OT_texture_paint_radial_control(wmOperatorType *ot)
-{
-       WM_OT_radial_control_partial(ot);
-
-       ot->name= "Texture Paint Radial Control";
-       ot->idname= "PAINT_OT_texture_paint_radial_control";
-
-       ot->invoke= texture_paint_radial_control_invoke;
-       ot->modal= paint_radial_control_modal;
-       ot->exec= texture_paint_radial_control_exec;
-       ot->poll= texture_paint_poll;
-       
-       /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
-}
-
-
 int facemask_paint_poll(bContext *C)
 {
        return paint_facesel_test(CTX_data_active_object(C));
index 48fca04ac874033dedde2f4ecc8e73e20e66a060..ba7235a3161b1841ad4cd4a158364ed8980b3358 100644 (file)
@@ -81,12 +81,10 @@ void vpaint_fill(struct Object *ob, unsigned int paintcol);
 void wpaint_fill(struct VPaint *wp, struct Object *ob, float paintweight);
 
 void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot);
-void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot);
 void PAINT_OT_weight_paint(struct wmOperatorType *ot);
 void PAINT_OT_weight_set(struct wmOperatorType *ot);
 void PAINT_OT_weight_from_bones(struct wmOperatorType *ot);
 
-void PAINT_OT_vertex_paint_radial_control(struct wmOperatorType *ot);
 void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot);
 void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
 
@@ -96,12 +94,10 @@ unsigned int vpaint_get_current_col(struct VPaint *vp);
 int image_texture_paint_poll(struct bContext *C);
 
 void PAINT_OT_image_paint(struct wmOperatorType *ot);
-void PAINT_OT_image_paint_radial_control(struct wmOperatorType *ot);
 void PAINT_OT_grab_clone(struct wmOperatorType *ot);
 void PAINT_OT_sample_color(struct wmOperatorType *ot);
 void PAINT_OT_clone_cursor_set(struct wmOperatorType *ot);
 void PAINT_OT_texture_paint_toggle(struct wmOperatorType *ot);
-void PAINT_OT_texture_paint_radial_control(struct wmOperatorType *ot);
 void PAINT_OT_project_image(struct wmOperatorType *ot);
 void PAINT_OT_image_from_view(struct wmOperatorType *ot);
 
index 9a1de939067b2ff42be25f1f28fc320e2421b27d..e4a21b1f1a7e0eedc5b0964a28088d2607c27127 100644 (file)
  *  \ingroup edsculpt
  */
 
+#include "MEM_guardedalloc.h"
 
+#include <stdlib.h>
+#include "BLI_string.h"
 #include "BLI_utildefines.h"
 
 #include "DNA_object_types.h"
@@ -355,9 +358,7 @@ void ED_operatortypes_paint(void)
 
        /* image */
        WM_operatortype_append(PAINT_OT_texture_paint_toggle);
-       WM_operatortype_append(PAINT_OT_texture_paint_radial_control);
        WM_operatortype_append(PAINT_OT_image_paint);
-       WM_operatortype_append(PAINT_OT_image_paint_radial_control);
        WM_operatortype_append(PAINT_OT_sample_color);
        WM_operatortype_append(PAINT_OT_grab_clone);
        WM_operatortype_append(PAINT_OT_clone_cursor_set);
@@ -366,13 +367,11 @@ void ED_operatortypes_paint(void)
 
        /* weight */
        WM_operatortype_append(PAINT_OT_weight_paint_toggle);
-       WM_operatortype_append(PAINT_OT_weight_paint_radial_control);
        WM_operatortype_append(PAINT_OT_weight_paint);
        WM_operatortype_append(PAINT_OT_weight_set);
        WM_operatortype_append(PAINT_OT_weight_from_bones);
 
        /* vertex */
-       WM_operatortype_append(PAINT_OT_vertex_paint_radial_control);
        WM_operatortype_append(PAINT_OT_vertex_paint_toggle);
        WM_operatortype_append(PAINT_OT_vertex_paint);
        WM_operatortype_append(PAINT_OT_vertex_color_set);
@@ -464,6 +463,59 @@ static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path
        RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111....
 }
 
+typedef enum {
+       RC_COLOR = 1,
+       RC_ROTATION = 2,
+       RC_ZOOM = 4,
+} RCFlags;
+
+static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
+                             const char *output_name, const char *input_name)
+{
+       char *path;
+
+       path = BLI_sprintfN("%s.%s", brush_path, input_name);
+       RNA_string_set(ptr, output_name, path);
+       MEM_freeN(path);
+}
+
+static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
+                              const char *prop, RCFlags flags)
+{
+       char *brush_path;
+
+       brush_path = BLI_sprintfN("tool_settings.%s.brush", paint);
+
+       set_brush_rc_path(ptr, brush_path, "data_path", prop);
+       set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add");
+       set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle");
+       RNA_string_set(ptr, "image_id", brush_path);
+
+       if(flags & RC_COLOR)
+               set_brush_rc_path(ptr, brush_path, "fill_color_path", "color");
+       if(flags & RC_ZOOM)
+               RNA_string_set(ptr, "zoom_path", "space_data.zoom");
+
+       MEM_freeN(brush_path);
+}
+
+static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint,
+                                                RCFlags flags)
+{
+       wmKeyMapItem *kmi;
+
+       kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
+       set_brush_rc_props(kmi->ptr, paint, "size", flags);
+
+       kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
+       set_brush_rc_props(kmi->ptr, paint, "strength", flags);
+
+       if(flags & RC_ROTATION) {
+               kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0);
+               set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", flags);
+       }
+}
+
 void ED_keymap_paint(wmKeyConfig *keyconf)
 {
        wmKeyMap *keymap;
@@ -474,10 +526,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0);
        keymap->poll= sculpt_poll;
 
-       RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr,        "mode", WM_RADIALCONTROL_SIZE);
-       RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
-       RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr,  "mode", WM_RADIALCONTROL_ANGLE);
-
        RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0,        0)->ptr, "mode", BRUSH_STROKE_NORMAL);
        RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL,  0)->ptr, "mode", BRUSH_STROKE_INVERT);
        RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH);
@@ -496,6 +544,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
 
        ed_keymap_paint_brush_switch(keymap, "sculpt");
        ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size");
+       ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION);
 
        RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", DKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_DRAW);
        RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", SKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_SMOOTH);
@@ -521,8 +570,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0);
        keymap->poll= vertex_paint_mode_poll;
 
-       RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
-       RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
        WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
 
@@ -531,6 +578,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
 
        ed_keymap_paint_brush_switch(keymap, "vertex_paint");
        ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size");
+       ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR);
 
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
        RNA_string_set(kmi->ptr, "data_path", "vertex_paint_object.data.use_paint_mask");
@@ -539,9 +587,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0);
        keymap->poll= weight_paint_mode_poll;
 
-       RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
-       RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
-
        WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0);
 
        WM_keymap_add_item(keymap,
@@ -549,6 +594,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
 
        ed_keymap_paint_brush_switch(keymap, "weight_paint");
        ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size");
+       ed_keymap_paint_brush_radial_control(keymap, "weight_paint", 0);
 
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
        RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask");
@@ -559,12 +605,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0);
        keymap->poll= image_texture_paint_poll;
 
-       RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
-       RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
-
-       RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
-       RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
-
        WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
@@ -572,6 +612,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
 
        ed_keymap_paint_brush_switch(keymap, "image_paint");
        ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size");
+       ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR|RC_ZOOM);
 
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
        RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask");
index 4f77ecf828742bdd2831fcfb30763276ddf7a8c4..cc3ee805a8b938db3b46cfbedece7a966cf1d2c8 100644 (file)
@@ -1205,110 +1205,6 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
        
 }
 
-/* ************ paint radial controls *************/
-
-static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       Paint *p = paint_get_active(CTX_data_scene(C));
-       Brush *brush = paint_brush(p);
-       float col[4];
-       
-       WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor);
-       p->paint_cursor = NULL;
-       brush_radial_control_invoke(op, brush, 1);
-
-       copy_v3_v3(col, brush->add_col);
-       col[3]= 0.5f;
-       RNA_float_set_array(op->ptr, "color", col);
-
-       return WM_radial_control_invoke(C, op, event);
-}
-
-static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
-{
-       int ret = WM_radial_control_modal(C, op, event);
-       if(ret != OPERATOR_RUNNING_MODAL)
-               paint_cursor_start(C, vertex_paint_poll);
-       return ret;
-}
-
-static int vpaint_radial_control_exec(bContext *C, wmOperator *op)
-{
-       Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint);
-       int ret = brush_radial_control_exec(op, brush, 1);
-       
-       WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
-       
-       return ret;
-}
-
-static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       Paint *p = paint_get_active(CTX_data_scene(C));
-       Brush *brush = paint_brush(p);
-       float col[4];
-       
-       WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor);
-       p->paint_cursor = NULL;
-       brush_radial_control_invoke(op, brush, 1);
-
-       copy_v3_v3(col, brush->add_col);
-       col[3]= 0.5f;
-       RNA_float_set_array(op->ptr, "color", col);
-
-       return WM_radial_control_invoke(C, op, event);
-}
-
-static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
-{
-       int ret = WM_radial_control_modal(C, op, event);
-       if(ret != OPERATOR_RUNNING_MODAL)
-               paint_cursor_start(C, weight_paint_poll);
-       return ret;
-}
-
-static int wpaint_radial_control_exec(bContext *C, wmOperator *op)
-{
-       Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint);
-       int ret = brush_radial_control_exec(op, brush, 1);
-       
-       WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
-       
-       return ret;
-}
-
-void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot)
-{
-       WM_OT_radial_control_partial(ot);
-
-       ot->name= "Weight Paint Radial Control";
-       ot->idname= "PAINT_OT_weight_paint_radial_control";
-
-       ot->invoke= wpaint_radial_control_invoke;
-       ot->modal= wpaint_radial_control_modal;
-       ot->exec= wpaint_radial_control_exec;
-       ot->poll= weight_paint_poll;
-       
-       /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
-}
-
-void PAINT_OT_vertex_paint_radial_control(wmOperatorType *ot)
-{
-       WM_OT_radial_control_partial(ot);
-
-       ot->name= "Vertex Paint Radial Control";
-       ot->idname= "PAINT_OT_vertex_paint_radial_control";
-
-       ot->invoke= vpaint_radial_control_invoke;
-       ot->modal= vpaint_radial_control_modal;
-       ot->exec= vpaint_radial_control_exec;
-       ot->poll= vertex_paint_poll;
-       
-       /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
-}
-
 /* ************ weight paint operator ********** */
 
 struct WPaintData {
index c8f63e871b4049861449c4eef898d7b16eacdd2b..0f514ff4e8f629f60eefb2fffa47730057fa8554 100644 (file)
@@ -2837,65 +2837,6 @@ static const char *sculpt_tool_name(Sculpt *sd)
        }
 }
 
-/**** Radial control ****/
-static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       Paint *p = paint_get_active(CTX_data_scene(C));
-       Brush *brush = paint_brush(p);
-       float col[4], tex_col[4];
-
-       WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor);
-       p->paint_cursor = NULL;
-       brush_radial_control_invoke(op, brush, 1);
-
-       if((brush->flag & BRUSH_DIR_IN) && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH))
-               copy_v3_v3(col, brush->sub_col);
-       else
-               copy_v3_v3(col, brush->add_col);
-       col[3]= 0.5f;
-                                                                           
-       copy_v3_v3(tex_col, U.sculpt_paint_overlay_col);
-       tex_col[3]= (brush->texture_overlay_alpha / 100.0f);
-
-       RNA_float_set_array(op->ptr, "color", col);
-       RNA_float_set_array(op->ptr, "texture_color", tex_col);
-
-       return WM_radial_control_invoke(C, op, event);
-}
-
-static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
-{
-       int ret = WM_radial_control_modal(C, op, event);
-       if(ret != OPERATOR_RUNNING_MODAL)
-               paint_cursor_start(C, sculpt_poll);
-       return ret;
-}
-
-static int sculpt_radial_control_exec(bContext *C, wmOperator *op)
-{
-       Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint);
-       int ret = brush_radial_control_exec(op, brush, 1);
-
-       WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
-
-       return ret;
-}
-
-static void SCULPT_OT_radial_control(wmOperatorType *ot)
-{
-       WM_OT_radial_control_partial(ot);
-
-       ot->name= "Sculpt Radial Control";
-       ot->idname= "SCULPT_OT_radial_control";
-
-       ot->invoke= sculpt_radial_control_invoke;
-       ot->modal= sculpt_radial_control_modal;
-       ot->exec= sculpt_radial_control_exec;
-       ot->poll= sculpt_poll;
-
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
-}
-
 /**** Operator for applying a stroke (various attributes including mouse path)
          using the current brush. ****/
 
@@ -3784,7 +3725,6 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
 
 void ED_operatortypes_sculpt(void)
 {
-       WM_operatortype_append(SCULPT_OT_radial_control);
        WM_operatortype_append(SCULPT_OT_brush_stroke);
        WM_operatortype_append(SCULPT_OT_sculptmode_toggle);
        WM_operatortype_append(SCULPT_OT_set_persistent_base);
index fe0b0b7c928d2a3fd0c87a438a544e4a55b58c43..66f5ac18fbf31e9d5db8397303ccdad69ce74979 100644 (file)
@@ -998,10 +998,14 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
        y2= viewborder.ymax;
        
        /* apply offsets so the real 3D camera shows through */
-       x1i= (int)(x1 - 1.0f);
-       y1i= (int)(y1 - 1.0f);
-       x2i= (int)(x2 + 1.0f);
-       y2i= (int)(y2 + 1.0f);
+
+       /* note: quite un-scientific but without this bit extra
+        * 0.0001 on the lower left the 2D border sometimes
+        * obscures the 3D camera border */
+       x1i= (int)(x1 - 1.0001f);
+       y1i= (int)(y1 - 1.0001f);
+       x2i= (int)(x2 + (1.0f-0.0001f));
+       y2i= (int)(y2 + (1.0f-0.0001f));
        
        /* passepartout, specified in camera edit buttons */
        if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) {
index 769f0ad17db3f145a1c913ec251480c173d5d5ce..623a0fc1038cc189fdd5431554ecd2c865cd1fbb 100644 (file)
@@ -317,10 +317,4 @@ typedef struct wmOperator {
 /* wmOperator flag */
 #define OP_GRAB_POINTER                        1
 
-typedef enum wmRadialControlMode {
-       WM_RADIALCONTROL_SIZE,
-       WM_RADIALCONTROL_STRENGTH,
-       WM_RADIALCONTROL_ANGLE
-} wmRadialControlMode;
-
 #endif /* DNA_WINDOWMANAGER_TYPES_H */
index ce018fdfd6ef7fd8e90618c8a9af5c858d6a5426..da536f95cbae3a39660fc2192852dbb56200b5e5 100644 (file)
@@ -481,12 +481,12 @@ static void rna_def_particle_edit(BlenderRNA *brna)
        RNA_def_struct_sdna(srna, "ParticleBrushData");
        RNA_def_struct_ui_text(srna, "Particle Brush", "Particle editing brush");
 
-       prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
+       prop= RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE);
        RNA_def_property_range(prop, 1, SHRT_MAX);
        RNA_def_property_ui_range(prop, 1, 100, 10, 3);
        RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
 
-       prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
+       prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
        RNA_def_property_range(prop, 0.001, 1.0);
        RNA_def_property_ui_text(prop, "Strength", "Brush strength");
 
index 922c68f45bd76ec25c6077201a781751193d4eb1..974f2fdecb8ddfbe0b105a95b0340285b9f54f79 100644 (file)
@@ -212,7 +212,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
        RNA_def_property_float_sdna(prop, NULL, "strength");
        RNA_def_property_range(prop, 0.0, 10.0);
        RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2);
-       RNA_def_property_ui_text(prop, "Strength", "Strength of wavelet noise");
+       RNA_def_property_ui_text(prop, "Strength", "Strength of noise");
        RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset");
 
        prop= RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE);
index 59824d6a7527d25bb5b9e4fd1df39447c4cc3fa8..5281e152d543a2873d19112fc05fe60dc137e255 100644 (file)
@@ -508,6 +508,27 @@ static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, P
        return item;
 }
 
+static void rna_SpaceImageEditor_zoom_get(PointerRNA *ptr, float *values)
+{
+       SpaceImage *sima= (SpaceImage*)ptr->data;
+       ScrArea *sa;
+       ARegion *ar;
+
+       values[0] = values[1] = 1;
+
+       sa = rna_area_from_space(ptr);
+       if(!sa) return;
+       
+       /* find aregion */
+       for(ar=sa->regionbase.first; ar; ar=ar->next) {
+               if(ar->regiontype == RGN_TYPE_WINDOW)
+                       break;
+       }
+       if(!ar) return;
+
+       ED_space_image_zoom(sima, ar, &values[0], &values[1]);
+}
+
 static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *values)
 {
        SpaceImage *sima= (SpaceImage*)ptr->data;
@@ -1556,6 +1577,12 @@ static void rna_def_space_image(BlenderRNA *brna)
        RNA_def_property_pointer_sdna(prop, NULL, "sample_line_hist");
        RNA_def_property_struct_type(prop, "Histogram");
        RNA_def_property_ui_text(prop, "Line sample", "Sampled colors along line");
+
+       prop= RNA_def_property(srna, "zoom", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_array(prop, 2);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_float_funcs(prop, "rna_SpaceImageEditor_zoom_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "Zoom", "Zoom factor");
        
        /* image draw */
        prop= RNA_def_property(srna, "show_repeat", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/readblenfile/BLO_readblenfile.h b/source/blender/readblenfile/BLO_readblenfile.h
deleted file mode 100644 (file)
index 9b4e151..0000000
+++ /dev/null
@@ -1,87 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 BLO_READBLENFILE_H
-#define BLO_READBLENFILE_H
-
-/** \file BLO_readblenfile.h
- *  \ingroup blo
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct ReportList;
-
-       BlendFileData *
-BLO_readblenfilename(
-       char *fileName, 
-       struct ReportList *reports);
-
-       BlendFileData *
-BLO_readblenfilehandle(
-       int fileHandle, 
-       struct ReportList *reports);
-
-       BlendFileData *
-BLO_readblenfilememory(
-       char *fromBuffer,
-       int fromBufferSize, 
-       struct ReportList *reports);
-
-
-       void
-BLO_setcurrentversionnumber(
-       char array[4]);
-
-       void
-BLO_setversionnumber(
-       char array[4],
-       int version);
-
-       int
-blo_is_a_runtime(
-       char *file);
-
-       BlendFileData *
-blo_read_runtime(
-       char *file, 
-       struct ReportList *reports);
-
-#define BLO_RESERVEDSIZE 12
-extern const char *headerMagic;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BLO_READBLENFILE_H */
-
diff --git a/source/blender/readblenfile/CMakeLists.txt b/source/blender/readblenfile/CMakeLists.txt
deleted file mode 100644 (file)
index 9b869d3..0000000
+++ /dev/null
@@ -1,42 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# The Original Code is Copyright (C) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-set(INC 
-       .
-       ../blenloader
-       ../blenloader/intern
-       ../blenkernel
-       ../blenlib
-       ../makesdna
-)
-
-set(SRC
-       intern/BLO_readblenfile.c
-
-       BLO_readblenfile.h
-)
-
-blender_add_lib(bf_readblenfile "${SRC}" "${INC}")
diff --git a/source/blender/readblenfile/SConscript b/source/blender/readblenfile/SConscript
deleted file mode 100644 (file)
index 07f84eb..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/python
-Import ('env')
-
-sources = env.Glob('intern/*.c')
-
-incs = '.  ../blenloader ../blenloader/intern ../blenkernel ../blenlib ../makesdna'
-
-env.BlenderLib ( 'bf_readblenfile', sources, Split(incs), [], libtype=['core','player'], priority = [0,5] )
diff --git a/source/blender/readblenfile/stub/BLO_readblenfileSTUB.c b/source/blender/readblenfile/stub/BLO_readblenfileSTUB.c
deleted file mode 100644 (file)
index 0f3541b..0000000
+++ /dev/null
@@ -1,97 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 *****
- *
- */
-
-/** \file blender/readblenfile/stub/BLO_readblenfileSTUB.c
- *  \ingroup blo
- */
-
-
-#include <stdio.h>
-
-int BLO_readblenfilememory( char *fromBuffer, int fromBufferSize);
-int BLO_readblenfilename( char *fileName);
-int BLO_readblenfilehandle( int fileHandle);
-int BLO_is_a_runtime( char *file);
-int BLO_read_runtime( char *file);
-
-       int
-BLO_readblenfilememory(
-       char *fromBuffer, int fromBufferSize)
-{
-#if defined(DEBUG)
-       fprintf(stderr,
-                       "Error BLO_readblenfilename is a stub\n");
-#endif
-       return(1);
-}
-
-       int
-BLO_readblenfilename(
-       char *fileName)
-{
-#if defined(DEBUG)
-       fprintf(stderr,
-                       "Error BLO_readblenfilename is a stub\n");
-#endif
-       return(1);
-}
-
-       int
-BLO_readblenfilehandle(
-       int fileHandle)
-{
-#if defined(DEBUG)
-       fprintf(stderr,
-                       "Error BLO_readblenfilehandle is a stub\n");
-#endif
-       return(1);
-}
-
-       int
-BLO_is_a_runtime(
-       char *file)
-{
-#if defined(DEBUG)
-       fprintf(stderr,
-                       "Error BLO_is_a_runtime is a stub\n");
-#endif
-       return 0;
-}
-
-       int
-BLO_read_runtime(
-       char *file) 
-{
-#if defined(DEBUG)
-       fprintf(stderr,
-                       "Error BLO_read_runtime is a stub\n");
-#endif
-       return 0;
-}
index 1b4fff8cd13a8ae03ceeb9e3a942eb1b195b570c..58645f48787992cdd372f4448d4b9b8b1ff49521 100644 (file)
@@ -293,12 +293,6 @@ struct wmGesture *WM_gesture_new(struct bContext *C, struct wmEvent *event, int
 void           WM_gesture_end(struct bContext *C, struct wmGesture *gesture);
 void           WM_gestures_remove(struct bContext *C);
 
-                       /* radial control operator */
-int                    WM_radial_control_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
-int                    WM_radial_control_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
-void           WM_OT_radial_control_partial(struct wmOperatorType *ot);
-void           WM_radial_control_string(struct wmOperator *op, char str[], int maxlen);
-
                        /* fileselecting support */
 void           WM_event_add_fileselect(struct bContext *C, struct wmOperator *op);
 void           WM_event_fileselect_event(struct bContext *C, void *ophandle, int eventval);
index d32a26549e7bcc104278c9f89e8dbfcc8d1a5bcc..fa693752ff7a17d4de3e18b6b7a20695da18a865 100644 (file)
@@ -61,6 +61,7 @@
 #include "BLO_readfile.h"
 
 #include "BKE_blender.h"
+#include "BKE_brush.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_idprop.h"
@@ -2674,272 +2675,465 @@ void WM_OT_straightline_gesture(wmOperatorType *ot)
 
 static const int WM_RADIAL_CONTROL_DISPLAY_SIZE = 200;
 
-typedef struct wmRadialControl {
-       int mode;
-       float initial_value, value, max_value;
-       float col[4], tex_col[4];
+typedef struct {
+       PropertyType type;
+       PropertySubType subtype;
+       PointerRNA ptr, col_ptr, fill_col_ptr, rot_ptr, zoom_ptr, image_id_ptr;
+       PropertyRNA *prop, *col_prop, *fill_col_prop, *rot_prop, *zoom_prop;
+       StructRNA *image_id_srna;
+       float initial_value, current_value, min_value, max_value;
        int initial_mouse[2];
+       unsigned int gltex;
+       ListBase orig_paintcursors;
        void *cursor;
-       GLuint tex;
-} wmRadialControl;
+} RadialControl;
 
-static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata)
+static void radial_control_set_initial_mouse(RadialControl *rc, wmEvent *event)
 {
-       wmRadialControl *rc = (wmRadialControl*)customdata;
-       ARegion *ar = CTX_wm_region(C);
-       float r1=0.0f, r2=0.0f, r3=0.0f, angle=0.0f;
+       float d[2] = {0, 0};
+       float zoom[2] = {1, 1};
 
-       // int hit = 0;
-       
-       if(rc->mode == WM_RADIALCONTROL_STRENGTH)
-               rc->tex_col[3]= (rc->value + 0.5f);
+       rc->initial_mouse[0]= event->x;
+       rc->initial_mouse[1]= event->y;
 
-       if(rc->mode == WM_RADIALCONTROL_SIZE) {
-               r1= rc->value;
-               r2= rc->initial_value;
-               r3= r1;
-       } else if(rc->mode == WM_RADIALCONTROL_STRENGTH) {
-               r1= (1 - rc->value) * WM_RADIAL_CONTROL_DISPLAY_SIZE;
-               r2= r3= (float)WM_RADIAL_CONTROL_DISPLAY_SIZE;
-       } else if(rc->mode == WM_RADIALCONTROL_ANGLE) {
-               r1= r2= r3= (float)WM_RADIAL_CONTROL_DISPLAY_SIZE;
-               angle = rc->value;
+       switch(rc->subtype) {
+       case PROP_DISTANCE:
+               d[0] = rc->initial_value;
+               break;
+       case PROP_FACTOR:
+               d[0] = WM_RADIAL_CONTROL_DISPLAY_SIZE * (1 - rc->initial_value);
+               break;
+       case PROP_ANGLE:
+               d[0] = WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(rc->initial_value);
+               d[1] = WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(rc->initial_value);
+               break;
+       default:
+               return;
        }
 
-       /* Keep cursor in the original place */
-       x = rc->initial_mouse[0] - ar->winrct.xmin;
-       y = rc->initial_mouse[1] - ar->winrct.ymin;
+       if(rc->zoom_prop) {
+               RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
+               d[0] *= zoom[0];
+               d[1] *= zoom[1];
+       }
 
-       glTranslatef((float)x, (float)y, 0.0f);
+       rc->initial_mouse[0]-= d[0];
+       rc->initial_mouse[1]-= d[1];
+}
 
-       glEnable(GL_BLEND);
+static void radial_control_set_tex(RadialControl *rc)
+{
+       ImBuf *ibuf;
 
-       if(rc->mode == WM_RADIALCONTROL_ANGLE) {
-               glRotatef(angle, 0, 0, 1);
+       switch(RNA_type_to_ID_code(rc->image_id_ptr.type)) {
+       case ID_BR:
+               if((ibuf = brush_gen_radial_control_imbuf(rc->image_id_ptr.data))) {
+                       glGenTextures(1, &rc->gltex);
+                       glBindTexture(GL_TEXTURE_2D, rc->gltex);
+                       glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, ibuf->x, ibuf->y, 0,
+                                    GL_ALPHA, GL_FLOAT, ibuf->rect_float);
+                       MEM_freeN(ibuf->rect_float);
+                       MEM_freeN(ibuf);
+               }
+               break;
+       default:
+               break;
        }
+}
+
+static void radial_control_paint_tex(RadialControl *rc, float radius, float alpha)
+{
+       float col[3] = {0, 0, 0};
+       float rot;
+
+       /* set fill color */
+       if(rc->fill_col_prop)
+               RNA_property_float_get_array(&rc->fill_col_ptr, rc->fill_col_prop, col);
+       glColor4f(col[0], col[1], col[2], alpha);
 
-       if (rc->tex) {
-               glBindTexture(GL_TEXTURE_2D, rc->tex);
+       if(rc->gltex) {
+               glBindTexture(GL_TEXTURE_2D, rc->gltex);
 
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
+               /* set up rotation if available */
+               if(rc->rot_prop) {
+                       rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
+                       glPushMatrix();
+                       glRotatef(RAD2DEGF(rot), 0, 0, 1);
+               }
+
+               /* draw textured quad */
                glEnable(GL_TEXTURE_2D);
                glBegin(GL_QUADS);
-               glColor4fv(rc->tex_col);
                glTexCoord2f(0,0);
-               glVertex2f(-r3, -r3);
+               glVertex2f(-radius, -radius);
                glTexCoord2f(1,0);
-               glVertex2f(r3, -r3);
+               glVertex2f(radius, -radius);
                glTexCoord2f(1,1);
-               glVertex2f(r3, r3);
+               glVertex2f(radius, radius);
                glTexCoord2f(0,1);
-               glVertex2f(-r3, r3);
+               glVertex2f(-radius, radius);
                glEnd();
                glDisable(GL_TEXTURE_2D);
+
+               /* undo rotation */
+               if(rc->rot_prop)
+                       glPopMatrix();
        }
+       else {
+               /* flat color if no texture available */
+               glutil_draw_filled_arc(0, M_PI * 2, radius, 40);
+       }
+}
+
+static void radial_control_paint_cursor(bContext *C, int x, int y, void *customdata)
+{
+       RadialControl *rc = customdata;
+       ARegion *ar = CTX_wm_region(C);
+       float r1=0.0f, r2=0.0f, tex_radius, alpha;
+       float zoom[2], col[3] = {1, 1, 1};
 
-       if(rc->mode == WM_RADIALCONTROL_ANGLE) {
-               glColor4fv(rc->col);
-               glEnable(GL_LINE_SMOOTH);
-               glRotatef(-angle, 0, 0, 1);
+       switch(rc->subtype) {
+       case PROP_DISTANCE:
+               r1= rc->current_value;
+               r2= rc->initial_value;
+               tex_radius= r1;
+               alpha = 0.75;
+               break;
+       case PROP_FACTOR:
+               r1= (1 - rc->current_value) * WM_RADIAL_CONTROL_DISPLAY_SIZE;
+               r2= tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE;
+               alpha = rc->current_value / 2 + 0.5;
+               break;
+       case PROP_ANGLE:
+               r1= r2= tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE;
+               alpha = 0.75;
+               break;
+       default:
+               break;
+       }
+
+       /* Keep cursor in the original place */
+       x = rc->initial_mouse[0] - ar->winrct.xmin;
+       y = rc->initial_mouse[1] - ar->winrct.ymin;
+       glTranslatef((float)x, (float)y, 0.0f);
+
+       glEnable(GL_BLEND);
+       glEnable(GL_LINE_SMOOTH);
+
+       /* apply zoom if available */
+       if(rc->zoom_prop) {
+               RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
+               glScalef(zoom[0], zoom[1], 1);
+       }
+
+       /* draw rotated texture */
+       radial_control_paint_tex(rc, tex_radius, alpha);
+
+       /* set line color */
+       if(rc->col_prop)
+               RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col);
+       glColor4f(col[0], col[1], col[2], 0.5);
+
+       if(rc->subtype == PROP_ANGLE) {
+               glPushMatrix();
+               /* draw original angle line */
+               glRotatef(RAD2DEGF(rc->initial_value), 0, 0, 1);
                fdrawline(0.0f, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f);
-               glRotatef(angle, 0, 0, 1);
+               /* draw new angle line */
+               glRotatef(RAD2DEGF(rc->current_value - rc->initial_value), 0, 0, 1);
                fdrawline(0.0f, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f);
-               glDisable(GL_LINE_SMOOTH);
+               glPopMatrix();
        }
 
-       glColor4fv(rc->col);
+       /* draw circles on top */
        glutil_draw_lined_arc(0.0, (float)(M_PI*2.0), r1, 40);
        glutil_draw_lined_arc(0.0, (float)(M_PI*2.0), r2, 40);
+
        glDisable(GL_BLEND);
+       glDisable(GL_LINE_SMOOTH);
 }
 
-int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
+/* attempt to retrieve the rna pointer/property from an rna path;
+   returns 0 for failure, 1 for success, and also 1 if property is not
+   set */
+static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op,
+                                  const char *name, PointerRNA *r_ptr,
+                                  PropertyRNA **r_prop, int req_float,
+                                  int req_length, int allow_missing)
 {
-       wmRadialControl *rc = (wmRadialControl*)op->customdata;
-       int mode, initial_mouse[2], delta[2];
-       float dist;
-       double new_value = RNA_float_get(op->ptr, "new_value");
-       int ret = OPERATOR_RUNNING_MODAL;
-       // float initial_value = RNA_float_get(op->ptr, "initial_value");
+       PropertyRNA *unused_prop;
+       int len;
+       char *str;
 
-       mode = RNA_enum_get(op->ptr, "mode");
-       RNA_int_get_array(op->ptr, "initial_mouse", initial_mouse);
+       /* get an rna string path from the operator's properties */
+       if(!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0)))
+               return 1;
 
-       switch(event->type) {
-       case MOUSEMOVE:
-               delta[0]= initial_mouse[0] - event->x;
-               delta[1]= initial_mouse[1] - event->y;
+       if(str[0] == '\0') {
+               MEM_freeN(str);
+               return 1;
+       }
 
-               //if (mode == WM_RADIALCONTROL_SIZE) 
-               //      delta[0]+= initial_value;
-               //else if(mode == WM_RADIALCONTROL_STRENGTH)
-               //      delta[0]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * (1 - initial_value);
-               //else if(mode == WM_RADIALCONTROL_ANGLE) {
-               //      delta[0]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(initial_value*M_PI/180.0f);
-               //      delta[1]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(initial_value*M_PI/180.0f);
-               //}
+       if(!r_prop)
+               r_prop = &unused_prop;
 
-               dist= sqrtf(delta[0]*delta[0]+delta[1]*delta[1]);
+       /* get rna from path */
+       if(!RNA_path_resolve(ctx_ptr, str, r_ptr, r_prop)) {
+               MEM_freeN(str);
+               if(allow_missing)
+                       return 1;
+               else {
+                       BKE_reportf(op->reports, RPT_ERROR, "Couldn't resolve path %s", name);
+                       return 0;
+               }
+       }
 
-               if(mode == WM_RADIALCONTROL_SIZE)
-                       new_value = dist;
-               else if(mode == WM_RADIALCONTROL_STRENGTH) {
-                       new_value = 1 - dist / WM_RADIAL_CONTROL_DISPLAY_SIZE;
-               } else if(mode == WM_RADIALCONTROL_ANGLE)
-                       new_value = ((int)(atan2f(delta[1], delta[0]) * (float)(180.0 / M_PI)) + 180);
-               
-               if(event->ctrl) {
-                       if(mode == WM_RADIALCONTROL_STRENGTH)
-                               new_value = ((int)ceilf(new_value * 10.f) * 10.0f) / 100.f;
-                       else
-                               new_value = ((int)new_value + 5) / 10*10;
+       /* if property is expected to be a float, check its type */
+       if(req_float) {
+               if(!(*r_prop) || (RNA_property_type(*r_prop) != PROP_FLOAT)) {
+                       MEM_freeN(str);
+                       BKE_reportf(op->reports, RPT_ERROR,
+                                   "Property from path %s is not a float", name);
+                       return 0;
                }
-               
-               break;
-       case ESCKEY:
-       case RIGHTMOUSE:
-               ret = OPERATOR_CANCELLED;
-               break;
-       case LEFTMOUSE:
-       case PADENTER:
-               op->type->exec(C, op);
-               ret = OPERATOR_FINISHED;
-               break;
+       }
+       
+       /* check property's array length */
+       if(*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) {
+               MEM_freeN(str);
+               BKE_reportf(op->reports, RPT_ERROR,
+                           "Property from path %s has length %d instead of %d",
+                           name, len, req_length);
+               return 0;
        }
 
-       /* Clamp */
-       if(new_value > rc->max_value)
-               new_value = rc->max_value;
-       else if(new_value < 0)
-               new_value = 0;
+       /* success */
+       MEM_freeN(str);
+       return 1;
+}
 
-       /* Update paint data */
-       rc->value = (float)new_value;
+/* initialize the rna pointers and properties using rna paths */
+static int radial_control_get_properties(bContext *C, wmOperator *op)
+{
+       RadialControl *rc = op->customdata;
+       PointerRNA ctx_ptr;
 
-       RNA_float_set(op->ptr, "new_value", rc->value);
+       RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
 
-       if(ret != OPERATOR_RUNNING_MODAL) {
-               WM_paint_cursor_end(CTX_wm_manager(C), rc->cursor);
-               MEM_freeN(rc);
-       }
-       
-       ED_region_tag_redraw(CTX_wm_region(C));
+       if(!radial_control_get_path(&ctx_ptr, op, "data_path", &rc->ptr, &rc->prop, 0, 0, 0))
+               return 0;
 
-       //if (ret != OPERATOR_RUNNING_MODAL) {
-       //      wmWindow *win = CTX_wm_window(C);
-       //      WM_cursor_restore(win);
-       //}
+       /* data path is required */
+       if(!rc->prop)
+               return 0;
+       
+       if(!radial_control_get_path(&ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 1, 0, 0))
+               return 0;
+       if(!radial_control_get_path(&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 1, 3, 0))
+               return 0;
+       if(!radial_control_get_path(&ctx_ptr, op, "fill_color_path", &rc->fill_col_ptr, &rc->fill_col_prop, 1, 3, 0))
+               return 0;
+       
+       /* slightly ugly; allow this property to not resolve
+          correctly. needed because 3d texture paint shares the same
+          keymap as 2d image paint */
+       if(!radial_control_get_path(&ctx_ptr, op, "zoom_path", &rc->zoom_ptr, &rc->zoom_prop, 1, 2, 1))
+               return 0;
+       
+       if(!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0, 0))
+               return 0;
+       else if(rc->image_id_ptr.data) {
+               /* extra check, pointer must be to an ID */
+               if(!RNA_struct_is_ID(rc->image_id_ptr.type)) {
+                       BKE_report(op->reports, RPT_ERROR,
+                                  "Pointer from path image_id is not an ID");
+                       return 0;
+               }
+       }
 
-       return ret;
+       return 1;
 }
 
-/* Expects the operator customdata to be an ImBuf (or NULL) */
-int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       wmRadialControl *rc = MEM_callocN(sizeof(wmRadialControl), "radial control");
-       // wmWindow *win = CTX_wm_window(C);
-       int mode = RNA_enum_get(op->ptr, "mode");
-       float initial_value = RNA_float_get(op->ptr, "initial_value");
-       //float initial_size = RNA_float_get(op->ptr, "initial_size");
-       int mouse[2];
+       wmWindowManager *wm;
+       RadialControl *rc;
+       int min_value_int, max_value_int, step_int;
+       float step_float, precision;
 
-       mouse[0]= event->x;
-       mouse[1]= event->y;
-
-       //if (initial_size == 0)
-       //      initial_size = WM_RADIAL_CONTROL_DISPLAY_SIZE;
+       if(!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl")))
+               return OPERATOR_CANCELLED;
 
-       if(mode == WM_RADIALCONTROL_SIZE) {
-               rc->max_value = 200;
-               mouse[0]-= (int)initial_value;
-       }
-       else if(mode == WM_RADIALCONTROL_STRENGTH) {
-               rc->max_value = 1;
-               mouse[0]-= (int)(WM_RADIAL_CONTROL_DISPLAY_SIZE * (1.0f - initial_value));
-       }
-       else if(mode == WM_RADIALCONTROL_ANGLE) {
-               rc->max_value = 360;
-               mouse[0]-= (int)(WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(initial_value));
-               mouse[1]-= (int)(WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(initial_value));
-               initial_value *= 180.0f/(float)M_PI;
+       if(!radial_control_get_properties(C, op)) {
+               MEM_freeN(rc);
+               return OPERATOR_CANCELLED;
        }
 
-       if(op->customdata) {
-               ImBuf *im = (ImBuf*)op->customdata;
-               /* Build GL texture */
-               glGenTextures(1, &rc->tex);
-               glBindTexture(GL_TEXTURE_2D, rc->tex);
-               glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, im->x, im->y, 0, GL_ALPHA, GL_FLOAT, im->rect_float);
-               MEM_freeN(im->rect_float);
-               MEM_freeN(im);
+       /* get type, initial, min, and max values of the property */
+       switch((rc->type = RNA_property_type(rc->prop))) {
+       case PROP_INT:
+               rc->initial_value = RNA_property_int_get(&rc->ptr, rc->prop);
+               RNA_property_int_ui_range(&rc->ptr, rc->prop, &min_value_int,
+                                         &max_value_int, &step_int);
+               rc->min_value = min_value_int;
+               rc->max_value = max_value_int;
+               break;
+       case PROP_FLOAT:
+               rc->initial_value = RNA_property_float_get(&rc->ptr, rc->prop);
+               RNA_property_float_ui_range(&rc->ptr, rc->prop, &rc->min_value,
+                                           &rc->max_value, &step_float, &precision);
+               break;
+       default:
+               BKE_report(op->reports, RPT_ERROR, "Property must be an integer or a float");
+               MEM_freeN(rc);
+               return OPERATOR_CANCELLED;
        }
 
-       RNA_float_get_array(op->ptr, "color", rc->col);
-       RNA_float_get_array(op->ptr, "texture_color", rc->tex_col);
-
-       RNA_int_set_array(op->ptr, "initial_mouse", mouse);
-       RNA_float_set(op->ptr, "new_value", initial_value);
+       /* get subtype of property */
+       rc->subtype = RNA_property_subtype(rc->prop);
+       if(!ELEM3(rc->subtype, PROP_DISTANCE, PROP_FACTOR, PROP_ANGLE)) {
+               BKE_report(op->reports, RPT_ERROR, "Property must be a distance, a factor, or an angle");
+               MEM_freeN(rc);
+               return OPERATOR_CANCELLED;
+       }
                
-       op->customdata = rc;
-       rc->mode = mode;
-       rc->initial_value = initial_value;
-       rc->initial_mouse[0] = mouse[0];
-       rc->initial_mouse[1] = mouse[1];
-       rc->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), op->type->poll,
-                                                 wm_radial_control_paint, op->customdata);
+       rc->current_value = rc->initial_value;
+       radial_control_set_initial_mouse(rc, event);
+       radial_control_set_tex(rc);
 
-       //WM_cursor_modal(win, CURSOR_NONE);
+       /* temporarily disable other paint cursors */
+       wm = CTX_wm_manager(C);
+       rc->orig_paintcursors = wm->paintcursors;
+       wm->paintcursors.first = wm->paintcursors.last = NULL;
+
+       /* add radial control paint cursor */
+       rc->cursor = WM_paint_cursor_activate(wm, op->type->poll,
+                                             radial_control_paint_cursor, rc);
 
-       /* add modal handler */
        WM_event_add_modal_handler(C, op);
-       
-       WM_radial_control_modal(C, op, event);
-       
+
        return OPERATOR_RUNNING_MODAL;
 }
 
-/* Gets a descriptive string of the operation */
-void WM_radial_control_string(wmOperator *op, char str[], int maxlen)
+static void radial_control_set_value(RadialControl *rc, float val)
 {
-       int mode = RNA_enum_get(op->ptr, "mode");
-       float v = RNA_float_get(op->ptr, "new_value");
-
-       if(mode == WM_RADIALCONTROL_SIZE)
-               BLI_snprintf(str, maxlen, "Size: %d", (int)v);
-       else if(mode == WM_RADIALCONTROL_STRENGTH)
-               BLI_snprintf(str, maxlen, "Strength: %d", (int)v);
-       else if(mode == WM_RADIALCONTROL_ANGLE)
-               BLI_snprintf(str, maxlen, "Angle: %d", (int)(v * 180.0f/(float)M_PI));
+       switch(rc->type) {
+       case PROP_INT:
+               RNA_property_int_set(&rc->ptr, rc->prop, val);
+               break;
+       case PROP_FLOAT:
+               RNA_property_float_set(&rc->ptr, rc->prop, val);
+               break;
+       default:
+               break;
+       }
 }
 
-/** Important: this doesn't define an actual operator, it
-       just sets up the common parts of the radial control op. **/
-void WM_OT_radial_control_partial(wmOperatorType *ot)
+static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
-       static EnumPropertyItem radial_mode_items[] = {
-               {WM_RADIALCONTROL_SIZE, "SIZE", 0, "Size", ""},
-               {WM_RADIALCONTROL_STRENGTH, "STRENGTH", 0, "Strength", ""},
-               {WM_RADIALCONTROL_ANGLE, "ANGLE", 0, "Angle", ""},
-               {0, NULL, 0, NULL, NULL}};
-       static float color[4] = {1.0f, 1.0f, 1.0f, 0.5f};
-       static float tex_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+       RadialControl *rc = op->customdata;
+       wmWindowManager *wm;
+       float new_value, dist, zoom[2];
+       float delta[2], snap, ret = OPERATOR_RUNNING_MODAL;
+
+       /* TODO: fix hardcoded events */
 
-       /* Should be set in custom invoke() */
-       RNA_def_float(ot->srna, "initial_value", 0, 0, FLT_MAX, "Initial Value", "", 0, FLT_MAX);
+       snap = event->ctrl;
 
-       /* Set internally, should be used in custom exec() to get final value */
-       RNA_def_float(ot->srna, "new_value", 0, 0, FLT_MAX, "New Value", "", 0, FLT_MAX);
+       switch(event->type) {
+       case MOUSEMOVE:
+               delta[0]= rc->initial_mouse[0] - event->x;
+               delta[1]= rc->initial_mouse[1] - event->y;
+
+               if(rc->zoom_prop) {
+                       RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
+                       delta[0] /= zoom[0];
+                       delta[1] /= zoom[1];
+               }
+
+               dist= sqrt(delta[0]*delta[0]+delta[1]*delta[1]);
+
+               /* calculate new value and apply snapping  */
+               switch(rc->subtype) {
+               case PROP_DISTANCE:
+                       new_value = dist;
+                       if(snap) new_value = ((int)new_value + 5) / 10*10;
+                       break;
+               case PROP_FACTOR:
+                       new_value = 1 - dist / WM_RADIAL_CONTROL_DISPLAY_SIZE;
+                       if(snap) new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f;
+                       break;
+               case PROP_ANGLE:
+                       new_value = atan2(delta[1], delta[0]) + M_PI;
+                       if(snap) new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10*10);
+                       break;
+               default:
+                       break;
+               }
+
+               /* clamp and update */
+               CLAMP(new_value, rc->min_value, rc->max_value);
+               radial_control_set_value(rc, new_value);
+               rc->current_value = new_value;
+               break;
+
+       case ESCKEY:
+       case RIGHTMOUSE:
+               /* cancelled; restore original value */
+               radial_control_set_value(rc, rc->initial_value);
+               ret = OPERATOR_CANCELLED;
+               break;
+               
+       case LEFTMOUSE:
+       case PADENTER:
+               /* done; value already set */
+               ret = OPERATOR_FINISHED;
+               break;
+       }
+
+       ED_region_tag_redraw(CTX_wm_region(C));
+
+       if(ret != OPERATOR_RUNNING_MODAL) {
+               wm = CTX_wm_manager(C);
+
+               WM_paint_cursor_end(wm, rc->cursor);
+
+               /* restore original paint cursors */
+               wm->paintcursors = rc->orig_paintcursors;
+
+               /* not sure if this is a good notifier to use;
+                  intended purpose is to update the UI so that the
+                  new value is displayed in sliders/numfields */
+               WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+               glDeleteTextures(1, &rc->gltex);
+
+               MEM_freeN(rc);
+       }
+
+       return ret;
+}
+
+static void WM_OT_radial_control(wmOperatorType *ot)
+{
+       ot->name= "Radial Control";
+       ot->idname= "WM_OT_radial_control";
 
-       /* Should be set before calling operator */
-       RNA_def_enum(ot->srna, "mode", radial_mode_items, 0, "Mode", "");
+       ot->invoke= radial_control_invoke;
+       ot->modal= radial_control_modal;
 
-       /* Internal */
-       RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "Initial Mouse", "", INT_MIN, INT_MAX);
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
 
-       RNA_def_float_color(ot->srna, "color", 4, color, 0.0f, FLT_MAX, "Color", "Radial control color", 0.0f, 1.0f);
-       RNA_def_float_color(ot->srna, "texture_color", 4, tex_color, 0.0f, FLT_MAX, "Texture Color", "Radial control texture color", 0.0f, 1.0f);
+       /* all paths relative to the context */
+       RNA_def_string(ot->srna, "data_path", "", 0, "Data Path", "Path of property to be set by the radial control.");
+       RNA_def_string(ot->srna, "rotation_path", "", 0, "Rotation Path", "Path of property used to rotate the texture display.");
+       RNA_def_string(ot->srna, "color_path", "", 0, "Color Path", "Path of property used to set the color of the control.");
+       RNA_def_string(ot->srna, "fill_color_path", "", 0, "Fill Color Path", "Path of property used to set the fill color of the control.");
+       RNA_def_string(ot->srna, "zoom_path", "", 0, "Zoom Path", "Path of property used to set the zoom level for the control.");
+       RNA_def_string(ot->srna, "image_id", "", 0, "Image ID", "Path of ID that is used to generate an image for the control.");
 }
 
 /* ************************** timer for testing ***************** */
@@ -3133,6 +3327,7 @@ void wm_operatortype_init(void)
        WM_operatortype_append(WM_OT_splash);
        WM_operatortype_append(WM_OT_search_menu);
        WM_operatortype_append(WM_OT_call_menu);
+       WM_operatortype_append(WM_OT_radial_control);
 #if defined(WIN32)
        WM_operatortype_append(WM_OT_console_toggle);
 #endif
index 97021df288f72afa20e7b13e3795b0f11b48702f..3aafc7d747a3c1e360ed7f3ee334d27d4f3ba1cb 100644 (file)
@@ -128,7 +128,6 @@ endif()
                extern_openjpeg
                extern_redcode
                bf_imbuf_dds
-               bf_readblenfile 
                bf_dna
                ge_videotex
                bf_blenfont
index ce26510d212f4b8a7677261a766e28cb27a01007..3fc25dc4f14b6d87855249d420d375aa50959835 100644 (file)
@@ -248,6 +248,7 @@ short ANIM_add_driver(struct ID *id, const char rna_path[], int array_index, sho
 short ANIM_remove_driver (struct ID *id, const char rna_path[], int array_index, short flag){return 0;}
 void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock){}
 struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r){return (struct ImBuf *) NULL;}
+void ED_space_image_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy) {}
 char *ED_info_stats_string(struct Scene *scene){return (char *) NULL;}
 void ED_area_tag_redraw(struct ScrArea *sa){}
 void ED_area_tag_refresh(struct ScrArea *sa){}
index bf88b4a84cce6d9b82558d281b0a26105bf5ad82..26935d4b127adb2173dc60092b5ea97eea601435 100644 (file)
@@ -773,7 +773,6 @@ endif()
                bf_imbuf_cineon
                bf_imbuf_openexr
                bf_imbuf_dds
-               bf_readblenfile
                bf_collada
                bf_intern_bsp
                bf_intern_bop
index edf0839f74786ef36b9792d56b3d53c7a2c0d197..389300efc2137efdf73b4a4b90fa9f70b3c7bac7 100644 (file)
@@ -39,7 +39,6 @@ set(INC
        ../../../../source/blender/blenfont
        ../../../../source/blender/blenlib
        ../../../../source/blender/blenkernel
-       ../../../../source/blender/readblenfile
        ../../../../source/blender
        ../../../../source/blender/makesdna
        ../../../../source/blender/makesrna
index a4f1391b1b0bae61d8648d36ec100eb901c7ffec..832cd8b0651e92507d6781a01adf82225b348a9c 100644 (file)
@@ -67,7 +67,7 @@ extern "C"
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
 #include "BLO_readfile.h"
-#include "BLO_readblenfile.h"
+#include "BLO_runtime.h"
 #include "IMB_imbuf.h"
 #include "BKE_text.h"
        
@@ -313,8 +313,8 @@ static BlendFileData *load_game_data(char *progname, char *filename = NULL, char
        BKE_reports_init(&reports, RPT_STORE);
        
        /* try to load ourself, will only work if we are a runtime */
-       if (blo_is_a_runtime(progname)) {
-               bfd= blo_read_runtime(progname, &reports);
+       if (BLO_is_a_runtime(progname)) {
+               bfd= BLO_read_runtime(progname, &reports);
                if (bfd) {
                        bfd->type= BLENFILETYPE_RUNTIME;
                        strcpy(bfd->main->name, progname);
@@ -444,7 +444,7 @@ int main(int argc, char** argv)
        U.audiochannels = 2;
 
        /* if running blenderplayer the last argument can't be parsed since it has to be the filename. */
-       isBlenderPlayer = !blo_is_a_runtime(argv[0]);
+       isBlenderPlayer = !BLO_is_a_runtime(argv[0]);
        if (isBlenderPlayer)
                validArguments = argc - 1;
        else
index 65bd55f95d7ddf2152ce443bfceb31fadd311880..e3ffc1a406b2b9c1295a7deb80ea62e16c6174c9 100644 (file)
@@ -22,7 +22,6 @@ incs = ['.',
         '#source/blender/blenfont',
         '#source/blender/blenlib',
         '#source/blender/blenkernel',
-        '#source/blender/readblenfile',
         '#source/blender',
         '#source/blender/include',
         '#source/blender/makesdna',