Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2007-04-05 16:42:07 +0400
committerMatt Ebb <matt@mke3.net>2007-04-05 16:42:07 +0400
commitbbceedced0ecf1426d90faf5f36136f688853ab6 (patch)
treeded71b41ad8ae8434112e9c7627385dce27b5513 /source/blender/src/sculptmode.c
parent54f57cca0872924f3b9ed3a329ef767365fafcc9 (diff)
* Tablet support fixup
This commit should hopefully fix some of the problems some people were having with tablet support in sculpt mode, and also the problems I made visible with my previous commit related to number field dragging. Now, all the ghost related stuff is tucked away in ghostwinlay.c and a simple Blender API, similar to the existing get_mbut() for example, is provided to access the tablet data. As with the other mouse related data in Blender, the tablet data is cached upon each mouse move or click, in the Window struct. You can now just use: float get_pressure(void); void get_tilt(float *xtilt, float *ytilt); short get_activedevice(void); to get such data from the tablet. Documentation on the returned data is in ghostwinlay.c in the _Window struct definition. Brecht and Nicholas, I've updated the painting and sculpt code and it works just fine here, you may want to give it a check though to make sure I haven't done anything silly.
Diffstat (limited to 'source/blender/src/sculptmode.c')
-rw-r--r--source/blender/src/sculptmode.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c
index 2338765e3c9..8dcfa586631 100644
--- a/source/blender/src/sculptmode.c
+++ b/source/blender/src/sculptmode.c
@@ -395,13 +395,14 @@ char brush_size()
{
const BrushData *b= sculptmode_brush();
float size= b->size;
- const GHOST_TabletData *td= get_tablet_data();
+ float pressure= get_pressure();
+ short activedevice= get_activedevice();
- if(td && sculpt_data()->brush_type!=GRAB_BRUSH) {
+ if(sculpt_data()->brush_type!=GRAB_BRUSH) {
const float size_factor= G.scene->sculptdata.tablet_size / 10.0f;
- if(td->Active==1 || td->Active==2)
+ if(ELEM(activedevice, DEV_STYLUS, DEV_ERASER))
size*= G.scene->sculptdata.tablet_size==0?1:
- (1-size_factor) + td->Pressure*size_factor;
+ (1-size_factor) + pressure*size_factor;
}
return size;
@@ -415,19 +416,17 @@ float brush_strength(EditData *e)
const BrushData* b= sculptmode_brush();
float dir= b->dir==1 ? 1 : -1;
float pressure= 1;
- const GHOST_TabletData *td= get_tablet_data();
+ short activedevice= get_activedevice();
float flip= e->flip ? -1:1;
- if(td) {
- const float strength_factor= G.scene->sculptdata.tablet_strength / 10.0f;
- if(td->Active==1 || td->Active==2)
- pressure= G.scene->sculptdata.tablet_strength==0?1:
- (1-strength_factor) + td->Pressure*strength_factor;
-
- /* Flip direction for eraser */
- if(td->Active==2)
- dir= -dir;
- }
+ const float strength_factor= G.scene->sculptdata.tablet_strength / 10.0f;
+ if(ELEM(activedevice, DEV_STYLUS, DEV_ERASER))
+ pressure= G.scene->sculptdata.tablet_strength==0?1:
+ (1-strength_factor) + get_pressure()*strength_factor;
+
+ /* Flip direction for eraser */
+ if(activedevice==DEV_ERASER)
+ dir= -dir;
switch(G.scene->sculptdata.brush_type){
case DRAW_BRUSH: