[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13257] trunk/blender/source/blender: == Radial Control ==
Nicholas Bishop
nicholasbishop at gmail.com
Wed Jan 16 08:19:21 CET 2008
Revision: 13257
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13257
Author: nicholasbishop
Date: 2008-01-16 08:19:21 +0100 (Wed, 16 Jan 2008)
Log Message:
-----------
== Radial Control ==
* Generalized the interactive brush property control from sculpt mode into a simple API
* Modified sculpt mode to take advantage of this (even fixes some minor bugs!)
* Added shortcuts in particle edit to set brush size/strength (FKEY/shift+FKEY)
Still todo are the other modes that have brushes...
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_sculpt.h
trunk/blender/source/blender/blenkernel/intern/scene.c
trunk/blender/source/blender/include/BDR_sculptmode.h
trunk/blender/source/blender/include/BIF_editparticle.h
trunk/blender/source/blender/src/drawview.c
trunk/blender/source/blender/src/editparticle.c
trunk/blender/source/blender/src/header_view3d.c
trunk/blender/source/blender/src/sculptmode.c
trunk/blender/source/blender/src/space.c
Added Paths:
-----------
trunk/blender/source/blender/include/BIF_radialcontrol.h
trunk/blender/source/blender/src/radialcontrol.c
Modified: trunk/blender/source/blender/blenkernel/BKE_sculpt.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_sculpt.h 2008-01-16 03:02:54 UTC (rev 13256)
+++ trunk/blender/source/blender/blenkernel/BKE_sculpt.h 2008-01-16 07:19:21 UTC (rev 13257)
@@ -31,30 +31,11 @@
#define BKE_SCULPT_H
struct NumInput;
+struct RadialControl;
struct Scene;
struct SculptData;
struct SculptSession;
-typedef enum PropsetMode {
- PropsetNone = 0,
- PropsetSize,
- PropsetStrength,
- PropsetTexRot
-} PropsetMode;
-
-typedef struct PropsetData {
- PropsetMode mode;
- unsigned int tex;
- short origloc[2];
- float *texdata;
-
- short origsize;
- char origstrength;
- float origtexrot;
-
- struct NumInput *num;
-} PropsetData;
-
typedef struct SculptSession {
struct ProjVert *projverts;
@@ -76,7 +57,7 @@
/* Used to cache the render of the active texture */
unsigned int texcache_w, texcache_h, *texcache;
- struct PropsetData *propset;
+ struct RadialControl *radialcontrol;
/* For rotating around a pivot point */
vec3f pivot;
Modified: trunk/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/scene.c 2008-01-16 03:02:54 UTC (rev 13256)
+++ trunk/blender/source/blender/blenkernel/intern/scene.c 2008-01-16 07:19:21 UTC (rev 13257)
@@ -661,13 +661,8 @@
if(ss->mats)
MEM_freeN(ss->mats);
- if(ss->propset) {
- if(ss->propset->texdata)
- MEM_freeN(ss->propset->texdata);
- if(ss->propset->num)
- MEM_freeN(ss->propset->num);
- MEM_freeN(ss->propset);
- }
+ if(ss->radialcontrol)
+ MEM_freeN(ss->radialcontrol);
sculpt_vertexusers_free(ss);
if(ss->texcache)
Modified: trunk/blender/source/blender/include/BDR_sculptmode.h
===================================================================
--- trunk/blender/source/blender/include/BDR_sculptmode.h 2008-01-16 03:02:54 UTC (rev 13256)
+++ trunk/blender/source/blender/include/BDR_sculptmode.h 2008-01-16 07:19:21 UTC (rev 13257)
@@ -33,7 +33,6 @@
#include "DNA_listBase.h"
#include "DNA_vec_types.h"
#include "BKE_sculpt.h"
-#include "transform.h"
struct uiBlock;
struct BrushData;
@@ -59,15 +58,13 @@
void sculptmode_draw_interface_brush(struct uiBlock *block,unsigned short cx, unsigned short cy);
void sculptmode_draw_interface_textures(struct uiBlock *block,unsigned short cx, unsigned short cy);
void sculptmode_rem_tex(void*,void*);
-void sculptmode_propset_init(PropsetMode mode);
-void sculptmode_propset(const unsigned short event);
void sculptmode_selectbrush_menu(void);
void sculptmode_draw_mesh(int);
void sculpt_paint_brush(char clear);
void sculpt_stroke_draw();
+void sculpt_radialcontrol_start(int mode);
struct BrushData *sculptmode_brush(void);
-float tex_angle(void);
void do_symmetrical_brush_actions(struct EditData *e, short *, short *);
void sculptmode_update_tex(void);
Modified: trunk/blender/source/blender/include/BIF_editparticle.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editparticle.h 2008-01-16 03:02:54 UTC (rev 13256)
+++ trunk/blender/source/blender/include/BIF_editparticle.h 2008-01-16 07:19:21 UTC (rev 13257)
@@ -38,6 +38,7 @@
struct Object;
struct ParticleSystem;
struct ParticleEditSettings;
+struct RadialControl;
/* particle edit mode */
void PE_set_particle_edit(void);
@@ -53,6 +54,7 @@
int PE_minmax(float *min, float *max);
void PE_get_colors(char sel[4], char nosel[4]);
struct ParticleEditSettings *PE_settings(void);
+struct RadialControl **PE_radialcontrol();
/* update calls */
void PE_hide_keys_time(struct ParticleSystem *psys, float cfra);
@@ -83,6 +85,7 @@
void PE_mirror_x(int tagged);
void PE_selectbrush_menu(void);
void PE_remove_doubles(void);
+void PE_radialcontrol_start(const int mode);
/* undo */
void PE_undo_push(char *str);
Added: trunk/blender/source/blender/include/BIF_radialcontrol.h
===================================================================
--- trunk/blender/source/blender/include/BIF_radialcontrol.h (rev 0)
+++ trunk/blender/source/blender/include/BIF_radialcontrol.h 2008-01-16 07:19:21 UTC (rev 13257)
@@ -0,0 +1,62 @@
+/*
+ * $Id: multires.h 13015 2007-12-27 07:27:03Z nicholasbishop $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 by Nicholas Bishop
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef RADIALCONTROL_H
+#define RADIALCONTROL_H
+
+struct NumInput;
+
+#define RADIALCONTROL_NONE 0
+#define RADIALCONTROL_SIZE 1
+#define RADIALCONTROL_STRENGTH 2
+#define RADIALCONTROL_ROTATION 3
+
+typedef void (*RadialControlCallback)(const int, const int);
+
+typedef struct RadialControl {
+ int mode;
+ short origloc[2];
+
+ unsigned int tex;
+
+ int new_value;
+ int original_value;
+ int max_value;
+ RadialControlCallback callback;
+
+ struct NumInput *num;
+} RadialControl;
+
+RadialControl *radialcontrol_start(const int mode, RadialControlCallback callback,
+ const int original_value, const int max_value,
+ const unsigned int tex);
+void radialcontrol_do_events(RadialControl *rc, const unsigned short event);
+void radialcontrol_draw(RadialControl *rc);
+
+#endif
Modified: trunk/blender/source/blender/src/drawview.c
===================================================================
--- trunk/blender/source/blender/src/drawview.c 2008-01-16 03:02:54 UTC (rev 13256)
+++ trunk/blender/source/blender/src/drawview.c 2008-01-16 07:19:21 UTC (rev 13257)
@@ -125,6 +125,7 @@
#include "BIF_mywindow.h"
#include "BIF_poseobject.h"
#include "BIF_previewrender.h"
+#include "BIF_radialcontrol.h"
#include "BIF_resources.h"
#include "BIF_retopo.h"
#include "BIF_screen.h"
@@ -3061,68 +3062,13 @@
/* Draw Sculpt Mode brush */
if(!G.obedit && (G.f & G_SCULPTMODE) && area_is_active_area(v3d->area) && sculpt_session()) {
- PropsetData *pd= sculpt_session()->propset;
- short r1=100, r2=100, r3=100;
- short mouse[2];
+ RadialControl *rc= sculpt_session()->radialcontrol;
if(sculpt_data()->flags & SCULPT_INPUT_SMOOTH)
sculpt_stroke_draw();
- if(pd) {
- if(pd->mode == PropsetSize) {
- r1= sculptmode_brush()->size;
- r2= pd->origsize;
- r3= r1;
- } else if(pd->mode == PropsetStrength) {
- r1= 200 - sculptmode_brush()->strength * 2;
- r2= 200;
- r3= 200;
- } else if(pd->mode == PropsetTexRot) {
- r1= r2= 200;
- r3= 200;
- }
-
- /* Draw brush with texture */
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glBindTexture(GL_TEXTURE_2D, pd->tex);
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- glPushMatrix();
- glTranslatef(pd->origloc[0], pd->origloc[1], 0);
- glRotatef(tex_angle(), 0, 0, 1);
-
- glEnable(GL_TEXTURE_2D);
- glBegin(GL_QUADS);
- glColor4f(0,0,0,1);
- glTexCoord2f(0,0);
- glVertex2f(-r3, -r3);
- glTexCoord2f(1,0);
- glVertex2f(r3, -r3);
- glTexCoord2f(1,1);
- glVertex2f(r3, r3);
- glTexCoord2f(0,1);
- glVertex2f(-r3, r3);
- glEnd();
- glDisable(GL_TEXTURE_2D);
-
- glPopMatrix();
-
- if(r1 != r2)
- fdrawXORcirc(pd->origloc[0], pd->origloc[1], r1);
- fdrawXORcirc(pd->origloc[0], pd->origloc[1], r2);
-
- if(pd->mode == PropsetTexRot) {
- const float ang= pd->origtexrot * (M_PI/180.0f);
- getmouseco_areawin(mouse);
- sdrawXORline(pd->origloc[0], pd->origloc[1],
- pd->origloc[0]+200*cos(ang), pd->origloc[1]+200*sin(ang));
- sdrawXORline(pd->origloc[0], pd->origloc[1], mouse[0], mouse[1]);
- }
- }
+ if(rc)
+ radialcontrol_draw(rc);
else if(sculpt_data()->flags & SCULPT_DRAW_BRUSH) {
short csc[2], car[2];
getmouseco_sc(csc);
@@ -3143,7 +3089,9 @@
ParticleEditSettings *pset = PE_settings();
short c[2];
- if(psys && psys->edit && pset->brushtype>=0){
+ if(*PE_radialcontrol())
+ radialcontrol_draw(*PE_radialcontrol());
+ else if(psys && psys->edit && pset->brushtype>=0) {
getmouseco_areawin(c);
fdrawXORcirc((float)c[0], (float)c[1], (float)pset->brush[pset->brushtype].size);
}
Modified: trunk/blender/source/blender/src/editparticle.c
===================================================================
--- trunk/blender/source/blender/src/editparticle.c 2008-01-16 03:02:54 UTC (rev 13256)
+++ trunk/blender/source/blender/src/editparticle.c 2008-01-16 07:19:21 UTC (rev 13257)
@@ -80,6 +80,7 @@
#include "BIF_interface.h"
#include "BIF_meshtools.h"
#include "BIF_mywindow.h"
+#include "BIF_radialcontrol.h"
#include "BIF_resources.h"
#include "BIF_screen.h"
#include "BIF_space.h"
@@ -1989,6 +1990,46 @@
BIF_undo_push("Remove double particles");
}
+static void PE_radialcontrol_callback(const int mode, const int val)
+{
+ ParticleEditSettings *pset = PE_settings();
+
+ if(pset->brushtype>=0) {
+ ParticleBrushData *brush= &pset->brush[pset->brushtype];
+
+ if(mode == RADIALCONTROL_SIZE)
+ brush->size = val;
+ else if(mode == RADIALCONTROL_STRENGTH)
+ brush->strength = val;
+ }
+
+ (*PE_radialcontrol()) = NULL;
+}
+
+RadialControl **PE_radialcontrol()
+{
+ static RadialControl *rc = NULL;
+ return &rc;
+}
+
+void PE_radialcontrol_start(const int mode)
+{
+ ParticleEditSettings *pset = PE_settings();
+ int orig;
+
+ if(pset->brushtype>=0) {
+ ParticleBrushData *brush= &pset->brush[pset->brushtype];
+
+ if(mode == RADIALCONTROL_SIZE)
+ orig = brush->size;
+ else if(mode == RADIALCONTROL_STRENGTH)
+ orig = brush->strength;
+
+ if(mode != RADIALCONTROL_NONE)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list