- Imagepaint code cleanup:
- Move UVTEXTTOOL variables into global Gip struct (like Gvp for
vertex paint). This will probably be moved into SpaceImage later,
so it is saved with the .blend file.
- Disable tool drawing. a better solution needs to be found.
- Panel button layout is still the same, this will change.
- Removed the NAN_TPT define, it has no use anymore.
This commit is contained in:
@@ -47,6 +47,7 @@ void free_image(struct Image *me);
|
||||
void free_image_buffers(struct Image *ima);
|
||||
struct Image *add_image(char *name);
|
||||
void free_unused_animimages(void);
|
||||
struct Image *new_image(int width, int height, char *name);
|
||||
|
||||
void makepicstring(char *string, int frame);
|
||||
void addImageExtension(char *string);
|
||||
|
||||
@@ -148,6 +148,38 @@ Image *add_image(char *name)
|
||||
return ima;
|
||||
}
|
||||
|
||||
Image *new_image(int width, int height, char *name)
|
||||
{
|
||||
Image *ima;
|
||||
|
||||
ima = alloc_libblock(&G.main->image, ID_IM, name);
|
||||
|
||||
if (ima)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
unsigned char *rect;
|
||||
int x, y;
|
||||
|
||||
strcpy(ima->name, "Untitled");
|
||||
|
||||
ibuf= IMB_allocImBuf(width, height, 24, IB_rect, 0);
|
||||
strcpy(ibuf->name, "Untitled");
|
||||
ima->ibuf= ibuf;
|
||||
|
||||
rect= (unsigned char*)ibuf->rect;
|
||||
for(y=0; y<ibuf->y; y++) {
|
||||
for(x=0; x<ibuf->x; x++, rect+=4) {
|
||||
rect[0]= rect[1]= rect[2]= 0;
|
||||
rect[3]= 255;
|
||||
}
|
||||
}
|
||||
|
||||
ima->ok= 1;
|
||||
}
|
||||
|
||||
return ima;
|
||||
}
|
||||
|
||||
void tag_image_time(Image *ima)
|
||||
{
|
||||
if (ima)
|
||||
|
||||
@@ -44,7 +44,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
extern IMG_BrushPtr IMG_BrushCreate(unsigned int width, unsigned int height, float red, float green, float blue, float alpha);
|
||||
extern IMG_BrushPtr IMG_BrushCreate(unsigned int width, unsigned int height, float *rgba);
|
||||
extern void IMG_BrushDispose(IMG_BrushPtr brush);
|
||||
extern void IMG_BrushSetInnerRaduisRatio(IMG_BrushPtr brush,float aspect);
|
||||
|
||||
@@ -55,10 +55,10 @@ extern void IMG_CanvasDraw(IMG_CanvasPtr canvas, IMG_BrushPtr brush, unsigned
|
||||
extern void IMG_CanvasDrawUV(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float u, float v);
|
||||
extern void IMG_CanvasDrawLine(IMG_CanvasPtr canvas, IMG_BrushPtr brush, unsigned int xStart, unsigned int yStart, unsigned int xEns, unsigned int yEnd);
|
||||
extern void IMG_CanvasDrawLineUV(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart, float vStart, float uEnd, float vEnd);
|
||||
extern void IMG_CanvasDrawLineUVEX(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart, float vStart, float uEnd, float vEnd,char mode);
|
||||
extern void IMG_CanvasSoftenAt(IMG_CanvasPtr canvas,float u, float v, unsigned int size,float alpha, float aspect,char mode);
|
||||
extern void IMG_CanvasFill(IMG_CanvasPtr canvas, float red, float green, float blue, float alpha);
|
||||
extern void IMG_CanvasSmear(IMG_CanvasPtr canvas,float uStart, float vStart, float uEnd, float vEnd, unsigned int size, float alpha, float aspect,char mode);
|
||||
extern void IMG_CanvasDrawLineUVEX(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart, float vStart, float uEnd, float vEnd, int torus);
|
||||
extern void IMG_CanvasSoftenAt(IMG_CanvasPtr canvas,float u, float v, unsigned int size,float alpha, float aspect, int torus);
|
||||
extern void IMG_CanvasFill(IMG_CanvasPtr canvas, float *rgba);
|
||||
extern void IMG_CanvasSmear(IMG_CanvasPtr canvas,float uStart, float vStart, float uEnd, float vEnd, unsigned int size, float alpha, float aspect, int torus);
|
||||
extern void IMG_CanvasCloneAt(IMG_CanvasPtr canvas,IMG_CanvasPtr other,float u,float v,float cu,float cv,int size,float alpha,float aspect);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -37,12 +37,12 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
IMG_BrushPtr IMG_BrushCreate(unsigned int w, unsigned int h, float r, float g, float b, float a)
|
||||
IMG_BrushPtr IMG_BrushCreate(unsigned int w, unsigned int h, float *rgba)
|
||||
{
|
||||
IMG_BrushPtr brush = 0;
|
||||
try {
|
||||
IMG_ColorRGB c (r, g, b);
|
||||
brush = new IMG_BrushRGBA32 (w, h, c, a);
|
||||
IMG_ColorRGB c (rgba[0], rgba[1], rgba[2]);
|
||||
brush = new IMG_BrushRGBA32 (w, h, c, rgba[3]);
|
||||
}
|
||||
catch (...) {
|
||||
brush = 0;
|
||||
@@ -50,7 +50,6 @@ IMG_BrushPtr IMG_BrushCreate(unsigned int w, unsigned int h, float r, float g, f
|
||||
return brush;
|
||||
}
|
||||
|
||||
|
||||
void IMG_BrushDispose(IMG_BrushPtr brush)
|
||||
{
|
||||
if (brush) {
|
||||
@@ -75,8 +74,6 @@ void IMG_BrushSetInnerRaduisRatio(IMG_BrushPtr brush,float aspect)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
IMG_CanvasPtr IMG_CanvasCreate(unsigned int w, unsigned int h)
|
||||
{
|
||||
IMG_CanvasPtr canvas = 0;
|
||||
@@ -89,7 +86,6 @@ IMG_CanvasPtr IMG_CanvasCreate(unsigned int w, unsigned int h)
|
||||
return canvas;
|
||||
}
|
||||
|
||||
|
||||
IMG_CanvasPtr IMG_CanvasCreateFromPtr(void* imagePtr, unsigned int w, unsigned int h, size_t rowBytes)
|
||||
{
|
||||
IMG_CanvasPtr canvas = 0;
|
||||
@@ -139,28 +135,28 @@ void IMG_CanvasDrawLineUV(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart
|
||||
((IMG_CanvasRGBA32*)canvas)->blendPixmap(uStart, vStart, uEnd, vEnd, *((IMG_BrushRGBA32*)brush));
|
||||
}
|
||||
|
||||
void IMG_CanvasDrawLineUVEX(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart, float vStart, float uEnd, float vEnd,char mode)
|
||||
void IMG_CanvasDrawLineUVEX(IMG_CanvasPtr canvas, IMG_BrushPtr brush, float uStart, float vStart, float uEnd, float vEnd, int torus)
|
||||
{
|
||||
if (!(canvas && brush)) return;
|
||||
((IMG_CanvasRGBA32*)canvas)->blendPixmap(uStart, vStart, uEnd, vEnd, *((IMG_BrushRGBA32*)brush),mode);
|
||||
((IMG_CanvasRGBA32*)canvas)->blendPixmap(uStart, vStart, uEnd, vEnd, *((IMG_BrushRGBA32*)brush), torus);
|
||||
}
|
||||
|
||||
void IMG_CanvasSoftenAt(IMG_CanvasPtr canvas,float u, float v, unsigned int size,float alpha, float aspect,char mode)
|
||||
void IMG_CanvasSoftenAt(IMG_CanvasPtr canvas,float u, float v, unsigned int size,float alpha, float aspect, int torus)
|
||||
{
|
||||
((IMG_CanvasRGBA32*)canvas)->SoftenAt(u,v,(TUns32)size,alpha,aspect,mode);
|
||||
((IMG_CanvasRGBA32*)canvas)->SoftenAt(u, v, (TUns32)size, alpha, aspect, torus);
|
||||
}
|
||||
|
||||
void IMG_CanvasFill(IMG_CanvasPtr canvas,float red, float green, float blue, float alpha)
|
||||
void IMG_CanvasFill(IMG_CanvasPtr canvas, float *rgba)
|
||||
{
|
||||
IMG_ColorRGB c (red, green, blue);
|
||||
IMG_ColorRGB c (rgba[0], rgba[1], rgba[2]);
|
||||
IMG_Rect R (0, 0, ((IMG_CanvasRGBA32*)canvas)->getWidth(),
|
||||
((IMG_CanvasRGBA32*)canvas)->getHeight()); // Bounds of this pixmap
|
||||
((IMG_CanvasRGBA32*)canvas)->fillRect(R,c);
|
||||
((IMG_CanvasRGBA32*)canvas)->fillRect(R, c);
|
||||
}
|
||||
|
||||
void IMG_CanvasSmear(IMG_CanvasPtr canvas,float uStart, float vStart, float uEnd, float vEnd, unsigned int size, float alpha, float aspect,char mode)
|
||||
void IMG_CanvasSmear(IMG_CanvasPtr canvas,float uStart, float vStart, float uEnd, float vEnd, unsigned int size, float alpha, float aspect, int torus)
|
||||
{
|
||||
((IMG_CanvasRGBA32*)canvas)->Smear(uStart,vStart,uEnd,vEnd,size,alpha,aspect,mode);
|
||||
((IMG_CanvasRGBA32*)canvas)->Smear(uStart, vStart, uEnd, vEnd, size, alpha, aspect, torus);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -48,18 +48,18 @@ IMG_CanvasRGBA32::IMG_CanvasRGBA32(void* image, TUns32 width, TUns32 height, TUn
|
||||
|
||||
void IMG_CanvasRGBA32::blendPixmap(
|
||||
TUns32 xStart, TUns32 yStart, TUns32 xEnd, TUns32 yEnd,
|
||||
const IMG_PixmapRGBA32& pixmap,char mode)
|
||||
const IMG_PixmapRGBA32& pixmap, bool torus)
|
||||
{
|
||||
// Determine visibility of the line
|
||||
IMG_Line l (xStart, yStart, xEnd, yEnd); // Line used for blending
|
||||
IMG_Rect bnds (0, 0, m_width, m_height); // Bounds of this pixmap
|
||||
TVisibility v = bnds.getVisibility(l);
|
||||
if (mode == 'c'){
|
||||
if (v == kNotVisible) return;
|
||||
if (v == kPartiallyVisible) {
|
||||
if (!torus) {
|
||||
if (v == kNotVisible)
|
||||
return;
|
||||
if (v == kPartiallyVisible)
|
||||
bnds.clip(l);
|
||||
}
|
||||
}
|
||||
|
||||
float numSteps = (((float)l.getLength()) / ((float)pixmap.getWidth() / 4));
|
||||
//numSteps *= 4;
|
||||
@@ -68,12 +68,10 @@ void IMG_CanvasRGBA32::blendPixmap(
|
||||
TInt32 x, y;
|
||||
for (TUns32 s = 0; s < numSteps; s++) {
|
||||
l.getPoint(step, x, y);
|
||||
if (mode == 'c') {
|
||||
if (torus)
|
||||
IMG_PixmapRGBA32::blendPixmapTorus((TUns32)x, (TUns32)y, pixmap);
|
||||
else
|
||||
IMG_PixmapRGBA32::blendPixmap((TUns32)x, (TUns32)y, pixmap);
|
||||
}
|
||||
else {
|
||||
if (mode == 't') IMG_PixmapRGBA32::blendPixmapTorus((TUns32)x, (TUns32)y, pixmap);
|
||||
}
|
||||
step += stepSize;
|
||||
}
|
||||
}
|
||||
@@ -81,16 +79,16 @@ void IMG_CanvasRGBA32::blendPixmap(
|
||||
|
||||
void IMG_CanvasRGBA32::blendPixmap(
|
||||
float uStart, float vStart, float uEnd, float vEnd,
|
||||
const IMG_PixmapRGBA32& pixmap, char mode)
|
||||
const IMG_PixmapRGBA32& pixmap, bool torus)
|
||||
{
|
||||
TUns32 xStart, yStart, xEnd, yEnd;
|
||||
getPixelAddress(uStart, vStart, xStart, yStart);
|
||||
getPixelAddress(uEnd, vEnd, xEnd, yEnd);
|
||||
blendPixmap(xStart, yStart, xEnd, yEnd, pixmap,mode);
|
||||
blendPixmap(xStart, yStart, xEnd, yEnd, pixmap, torus);
|
||||
}
|
||||
|
||||
|
||||
void IMG_CanvasRGBA32::SoftenAt(float u, float v, TUns32 size, float alpha, float aspect,char mode)
|
||||
void IMG_CanvasRGBA32::SoftenAt(float u, float v, TUns32 size, float alpha, float aspect, bool torus)
|
||||
{
|
||||
IMG_BrushRGBA32* brush = 0;
|
||||
int flag=0;
|
||||
@@ -116,7 +114,7 @@ void IMG_CanvasRGBA32::SoftenAt(float u, float v, TUns32 size, float alpha, floa
|
||||
getPixelAddress(u, v, x, y);
|
||||
xx = x - size/2;
|
||||
yy = y - size/2;
|
||||
if(mode == 't') flag = 1;
|
||||
if(torus) flag = 1;
|
||||
|
||||
/* now modify brush */
|
||||
for (int i= 0 ; i<(int)size;i++){
|
||||
@@ -125,11 +123,11 @@ void IMG_CanvasRGBA32::SoftenAt(float u, float v, TUns32 size, float alpha, floa
|
||||
float sR,sG,sB,sA;
|
||||
float cR,cG,cB=0.0;
|
||||
|
||||
if(mode == 't')
|
||||
if (torus)
|
||||
IMG_PixmapRGBA32::getRGBAatTorus(xx+i,yy+j ,&cR,&cG,&cB,0);
|
||||
|
||||
else
|
||||
else
|
||||
IMG_PixmapRGBA32::getRGBAat(xx+i,yy+j ,&cR,&cG,&cB,0);
|
||||
|
||||
int ccount = 1;
|
||||
/*
|
||||
cR += 7.0*cR;
|
||||
@@ -160,10 +158,11 @@ add_if_in(xx+i-1,yy+j-1,cR,cG,cB,ccount,flag);
|
||||
}
|
||||
|
||||
/* apply */
|
||||
if(mode == 't')
|
||||
if (torus)
|
||||
IMG_PixmapRGBA32::blendPixmapTorus(x, y, *brush);
|
||||
else
|
||||
else
|
||||
IMG_PixmapRGBA32::blendPixmap(x, y, *brush);
|
||||
|
||||
/* done clean up */
|
||||
if (brush) {
|
||||
delete ((IMG_BrushRGBA32*)brush);
|
||||
@@ -261,24 +260,25 @@ IMG_BrushRGBA32* IMG_CanvasRGBA32::LiftBrush(float u, float v, TUns32 size, floa
|
||||
return(brush);
|
||||
}
|
||||
|
||||
void IMG_CanvasRGBA32::Smear(float uStart, float vStart, float uEnd, float vEnd, TUns32 size, float alpha, float aspect,char mode)
|
||||
void IMG_CanvasRGBA32::Smear(float uStart, float vStart, float uEnd, float vEnd, TUns32 size, float alpha, float aspect, bool torus)
|
||||
{
|
||||
IMG_BrushRGBA32* brush = NULL;
|
||||
float du,dv;
|
||||
du = uEnd - uStart;
|
||||
dv = vEnd - vStart;
|
||||
|
||||
try {
|
||||
brush = LiftBrush(uStart-du,vStart-dv,size,alpha,aspect,1);
|
||||
brush = LiftBrush(uStart-du, vStart-dv, size, alpha, aspect, 1);
|
||||
}
|
||||
catch (...) {
|
||||
/* no brush , no fun ! */
|
||||
return;
|
||||
}
|
||||
if (brush){
|
||||
blendPixmap(uStart,vStart,uEnd,vEnd,*brush,mode);
|
||||
|
||||
if (brush) {
|
||||
blendPixmap(uStart, vStart, uEnd, vEnd, *brush, torus);
|
||||
delete(brush);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void IMG_CanvasRGBA32::CloneAt(IMG_CanvasRGBA32* other,float u,float v,float cu,float cv,TUns32 size,float alpha,float aspect)
|
||||
|
||||
@@ -46,12 +46,12 @@
|
||||
|
||||
class IMG_CanvasRGBA32 : public IMG_PixmapRGBA32 {
|
||||
public:
|
||||
int add_if_in(int x, int y,float &R,float &G,float &B, int &count, short flags);
|
||||
void Smear(float uStart, float vStart, float uEnd, float vEnd ,TUns32 size, float alpha, float aspect,char mode);
|
||||
int add_if_in(int x, int y, float &R, float &G, float &B, int &count, short flags);
|
||||
void Smear(float uStart, float vStart, float uEnd, float vEnd ,TUns32 size, float alpha, float aspect, bool torus=false);
|
||||
IMG_BrushRGBA32* LiftBrush(float u, float v, TUns32 size, float alpha, float aspect, short flags );
|
||||
IMG_BrushRGBA32* LiftBrush(TUns32 x, TUns32 y, TUns32 size, float alpha, float aspect, short flags);
|
||||
void SoftenAt(float u,float v,TUns32 size,float alpha,float aspect,char mode);
|
||||
void CloneAt(IMG_CanvasRGBA32* other,float u,float v,float cu,float cv,TUns32 size,float alpha,float aspect);
|
||||
void SoftenAt(float u, float v, TUns32 size, float alpha, float aspect, bool torus=false);
|
||||
void CloneAt(IMG_CanvasRGBA32* other, float u, float v, float cu, float cv, TUns32 size, float alpha, float aspect);
|
||||
/**
|
||||
* Constructor.
|
||||
* @throw <IMG_MemPtr::Size> when an invalid width and/or height is passed.
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
* @param y y-coordinate of the center location of the image.
|
||||
* @param pixmap the pixmap to blend
|
||||
*/
|
||||
virtual void blendPixmap(TUns32 xStart, TUns32 yStart, TUns32 xEnd, TUns32 yEnd, const IMG_PixmapRGBA32& pixmap,char mode = 'c');
|
||||
virtual void blendPixmap(TUns32 xStart, TUns32 yStart, TUns32 xEnd, TUns32 yEnd, const IMG_PixmapRGBA32& pixmap, bool torus=false);
|
||||
|
||||
/**
|
||||
* Blends a pixmap into this pixmap over a line in (u,v) coordinates.
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
* @param v v-coordinate of the center location of the image.
|
||||
* @param pixmap the pixmap to blend
|
||||
*/
|
||||
virtual void blendPixmap(float uStart, float vStart, float uEnd, float vEnd, const IMG_PixmapRGBA32& pixmap,char mode = 'c');
|
||||
virtual void blendPixmap(float uStart, float vStart, float uEnd, float vEnd, const IMG_PixmapRGBA32& pixmap, bool torus=false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||
@@ -28,14 +28,52 @@
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
* Texture paint tool file dependency fix (and kludge)
|
||||
*/
|
||||
|
||||
#ifndef TPT_DEPENDKLUDGE_H
|
||||
#define TPT_DEPENDKLUDGE_H
|
||||
#ifndef BDR_IMAGEPAINT_H
|
||||
#define BDR_IMAGEPAINT_H
|
||||
|
||||
#define NAN_TPT
|
||||
//#undef NAN_TPT
|
||||
/* ImagePaint.current */
|
||||
#define IMAGEPAINT_BRUSH 0
|
||||
#define IMAGEPAINT_AIRBRUSH 1
|
||||
#define IMAGEPAINT_SOFTEN 2
|
||||
#define IMAGEPAINT_AUX1 3
|
||||
#define IMAGEPAINT_AUX2 4
|
||||
#define IMAGEPAINT_SMEAR 5
|
||||
#define IMAGEPAINT_CLONE 6
|
||||
#define IMAGEPAINT_TOOL_SIZE 7
|
||||
|
||||
#endif /* TPT_DEPENDKLUDGE_H */
|
||||
/* ImagePaint.flag */
|
||||
#define IMAGEPAINT_DRAW_TOOL 1
|
||||
#define IMAGEPAINT_DRAW_TOOL_DRAWING 2
|
||||
#define IMAGEPAINT_DRAWING 4
|
||||
#define IMAGEPAINT_TORUS 8
|
||||
#define IMAGEPAINT_TIMED 16
|
||||
|
||||
typedef struct ImagePaintTool {
|
||||
float rgba[4];
|
||||
int size;
|
||||
float innerradius;
|
||||
float timing;
|
||||
} ImagePaintTool;
|
||||
|
||||
typedef struct ImagePaint {
|
||||
struct Clone {
|
||||
Image *image;
|
||||
float offset[2];
|
||||
float alpha;
|
||||
} clone;
|
||||
|
||||
ImagePaintTool tool[IMAGEPAINT_TOOL_SIZE];
|
||||
|
||||
short flag, current;
|
||||
} ImagePaint;
|
||||
|
||||
extern struct ImagePaint Gip;
|
||||
|
||||
void imagepaint_redraw_tool(void);
|
||||
void imagepaint_paint(short mousebutton);
|
||||
void imagepaint_pick(short mousebutton);
|
||||
|
||||
#endif /* BDR_IMAGEPAINT_H */
|
||||
|
||||
@@ -85,14 +85,5 @@ typedef struct VPaint {
|
||||
short mode, flag;
|
||||
} VPaint;
|
||||
|
||||
/*BM_TEXTUREPAINT */
|
||||
typedef struct BrushUIdata {
|
||||
float r, g, b, a;
|
||||
float size;
|
||||
float softradius;
|
||||
float brushtiming;
|
||||
} BrushUIdata;
|
||||
#define PAINTPANELMESSAGEEATER 9000
|
||||
|
||||
#endif /* BSE_TRANS_TYPES_H */
|
||||
|
||||
|
||||
@@ -301,6 +301,9 @@
|
||||
#define B_SIMAGEPAINTTOOL 362
|
||||
#define B_SIMAPACKIMA 363
|
||||
#define B_SIMAGESAVE 364
|
||||
#define B_SIMACLONEBROWSE 365
|
||||
#define B_SIMACLONEDELETE 366
|
||||
#define B_SIMABRUSHCHANGE 367
|
||||
|
||||
/* BUTS: 400 */
|
||||
#define B_BUTSHOME 401
|
||||
|
||||
@@ -215,11 +215,10 @@ typedef struct SpaceImage {
|
||||
|
||||
struct Image *image;
|
||||
float zoom;
|
||||
short mode, pin;
|
||||
short mode, menunr;
|
||||
short imanr, curtile;
|
||||
float xof, yof;
|
||||
short flag, lock;
|
||||
|
||||
} SpaceImage;
|
||||
|
||||
typedef struct SpaceNla{
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
#include "BDR_editface.h"
|
||||
#include "BDR_drawobject.h"
|
||||
#include "BDR_drawmesh.h"
|
||||
#include "BDR_imagepaint.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_mywindow.h"
|
||||
@@ -90,65 +91,53 @@
|
||||
#include "mydevice.h"
|
||||
#include "blendef.h"
|
||||
#include "butspace.h" // event codes
|
||||
// #ifdef BM_TEXTUREPAINT
|
||||
|
||||
extern Image* UVTEXTTOOL_cloneimage;
|
||||
extern short UVTEXTTOOL_imanr;
|
||||
extern short UVTEXTTOOL_POS[];
|
||||
extern float UVTEXTTOOL_RAD[];
|
||||
extern short UVTEXTTOOL_SHAPE;
|
||||
extern short UVTEXTTOOL_INDEX;
|
||||
extern short UVTEXTTOOL_uiflags;
|
||||
extern float UVTEXTTOOL_cloneoffx;
|
||||
extern float UVTEXTTOOL_cloneoffy;
|
||||
extern float UVTEXTTOOL_clonealpha;
|
||||
extern BrushUIdata UVTEXTTOOL_DATA[];
|
||||
|
||||
|
||||
|
||||
void setcloneimagealpha(char a,unsigned int *rect)
|
||||
static unsigned char *alloc_alpha_clone_image(int *width, int *height)
|
||||
{
|
||||
unsigned int size;
|
||||
char *cp= (char *)rect;
|
||||
if (UVTEXTTOOL_cloneimage == NULL) return;
|
||||
if (rect == NULL) return;
|
||||
unsigned int size, alpha;
|
||||
unsigned char *rect, *cp;
|
||||
|
||||
if(!Gip.clone.image)
|
||||
return NULL;
|
||||
|
||||
if(!Gip.clone.image->ibuf)
|
||||
load_image(Gip.clone.image, IB_rect, G.sce, G.scene->r.cfra);
|
||||
|
||||
if(!Gip.clone.image->ibuf || !Gip.clone.image->ibuf->rect)
|
||||
return NULL;
|
||||
|
||||
rect= MEM_dupallocN(Gip.clone.image->ibuf->rect);
|
||||
|
||||
if(!rect)
|
||||
return NULL;
|
||||
|
||||
*width= Gip.clone.image->ibuf->x;
|
||||
*height= Gip.clone.image->ibuf->y;
|
||||
|
||||
size= (*width)*(*height);
|
||||
alpha= (unsigned char)255*Gip.clone.alpha;
|
||||
cp= rect;
|
||||
|
||||
size = UVTEXTTOOL_cloneimage->ibuf->x*UVTEXTTOOL_cloneimage->ibuf->y;
|
||||
while(size-- > 0) {
|
||||
cp[3]= a;
|
||||
cp+= 4;
|
||||
cp[3]= alpha;
|
||||
cp += 4;
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
/* resolve UVTEXTTOOL_imanr to set UVTEXTTOOL_cloneimage pointer */
|
||||
void setcloneimage()
|
||||
static void setcloneimage()
|
||||
{
|
||||
int nr;
|
||||
ID *id, *idtest;
|
||||
UVTEXTTOOL_cloneimage = NULL;
|
||||
if (UVTEXTTOOL_imanr){
|
||||
nr= 1;
|
||||
id= (ID *)UVTEXTTOOL_cloneimage;
|
||||
idtest= G.main->image.first;
|
||||
while(idtest) {
|
||||
if(nr==UVTEXTTOOL_imanr) {
|
||||
break;
|
||||
}
|
||||
nr++;
|
||||
idtest= idtest->next;
|
||||
}
|
||||
if(G.sima->menunr > 0) {
|
||||
Image *ima= (Image*)BLI_findlink(&G.main->image, G.sima->menunr-1);
|
||||
|
||||
if(idtest==0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(idtest!=id) {
|
||||
UVTEXTTOOL_cloneimage= (Image *)idtest;
|
||||
if(ima) {
|
||||
Gip.clone.image= ima;
|
||||
Gip.clone.offset[0]= Gip.clone.offset[0]= 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the fields of the View2D member of the SpaceImage struct
|
||||
* This routine can be called in two modes:
|
||||
@@ -620,14 +609,30 @@ static void draw_image_view_icon(void)
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
// #ifdef BM_TEXTUREPAINT
|
||||
|
||||
static void draw_image_view_tool(void)
|
||||
{
|
||||
if(UVTEXTTOOL_SHAPE) {
|
||||
fdrawXORcirc(UVTEXTTOOL_POS[0],UVTEXTTOOL_POS[1],UVTEXTTOOL_RAD[0]);
|
||||
if ( UVTEXTTOOL_RAD[0] != UVTEXTTOOL_RAD[1])
|
||||
fdrawXORcirc(UVTEXTTOOL_POS[0],UVTEXTTOOL_POS[1],UVTEXTTOOL_RAD[1]);
|
||||
ImagePaintTool *tool = &Gip.tool[Gip.current];
|
||||
short mval[2];
|
||||
float radius;
|
||||
int draw= 0;
|
||||
|
||||
if(Gip.flag & IMAGEPAINT_DRAWING) {
|
||||
if(Gip.flag & IMAGEPAINT_DRAW_TOOL_DRAWING)
|
||||
draw= 1;
|
||||
}
|
||||
else if(Gip.flag & IMAGEPAINT_DRAW_TOOL)
|
||||
draw= 1;
|
||||
|
||||
if(draw) {
|
||||
getmouseco_areawin(mval);
|
||||
|
||||
radius= tool->size*G.sima->zoom/2;
|
||||
fdrawXORcirc(mval[0], mval[1], radius);
|
||||
|
||||
if (tool->innerradius != 1.0) {
|
||||
radius *= tool->innerradius;
|
||||
fdrawXORcirc(mval[0], mval[1], radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -796,23 +801,20 @@ void do_imagebuts(unsigned short event)
|
||||
}
|
||||
}
|
||||
break;
|
||||
// #ifdef BM_TEXTUREPAINT
|
||||
case B_SIMABROWSE:
|
||||
|
||||
case B_SIMACLONEBROWSE:
|
||||
setcloneimage();
|
||||
UVTEXTTOOL_cloneoffx = 0.0;
|
||||
UVTEXTTOOL_cloneoffy = 0.0;
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
image_changed(G.sima, 0);
|
||||
break;
|
||||
|
||||
case B_IMAGEDELETE:
|
||||
UVTEXTTOOL_cloneimage=NULL;
|
||||
UVTEXTTOOL_imanr = -2;
|
||||
case B_SIMACLONEDELETE:
|
||||
Gip.clone.image= NULL;
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
image_changed(G.sima, 0);
|
||||
break;
|
||||
|
||||
|
||||
case B_SIMABRUSHCHANGE:
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -849,65 +851,53 @@ static void image_panel_properties(short cntrl) // IMAGE_HANDLER_PROPERTIES
|
||||
image_editvertex_buts(block);
|
||||
}
|
||||
|
||||
// #ifdef BM_TEXTUREPAINT
|
||||
static void image_panel_paint(short cntrl) // IMAGE_HANDLER_PROPERTIES
|
||||
{
|
||||
BrushUIdata *data = NULL;
|
||||
ImagePaintTool *tool= &Gip.tool[Gip.current];
|
||||
uiBlock *block;
|
||||
ID *id;
|
||||
|
||||
data = &UVTEXTTOOL_DATA[UVTEXTTOOL_INDEX];
|
||||
if (!data) return;
|
||||
block= uiNewBlock(&curarea->uiblocks, "image_panel_paint", UI_EMBOSS, UI_HELV, curarea->win);
|
||||
uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
|
||||
uiSetPanelHandler(IMAGE_HANDLER_PAINT); // for close and esc
|
||||
if(uiNewPanel(curarea, block, "Image Paint", "Image", 10, 230, 318, 204)==0)
|
||||
return;
|
||||
|
||||
/* Having that nice color picker we won't need that
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, NUMSLI, 0, "R ", 979,160,194,19, &data->r, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of red used for painting");
|
||||
uiDefButF(block, NUMSLI, 0, "G ", 979,140,194,19, &data->g, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of green used for painting");
|
||||
uiDefButF(block, NUMSLI, 0, "B ", 979,120,194,19, &data->b, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of blue used for painting");
|
||||
uiBlockEndAlign(block);
|
||||
*/
|
||||
// uiDefButF(block, COL, B_VPCOLSLI, "", 979,160,230,19, &(data->r), 0, 0, 0, 0, "");
|
||||
uiDefButF(block, COL, B_VPCOLSLI, "", 979,160,230,19, tool->rgba, 0, 0, 0, 0, "");
|
||||
uiDefButF(block, NUMSLI, 0, "Opacity ", 979,140,230,19, tool->rgba+3, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
|
||||
uiDefButI(block, NUMSLI, 0, "Size ", 979,120,230,19, &tool->size, 2, 64, 0, 0, "The size of the brush");
|
||||
uiDefButF(block, NUMSLI, 0, "Fall ", 979,100,230,19, &tool->innerradius, 0.0, 1.0, 0, 0, "The fall off radius of the brush");
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, COL, B_VPCOLSLI, "", 979,160,230,19, &(data->r), 0, 0, 0, 0, "");
|
||||
uiDefButF(block, NUMSLI, 0, "Opacity ", 979,140,230,19, &data->a, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
|
||||
uiDefButF(block, NUMSLI, 0, "Size ", 979,120,230,19, &data->size, 2.0, 64.0, 0, 0, "The size of the brush");
|
||||
uiDefButF(block, NUMSLI, 0, "Fall ", 979,100,230,19, &data->softradius, 0.0, 1.0, 0, 0, "The fall off radius of the brush");
|
||||
if((UVTEXTTOOL_INDEX ==0) || (UVTEXTTOOL_INDEX ==5) ){ /* brush has no flow */
|
||||
uiDefButF(block, NUMSLI, 0, "Stepsize ", 979,80,230,19, &data->brushtiming, 1.0, 100.0, 0, 0, "Repeating Paint On %of Brush diameter");
|
||||
}
|
||||
else { /* but stepsize */
|
||||
uiDefButF(block, NUMSLI, 0, "Flow ", 979,80,230,19, &data->brushtiming, 1.0, 100.0, 0, 0, "Paint Flow for Air Brush");
|
||||
}
|
||||
if(Gip.current == IMAGEPAINT_BRUSH || Gip.current == IMAGEPAINT_SMEAR)
|
||||
uiDefButF(block, NUMSLI, 0, "Stepsize ",979,80,230,19, &tool->timing, 1.0, 100.0, 0, 0, "Repeating Paint On %of Brush diameter");
|
||||
else
|
||||
uiDefButF(block, NUMSLI, 0, "Flow ", 979,80,230,19, &tool->timing, 1.0, 100.0, 0, 0, "Paint Flow for Air Brush");
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
/* FLOATPANELMESSAGEEATER catching LMB on the panel buttons */
|
||||
/* TODO: FLOATPANELMESSAGEEATER catching LMB on the panel buttons */
|
||||
/* so LMB does not "GO" through the floating panel */
|
||||
uiDefButS(block,ROW, PAINTPANELMESSAGEEATER ,"Brush",890,160,80,19,&UVTEXTTOOL_INDEX, 7.0, 0.0, 0, 0, "Brush");
|
||||
uiDefButS(block,ROW, PAINTPANELMESSAGEEATER ,"AirBrush" ,890,140,80,19,&UVTEXTTOOL_INDEX, 7.0, 1.0, 0, 0, "AirBrush");
|
||||
uiDefButS(block,ROW, PAINTPANELMESSAGEEATER ,"Soften" ,890,120,80,19,&UVTEXTTOOL_INDEX, 7.0, 2.0, 0, 0, "Soften");
|
||||
uiDefButS(block,ROW, PAINTPANELMESSAGEEATER ,"Aux AB1" ,890,100,80,19,&UVTEXTTOOL_INDEX, 7.0, 3.0, 0, 0, "Aux Air Brush1");
|
||||
uiDefButS(block,ROW, PAINTPANELMESSAGEEATER ,"Aux AB2" ,890,80,80,19,&UVTEXTTOOL_INDEX, 7.0, 4.0, 0, 0, "Aux Air Brush2");
|
||||
uiDefButS(block,ROW, PAINTPANELMESSAGEEATER ,"Smear " ,890,60,80,19,&UVTEXTTOOL_INDEX, 7.0, 5.0, 0, 0, "Smear");
|
||||
uiDefButS(block,ROW, PAINTPANELMESSAGEEATER ,"Clone " ,890,40,80,19,&UVTEXTTOOL_INDEX, 7.0, 6.0, 0, 0, "Clone Brush / use RMB to drag source image");
|
||||
uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Brush", 890,160,80,19, &Gip.current, 7.0, IMAGEPAINT_BRUSH, 0, 0, "Brush");
|
||||
uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "AirBrush", 890,140,80,19, &Gip.current, 7.0, IMAGEPAINT_AIRBRUSH, 0, 0, "AirBrush");
|
||||
uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Soften", 890,120,80,19, &Gip.current, 7.0, IMAGEPAINT_SOFTEN, 0, 0, "Soften");
|
||||
uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Aux AB1", 890,100,80,19, &Gip.current, 7.0, IMAGEPAINT_AUX1, 0, 0, "Auxiliary Air Brush1");
|
||||
uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Aux AB2", 890,80,80,19, &Gip.current, 7.0, IMAGEPAINT_AUX2, 0, 0, "Auxiliary Air Brush2");
|
||||
uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Smear", 890,60,80,19, &Gip.current, 7.0, IMAGEPAINT_SMEAR, 0, 0, "Smear");
|
||||
uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Clone", 890,40,80,19, &Gip.current, 7.0, IMAGEPAINT_CLONE, 0, 0, "Clone Brush / use RMB to drag source image");
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
setcloneimage();
|
||||
uiBlockBeginAlign(block);
|
||||
std_libbuttons(block, 979, 40, 0, NULL, B_SIMABROWSE, (ID *)UVTEXTTOOL_cloneimage , 0,&UVTEXTTOOL_imanr, 0, 0, B_IMAGEDELETE, 0, 0);
|
||||
uiDefButF(block, NUMSLI, 0, "B ",979,20,230,19,&UVTEXTTOOL_clonealpha , 0.0, 1.0, 0, 0, "Blend clone image");
|
||||
id= (ID*)Gip.clone.image;
|
||||
std_libbuttons(block, 979, 40, 0, NULL, B_SIMACLONEBROWSE, id, 0, &G.sima->menunr, 0, 0, B_SIMACLONEDELETE, 0, 0);
|
||||
uiDefButF(block, NUMSLI, 0, "B ",979,20,230,19, &Gip.clone.alpha , 0.0, 1.0, 0, 0, "Blend clone image");
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
// uiDefButF(block, NUMSLI, 0, "B", 1100,1,100,19,&UVTEXTTOOL_clonealpha , 0.0, 1.0, 0, 0, "Blend clone image");
|
||||
uiDefButS(block, TOG|BIT|0, 9999, "TD",890,1,50,19,&UVTEXTTOOL_uiflags, 0, 0, 0, 0, "Enables tool shape while drawing");
|
||||
uiDefButS(block, TOG|BIT|1, 9999, "TP",940,1,50,19,&UVTEXTTOOL_uiflags, 0, 0, 0, 0, "Enables tool shape while not drawing");
|
||||
uiDefButS(block, TOG|BIT|2, 9999, "Torus",990,1,50,19,&UVTEXTTOOL_uiflags, 0, 0, 0, 0, "Enables torus wrapping");
|
||||
|
||||
#if 0
|
||||
uiDefButBitS(block, TOG|BIT, IMAGEPAINT_DRAW_TOOL_DRAWING, B_SIMABRUSHCHANGE, "TD", 890,1,50,19, &Gip.flag, 0, 0, 0, 0, "Enables tool shape while drawing");
|
||||
uiDefButBitS(block, TOG|BIT, IMAGEPAINT_DRAW_TOOL, B_SIMABRUSHCHANGE, "TP", 940,1,50,19, &Gip.flag, 0, 0, 0, 0, "Enables tool shape while not drawing");
|
||||
#endif
|
||||
uiDefButBitS(block, TOG|BIT, IMAGEPAINT_TORUS, B_SIMABRUSHCHANGE, "Wrap", 890,1,50,19, &Gip.flag, 0, 0, 0, 0, "Enables torus wrapping");
|
||||
}
|
||||
|
||||
static void image_blockhandlers(ScrArea *sa)
|
||||
@@ -1043,37 +1033,28 @@ void drawimagespace(ScrArea *sa, void *spacedata)
|
||||
else
|
||||
glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->rect);
|
||||
|
||||
// #ifdef BM_TEXTUREPAINT
|
||||
setcloneimage();
|
||||
if (UVTEXTTOOL_cloneimage){
|
||||
unsigned int* clonedrect=NULL;
|
||||
if(UVTEXTTOOL_cloneimage->ibuf==0) {
|
||||
load_image(UVTEXTTOOL_cloneimage, IB_rect, G.sce, G.scene->r.cfra);
|
||||
}
|
||||
if (UVTEXTTOOL_cloneimage->ibuf){ /* full paranoia check */
|
||||
if (UVTEXTTOOL_cloneimage->ibuf->rect){
|
||||
/* make a copy of image data so we can modify alpha for drawing */
|
||||
/* ok this is kind of brute force, since it copies all the time */
|
||||
/* but keeps code simple .. no need for globals etc.. */
|
||||
/* and is save if global UVTEXTTOOL_cloneimage is changed to
|
||||
something 2d space specific */
|
||||
clonedrect= MEM_dupallocN(UVTEXTTOOL_cloneimage->ibuf->rect);
|
||||
}
|
||||
if (clonedrect){
|
||||
int offx,offy;
|
||||
offx = G.sima->zoom*ibuf->x * + UVTEXTTOOL_cloneoffx;
|
||||
offy = G.sima->zoom*ibuf->y * + UVTEXTTOOL_cloneoffy;
|
||||
setcloneimagealpha(255*UVTEXTTOOL_clonealpha,clonedrect);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
if(Gip.current == IMAGEPAINT_CLONE) {
|
||||
int w, h;
|
||||
unsigned char *clonerect;
|
||||
|
||||
/* this is not very efficient, but glDrawPixels doesn't allow
|
||||
drawing with alpha */
|
||||
clonerect= alloc_alpha_clone_image(&w, &h);
|
||||
|
||||
if(clonerect) {
|
||||
int offx, offy;
|
||||
offx = G.sima->zoom*ibuf->x * + Gip.clone.offset[0];
|
||||
offy = G.sima->zoom*ibuf->y * + Gip.clone.offset[1];
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glaDrawPixelsSafe(x1+offx, y1+offy, UVTEXTTOOL_cloneimage->ibuf->x, UVTEXTTOOL_cloneimage->ibuf->y, clonedrect);
|
||||
MEM_freeN(clonedrect); /* clean up ! */
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glaDrawPixelsSafe(x1 + offx, y1 + offy, w, h, clonerect);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
MEM_freeN(clonerect);
|
||||
}
|
||||
}
|
||||
|
||||
// #endif
|
||||
glPixelZoom(1.0, 1.0);
|
||||
|
||||
draw_tfaces();
|
||||
@@ -1085,9 +1066,8 @@ void drawimagespace(ScrArea *sa, void *spacedata)
|
||||
draw_image_transform(ibuf);
|
||||
|
||||
myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
|
||||
// #ifdef BM_TEXTUREPAINT
|
||||
|
||||
draw_image_view_tool();
|
||||
// #endif
|
||||
draw_image_view_icon();
|
||||
draw_area_emboss(sa);
|
||||
|
||||
|
||||
@@ -90,12 +90,8 @@
|
||||
#include "blendef.h"
|
||||
#include "butspace.h"
|
||||
|
||||
#include "TPT_DependKludge.h"
|
||||
|
||||
#ifdef NAN_TPT
|
||||
#include "../img/IMG_Api.h"
|
||||
#include "BSE_trans_types.h"
|
||||
#endif /* NAN_TPT */
|
||||
|
||||
#include "BDR_unwrapper.h"
|
||||
|
||||
@@ -1200,7 +1196,6 @@ void set_faceselect() /* toggle */
|
||||
}
|
||||
|
||||
|
||||
#ifdef NAN_TPT
|
||||
/**
|
||||
* Get the view ray through the screen point.
|
||||
* Uses the OpenGL settings of the active view port.
|
||||
@@ -1487,7 +1482,7 @@ void face_draw()
|
||||
error("The active object does not have a mesh obData"); return;
|
||||
}
|
||||
|
||||
brush = IMG_BrushCreate(Gvp.size, Gvp.size, Gvp.r, Gvp.g, Gvp.b, Gvp.a);
|
||||
brush = IMG_BrushCreate(Gvp.size, Gvp.size, &Gvp.r);
|
||||
if (!brush) {
|
||||
error("Can't create brush"); return;
|
||||
}
|
||||
@@ -1678,4 +1673,4 @@ void get_same_uv(void)
|
||||
|
||||
object_tface_flags_changed(OBACT, 0);
|
||||
}
|
||||
#endif /* NAN_TPT */
|
||||
|
||||
|
||||
@@ -82,15 +82,11 @@
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
#include "IMG_Api.h"
|
||||
#include "BSE_trans_types.h"
|
||||
|
||||
|
||||
#include "blendef.h"
|
||||
#include "mydevice.h"
|
||||
|
||||
#include "TPT_DependKludge.h"
|
||||
|
||||
static void load_space_image(char *str) /* called from fileselect */
|
||||
{
|
||||
Image *ima=0;
|
||||
@@ -722,51 +718,25 @@ static void do_image_imagemenu(void *arg, int event)
|
||||
break;
|
||||
case 7: /* New Image */
|
||||
{
|
||||
// #ifdef BM_TEXTUREPAINT
|
||||
static int x=256,y=256;
|
||||
short depth;
|
||||
char str[256];
|
||||
Image *ima;
|
||||
ImBuf *ibuf;
|
||||
BrushUIdata *data = NULL;
|
||||
extern short UVTEXTTOOL_INDEX;
|
||||
extern BrushUIdata UVTEXTTOOL_DATA[] ;
|
||||
IMG_CanvasPtr canvas;
|
||||
int rowBytes;
|
||||
data = &UVTEXTTOOL_DATA[UVTEXTTOOL_INDEX];
|
||||
strcpy(str, "MEMORY");
|
||||
/* i must get used to this may to create a modal dialog BM :) */
|
||||
add_numbut(0, TEX, "Name IM:",0 , 255, str, NULL);
|
||||
add_numbut(1, NUM|INT, "Width:", 1, 5000, &x, NULL);
|
||||
add_numbut(2, NUM|INT, "Height:", 1, 5000, &y, NULL);
|
||||
static int width= 256, height= 256;
|
||||
char name[256];
|
||||
|
||||
strcpy(name, "Image");
|
||||
|
||||
add_numbut(0, TEX, "Name:", 0, 255, name, NULL);
|
||||
add_numbut(1, NUM|INT, "Width:", 1, 5000, &width, NULL);
|
||||
add_numbut(2, NUM|INT, "Height:", 1, 5000, &height, NULL);
|
||||
if (!do_clever_numbuts("New Image", 3, REDRAW))
|
||||
return;
|
||||
|
||||
|
||||
ima = alloc_libblock(&G.main->image, ID_IM, str);
|
||||
if (ima)
|
||||
{
|
||||
depth= 24;
|
||||
ibuf = IMB_allocImBuf(x, y, depth, IB_rect, 0);
|
||||
ima->ibuf = ibuf;
|
||||
strcpy(ibuf->name,"UNTITLED");
|
||||
strcpy(ima->name, "UNTITLED");
|
||||
G.sima->image = ima;
|
||||
|
||||
rowBytes = G.sima->image->ibuf->skipx ? G.sima->image->ibuf->skipx : G.sima->image->ibuf->x * 4;
|
||||
canvas = IMG_CanvasCreateFromPtr(G.sima->image->ibuf->rect, G.sima->image->ibuf->x, G.sima->image->ibuf->y, rowBytes);
|
||||
IMG_CanvasFill(canvas,data->r,data->g,data->b,0.0);
|
||||
IMG_CanvasDispose(canvas);
|
||||
ima->ok= 1;
|
||||
G.sima->image= new_image(width, height, name);
|
||||
image_changed(G.sima, 0);
|
||||
|
||||
}
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
// #endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,36 +1131,12 @@ void image_buttons(void)
|
||||
xco+= xmax;
|
||||
}
|
||||
|
||||
|
||||
/* other buttons: */
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
|
||||
// xco+=XIC;
|
||||
|
||||
/*xco = 8;
|
||||
|
||||
uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), xco,0,XIC+10,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
|
||||
*/
|
||||
// xco+= XIC+22;
|
||||
|
||||
/* FULL WINDOW */
|
||||
/* if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
|
||||
else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
|
||||
*/
|
||||
|
||||
/* HOME*/
|
||||
/* uiDefIconBut(block, BUT, B_SIMAGEHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
|
||||
|
||||
|
||||
uiDefIconButBitS(block, TOG, SI_BE_SQUARE, B_BE_SQUARE, ICON_KEEPRECT, xco+=XIC,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Toggles constraining UV polygons to squares while editing");
|
||||
uiDefIconButBitS(block, ICONTOG, SI_CLIP_UV, B_CLIP_UV, ICON_CLIPUV_DEHLT,xco+=XIC,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Toggles clipping UV with image size");
|
||||
*/
|
||||
|
||||
xco= std_libbuttons(block, xco, 0, 0, NULL, B_SIMABROWSE, (ID *)G.sima->image, 0, &(G.sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
|
||||
|
||||
|
||||
if (G.sima->image) {
|
||||
|
||||
xco+= 8;
|
||||
|
||||
if (G.sima->image->packedfile) {
|
||||
@@ -1201,51 +1147,11 @@ void image_buttons(void)
|
||||
xco+= XIC;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
uiBlockSetCol(block, TH_AUTO);
|
||||
uiDefBut(block, BUT, B_SIMAGELOAD, "Load", xco, 0, 2*XIC, YIC, 0, 0, 0, 0, 0, "Loads image - file select");
|
||||
xco+= 2*XIC;
|
||||
|
||||
if (G.sima->image) {
|
||||
uiBlockSetCol(block, TH_AUTO);
|
||||
uiDefBut(block, BUT, B_SIMAGEREPLACE, "Replace",xco,0,(short)(3*XIC),YIC, 0, 0, 0, 0, 0, "Replaces current image - file select");
|
||||
xco+= 3.5*XIC;
|
||||
uiDefIconButBitS(block, TOG, 16, 0, ICON_ENVMAP, xco,0,XIC,YIC, &G.sima->image->flag, 0, 0, 0, 0, "Uses this image as a reflection map (Ignores UV Coordinates)");
|
||||
|
||||
uiDefIconButBitS(block, TOG, 1, B_SIMAGEDRAW1, ICON_GRID, xco+=XIC,0,XIC,YIC, &G.sima->image->flag, 0, 0, 0, 0, "");
|
||||
uiDefButS(block, NUM, B_SIMAGEDRAW, "", xco+=XIC,0,XIC,YIC, &G.sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction");
|
||||
uiDefButS(block, NUM, B_SIMAGEDRAW, "", xco+=XIC,0,XIC,YIC, &G.sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction");
|
||||
|
||||
uiDefButBitS(block, TOG, IMA_TWINANIM, B_TWINANIM, "Anim", xco,0,(2*XIC),YIC, &G.sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of animated texture");
|
||||
xco+= XIC;
|
||||
uiDefButS(block, NUM, B_TWINANIM, "", xco+=XIC,0,XIC,YIC, &G.sima->image->twsta, 0.0, 128.0, 0, 0, "Displays the start frame of an animated texture. Click to change.");
|
||||
uiDefButS(block, NUM, B_TWINANIM, "", xco+=XIC,0,XIC,YIC, &G.sima->image->twend, 0.0, 128.0, 0, 0, "Displays the end frame of an animated texture. Click to change.");
|
||||
// uiDefButBitS(block, TOG, IMA_COLCYCLE, 0, "Cycle", xco+=XIC,0,2*XIC,YIC, &G.sima->image->tpageflag, 0, 0, 0, 0, "");
|
||||
|
||||
uiDefButS(block, NUM, 0, "Speed", xco,0,4*XIC,YIC, &G.sima->image->animspeed, 1.0, 100.0, 0, 0, "Displays Speed of the animation in frames per second. Click to change.");
|
||||
xco+= 4.5*XIC;
|
||||
|
||||
// texture paint button used to be here
|
||||
|
||||
xco+= XIC;
|
||||
if (G.sima->image && G.sima->image->ibuf && (G.sima->image->ibuf->userflags & IB_BITMAPDIRTY)) {
|
||||
uiDefBut(block, BUT, B_SIMAGESAVE, "Save", xco,0,2*XIC,YIC, 0, 0, 0, 0, 0, "Saves image");
|
||||
xco += 2*XIC;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
xco+= 8;
|
||||
|
||||
if (G.sima->image) {
|
||||
|
||||
#ifdef NAN_TPT
|
||||
|
||||
uiDefIconButBitS(block, TOG, SI_DRAWTOOL, B_SIMAGEPAINTTOOL, ICON_TPAINT_HLT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Enables painting textures on the image with left mouse button");
|
||||
xco+= XIC+8;
|
||||
#endif /* NAN_TPT */
|
||||
|
||||
}
|
||||
|
||||
/* draw LOCK */
|
||||
|
||||
@@ -113,8 +113,6 @@
|
||||
|
||||
#include "BIF_poseobject.h"
|
||||
|
||||
#include "TPT_DependKludge.h"
|
||||
|
||||
/* View3d->modeselect
|
||||
* This is a bit of a dodgy hack to enable a 'mode' menu with icons+labels
|
||||
* rather than those buttons.
|
||||
|
||||
@@ -171,8 +171,6 @@
|
||||
#include "nla.h" /* __NLA : To be removed later */
|
||||
#include "butspace.h" // test_idbutton
|
||||
|
||||
#include "TPT_DependKludge.h"
|
||||
|
||||
#include "BIF_poseobject.h"
|
||||
|
||||
#include "SYS_System.h"
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
* Functions to edit the "2D UV/Image "
|
||||
* and handle user events sent to it.
|
||||
*
|
||||
*
|
||||
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -34,6 +33,7 @@
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
@@ -47,15 +47,9 @@
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef INTERNATIONAL
|
||||
#include "BIF_language.h"
|
||||
#endif
|
||||
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
@@ -67,288 +61,241 @@
|
||||
#include "BIF_toolbox.h"
|
||||
|
||||
#include "BSE_drawipo.h"
|
||||
#include "BSE_trans_types.h"
|
||||
|
||||
#include "BDR_vpaint.h"
|
||||
#include "BDR_drawmesh.h"
|
||||
#include "BDR_imagepaint.h"
|
||||
#include "BDR_vpaint.h"
|
||||
|
||||
#include "IMG_Api.h"
|
||||
|
||||
#include "mydevice.h"
|
||||
|
||||
#include "TPT_DependKludge.h"
|
||||
#include "BSE_trans_types.h"
|
||||
#include "IMG_Api.h"
|
||||
struct ImagePaint Gip = {
|
||||
{NULL, {0.0f, 0.0f}, 0.5f},
|
||||
{{{1.0f, 1.0f, 1.0f, 0.2f}, 25, 0.5f, 100.0f}, /* brush */
|
||||
{{1.0f, 1.0f, 1.0f, 0.1f}, 25, 0.1f, 100.0f}, /* airbrush */
|
||||
{{0.5f, 0.5f, 0.5f, 1.0f}, 25, 0.5f, 100.0f}, /* soften */
|
||||
{{1.0f, 1.0f, 1.0f, 0.1f}, 25, 0.1f, 100.0f}, /* aux1 */
|
||||
{{0.0f, 0.0f, 0.0f, 0.1f}, 25, 0.1f, 100.0f}, /* aux2 */
|
||||
{{1.0f, 1.0f, 1.0f, 0.5f}, 25, 0.1f, 20.0f}, /* smear */
|
||||
{{1.0f, 1.0f, 1.0f, 0.5f}, 25, 0.1f, 20.0f}}, /* clone */
|
||||
0, IMAGEPAINT_BRUSH
|
||||
};
|
||||
|
||||
#include "SYS_System.h" /* for the user def menu ... should move elsewhere. */
|
||||
|
||||
|
||||
|
||||
/* this data should be a new datablock, used by G.sima .. G.sima->painttoolbox.yadayada */
|
||||
/* so get the rest working and then care for this */
|
||||
/* using UVTEXTTOOL_ as prefix so a grep will find 'em all later*/
|
||||
Image* UVTEXTTOOL_cloneimage = NULL;
|
||||
short UVTEXTTOOL_imanr= -2;
|
||||
float UVTEXTTOOL_cloneoffx = 0.0;
|
||||
float UVTEXTTOOL_cloneoffy = 0.0;
|
||||
float UVTEXTTOOL_clonealpha = 0.5;
|
||||
|
||||
short UVTEXTTOOL_POS[2];
|
||||
float UVTEXTTOOL_RAD[2];
|
||||
short UVTEXTTOOL_SHAPE;
|
||||
short UVTEXTTOOL_INDEX = 0;
|
||||
short UVTEXTTOOL_uiflags = 0;
|
||||
BrushUIdata UVTEXTTOOL_DATA[7] = {
|
||||
/* r,g,b,a,size,softradius,timing*/
|
||||
{ 1.0f , 1.0f , 1.0f ,0.2f , 25.0f, 0.5f,100.0f}, /* brush */
|
||||
{ 1.0f , 1.0f , 1.0f ,0.1f , 25.0f, 0.1f,100.0f}, /* air brush */
|
||||
{ 0.5f , 0.5f , 0.5f ,1.0f , 25.0f, 0.5f,100.0f}, /* soften */
|
||||
{ 1.0f , 1.0f , 1.0f ,0.1f , 25.0f, 0.1f,100.0f},
|
||||
{ 0.0f , 0.0f , 0.0f ,0.1f , 25.0f, 0.1f,100.0f},
|
||||
{ 1.0f , 0.0f , 1.0f ,0.5f , 25.0f, 0.1f, 20.0f},
|
||||
{ 1.0f , 0.0f , 1.0f ,0.5f , 25.0f, 0.1f, 20.0f}};
|
||||
|
||||
|
||||
|
||||
void texturepaintoff()
|
||||
{
|
||||
UVTEXTTOOL_SHAPE = 0;
|
||||
}
|
||||
|
||||
int uv_paint_panel_but(short val)
|
||||
static int imagepaint_init(IMG_BrushPtr **brush, IMG_CanvasPtr **canvas, IMG_CanvasPtr **clonecanvas)
|
||||
{
|
||||
/* but still i don't know if i like that crowded floating panel */
|
||||
switch(val){
|
||||
case PAINTPANELMESSAGEEATER:
|
||||
force_draw(0);/* tool changes so redraw settings */
|
||||
}
|
||||
ImBuf *ibuf= NULL, *cloneibuf= NULL;
|
||||
ImagePaintTool *tool= &Gip.tool[Gip.current];
|
||||
|
||||
/* verify that we can paint */
|
||||
if(!G.sima->image || !G.sima->image->ibuf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UVtimedaction(int action)
|
||||
{
|
||||
if (( action== 1.0)
|
||||
|| (action == 2.0)
|
||||
|| (action == 3.0)
|
||||
|| (action == 4.0)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UVTexturePaintToolAt(short* where)
|
||||
/* keep drawimage informed on actual tool position/setting */
|
||||
{
|
||||
SpaceImage *sima= curarea->spacedata.first;
|
||||
BrushUIdata *data = NULL;
|
||||
|
||||
data = &UVTEXTTOOL_DATA[UVTEXTTOOL_INDEX];
|
||||
if(!data) return;
|
||||
UVTEXTTOOL_POS[0] = where[0];
|
||||
UVTEXTTOOL_POS[1] = where[1];
|
||||
UVTEXTTOOL_RAD[0] = data->size*sima->zoom/2;
|
||||
UVTEXTTOOL_RAD[1] = data->softradius*data->size*sima->zoom/2;
|
||||
}
|
||||
|
||||
void UVTexturePaintMsg( void *spacedata, unsigned short event,short val,short paintmousebut)
|
||||
/* handle events in texturepaint mode of UV-Image Editor*/
|
||||
{
|
||||
SpaceImage *sima= curarea->spacedata.first;
|
||||
BrushUIdata *data=NULL;
|
||||
IMG_BrushPtr brush;
|
||||
IMG_CanvasPtr canvas,clonecanvas =NULL;
|
||||
short xy_prev[2], xy_curr[2];
|
||||
static short dtxy_prev[2], dtxy_curr[2];
|
||||
float uv_prev[2], uv_curr[2];
|
||||
int rowBytes,clonerowBytes;
|
||||
double brushtime;
|
||||
int firsttouch = 1;
|
||||
float duv[2];
|
||||
float dduv;
|
||||
char extensionmode;
|
||||
View2D *v2d= &sima->v2d;
|
||||
|
||||
data = &UVTEXTTOOL_DATA[UVTEXTTOOL_INDEX];
|
||||
if (!data) return;
|
||||
switch(event){
|
||||
case UI_BUT_EVENT:
|
||||
{
|
||||
if (uv_paint_panel_but(val)) break;
|
||||
}
|
||||
case MOUSEX:
|
||||
case MOUSEY:
|
||||
{
|
||||
/* tool preview */
|
||||
if (UVTEXTTOOL_uiflags & 2) {
|
||||
getmouseco_areawin(dtxy_curr);
|
||||
if ( dtxy_curr[0]!=dtxy_prev[0] || dtxy_curr[1]!=dtxy_prev[1]) {
|
||||
UVTexturePaintToolAt(dtxy_curr);
|
||||
UVTEXTTOOL_SHAPE = 1;
|
||||
force_draw(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UVTEXTTOOL_SHAPE = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
dtxy_prev[0] = dtxy_curr[0];
|
||||
dtxy_prev[1] = dtxy_curr[1];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
switch(event) {
|
||||
case LEFTMOUSE:
|
||||
/* Paranoia checks */
|
||||
if (!sima) break;
|
||||
if (!sima->image) break;
|
||||
if (!sima->image->ibuf) break;
|
||||
if (sima->image->packedfile) {
|
||||
else if(G.sima->image->packedfile) {
|
||||
error("Painting in packed images not supported");
|
||||
break;
|
||||
}
|
||||
brush = IMG_BrushCreate((int)(data->size), (int)(data->size), data->r, data->g, data->b, data->a);
|
||||
|
||||
IMG_BrushSetInnerRaduisRatio(brush,data->softradius);
|
||||
/* skipx is not set most of the times. Make a guess. */
|
||||
rowBytes = sima->image->ibuf->skipx ? sima->image->ibuf->skipx : sima->image->ibuf->x * 4;
|
||||
canvas = IMG_CanvasCreateFromPtr(sima->image->ibuf->rect, sima->image->ibuf->x, sima->image->ibuf->y, rowBytes);
|
||||
if (UVTEXTTOOL_cloneimage){
|
||||
if (UVTEXTTOOL_cloneimage->ibuf){
|
||||
clonerowBytes = UVTEXTTOOL_cloneimage->ibuf->skipx ? UVTEXTTOOL_cloneimage->ibuf->skipx : UVTEXTTOOL_cloneimage->ibuf->x * 4;
|
||||
clonecanvas = IMG_CanvasCreateFromPtr(UVTEXTTOOL_cloneimage->ibuf->rect, UVTEXTTOOL_cloneimage->ibuf->x, UVTEXTTOOL_cloneimage->ibuf->y, clonerowBytes);
|
||||
}
|
||||
}
|
||||
getmouseco_areawin(xy_prev);
|
||||
brushtime = PIL_check_seconds_timer();
|
||||
while (get_mbut() & paintmousebut) {
|
||||
UVTEXTTOOL_SHAPE = 0;
|
||||
getmouseco_areawin(xy_curr);
|
||||
/* check for timed actions */
|
||||
if (UVtimedaction(UVTEXTTOOL_INDEX)){
|
||||
if ((PIL_check_seconds_timer()-brushtime) > (5.0/data->brushtiming) )
|
||||
{
|
||||
brushtime=PIL_check_seconds_timer();
|
||||
firsttouch = 1;
|
||||
xy_prev[0] = xy_curr[0];
|
||||
xy_prev[1] = xy_curr[1];
|
||||
}
|
||||
}
|
||||
/* check for movement actions */
|
||||
if ((xy_prev[0] != xy_curr[0]) || (xy_prev[1] != xy_curr[1]) || firsttouch) {
|
||||
/* so now we know we did move at all */
|
||||
/* Convert mouse coordinates to u,v and draw */
|
||||
areamouseco_to_ipoco(v2d, xy_prev, &uv_prev[0], &uv_prev[1]);
|
||||
areamouseco_to_ipoco(v2d, xy_curr, &uv_curr[0], &uv_curr[1]);
|
||||
/* do some gearing down in % of brush diameter*/
|
||||
duv[0] = (float)(xy_prev[0]- xy_curr[0]);
|
||||
duv[1] = (float)(xy_prev[1]- xy_curr[1]);
|
||||
dduv = (float)sqrt(duv[0] * duv[0] + duv[1] * duv[1]);
|
||||
if ((dduv < (data->size*sima->zoom * data->brushtiming/200.0) ) && (firsttouch == 0)){
|
||||
if (UVTEXTTOOL_uiflags & 1){ /* this spoils all efforts reducing redraw needs */
|
||||
static short m_prev[2];
|
||||
/* doing a brute force toolshape update by backbuffer drawing */
|
||||
if ((m_prev[0] != xy_curr[0]) || (m_prev[1] != xy_curr[1])) {
|
||||
UVTexturePaintToolAt(xy_curr);
|
||||
UVTEXTTOOL_SHAPE = UVTEXTTOOL_uiflags & 1;
|
||||
force_draw(0);
|
||||
}
|
||||
m_prev[0] = xy_curr[0];
|
||||
m_prev[1] = xy_curr[1];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* respect timed actions */
|
||||
if (UVtimedaction(UVTEXTTOOL_INDEX) && (firsttouch == 0)){
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ibuf= G.sima->image->ibuf;
|
||||
|
||||
firsttouch = 0;
|
||||
if (UVTEXTTOOL_uiflags & 4)
|
||||
extensionmode = 't';
|
||||
if(Gip.current == IMAGEPAINT_CLONE) {
|
||||
if(!Gip.clone.image || !Gip.clone.image->ibuf)
|
||||
return 0;
|
||||
|
||||
cloneibuf= Gip.clone.image->ibuf;
|
||||
}
|
||||
|
||||
/* create brush */
|
||||
*brush= IMG_BrushCreate(tool->size, tool->size, tool->rgba);
|
||||
IMG_BrushSetInnerRaduisRatio(*brush, tool->innerradius);
|
||||
|
||||
/* create canvas */
|
||||
*canvas= IMG_CanvasCreateFromPtr(ibuf->rect, ibuf->x, ibuf->y, ibuf->x*4);
|
||||
|
||||
if(Gip.current == IMAGEPAINT_CLONE) {
|
||||
int w= cloneibuf->x, h= cloneibuf->y;
|
||||
*clonecanvas= IMG_CanvasCreateFromPtr(cloneibuf->rect, w, h, cloneibuf->x*4);
|
||||
}
|
||||
else
|
||||
extensionmode = 'c';
|
||||
switch(UVTEXTTOOL_INDEX) {
|
||||
case 2:
|
||||
IMG_CanvasSoftenAt(canvas,uv_prev[0],uv_prev[1],(int)(data->size),data->a,data->softradius,extensionmode);
|
||||
break;
|
||||
case 5:
|
||||
IMG_CanvasSmear(canvas,uv_prev[0], uv_prev[1], uv_curr[0], uv_curr[1],(int)(data->size),data->a,data->softradius,extensionmode);
|
||||
break;
|
||||
case 6:
|
||||
IMG_CanvasCloneAt(canvas,clonecanvas,uv_prev[0],uv_prev[1],UVTEXTTOOL_cloneoffx,UVTEXTTOOL_cloneoffy,(int)(data->size),data->a,data->softradius);
|
||||
break;
|
||||
default:
|
||||
// IMG_CanvasDrawLineUVEX(canvas, brush, uv_prev[0], uv_prev[1], uv_curr[0], uv_curr[1],'c');
|
||||
IMG_CanvasDrawLineUVEX(canvas, brush, uv_prev[0], uv_prev[1], uv_curr[0], uv_curr[1],extensionmode);
|
||||
}
|
||||
*clonecanvas= NULL;
|
||||
|
||||
if (G.sima->lock) {
|
||||
/* Make OpenGL aware of a changed texture */
|
||||
free_realtime_image(sima->image);
|
||||
/* Redraw this view and the 3D view */
|
||||
UVTexturePaintToolAt(xy_curr);
|
||||
UVTEXTTOOL_SHAPE = UVTEXTTOOL_uiflags & 1;
|
||||
force_draw_plus(SPACE_VIEW3D,0);
|
||||
/* initialize paint settings */
|
||||
if(Gip.current >= IMAGEPAINT_AIRBRUSH && Gip.current <= IMAGEPAINT_SOFTEN)
|
||||
Gip.flag |= IMAGEPAINT_TIMED;
|
||||
else
|
||||
Gip.flag &= ~IMAGEPAINT_TIMED;
|
||||
|
||||
}
|
||||
else {
|
||||
/* Redraw only this view */
|
||||
UVTexturePaintToolAt(xy_curr);
|
||||
UVTEXTTOOL_SHAPE = UVTEXTTOOL_uiflags & 1;
|
||||
force_draw(0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
xy_prev[0] = xy_curr[0];
|
||||
xy_prev[1] = xy_curr[1];
|
||||
}
|
||||
}
|
||||
UVTEXTTOOL_SHAPE = UVTEXTTOOL_uiflags & 2;
|
||||
/* Set the dirty bit in the image so that it is clear that it has been modified. */
|
||||
sima->image->ibuf->userflags |= IB_BITMAPDIRTY;
|
||||
if (!G.sima->lock) {
|
||||
/* Make OpenGL aware of a changed texture */
|
||||
free_realtime_image(sima->image);
|
||||
/* Redraw this view and the 3D view */
|
||||
force_draw_plus(SPACE_VIEW3D,0);
|
||||
}
|
||||
static void imagepaint_free(IMG_BrushPtr *brush, IMG_CanvasPtr *canvas, IMG_CanvasPtr *clonecanvas)
|
||||
{
|
||||
IMG_BrushDispose(brush);
|
||||
IMG_CanvasDispose(canvas);
|
||||
if (clonecanvas) IMG_CanvasDispose(clonecanvas);
|
||||
allqueue(REDRAWHEADERS, 0);
|
||||
|
||||
break;
|
||||
case RIGHTMOUSE:
|
||||
{
|
||||
extern float UVTEXTTOOL_cloneoffx;
|
||||
extern float UVTEXTTOOL_cloneoffy;
|
||||
/* call the color lifter */
|
||||
if (UVTEXTTOOL_INDEX==6){
|
||||
getmouseco_areawin(xy_prev);
|
||||
while (get_mbut() & paintmousebut) {
|
||||
getmouseco_areawin(xy_curr);
|
||||
/* check for movement actions */
|
||||
if ((xy_prev[0] != xy_curr[0]) || (xy_prev[1] != xy_curr[1]) ) {
|
||||
/* so now we know we did move at all */
|
||||
/* Convert mouse coordinates to u,v and draw */
|
||||
areamouseco_to_ipoco(v2d, xy_prev, &uv_prev[0], &uv_prev[1]);
|
||||
areamouseco_to_ipoco(v2d, xy_curr, &uv_curr[0], &uv_curr[1]);
|
||||
UVTEXTTOOL_cloneoffx += uv_curr[0] -uv_prev[0];
|
||||
UVTEXTTOOL_cloneoffy += uv_curr[1] -uv_prev[1];
|
||||
if(Gip.current == IMAGEPAINT_CLONE)
|
||||
IMG_CanvasDispose(clonecanvas);
|
||||
}
|
||||
|
||||
void imagepaint_redraw_tool(void)
|
||||
{
|
||||
if(Gip.flag & IMAGEPAINT_DRAW_TOOL_DRAWING)
|
||||
force_draw(0);
|
||||
}
|
||||
|
||||
static void imagepaint_redraw(int final, int painted)
|
||||
{
|
||||
if(!final && !painted) {
|
||||
imagepaint_redraw_tool();
|
||||
return;
|
||||
}
|
||||
|
||||
if(final || painted) {
|
||||
if (final || G.sima->lock) {
|
||||
/* Make OpenGL aware of a changed texture */
|
||||
free_realtime_image(G.sima->image);
|
||||
force_draw_plus(SPACE_VIEW3D,0);
|
||||
}
|
||||
else
|
||||
force_draw(0);
|
||||
}
|
||||
|
||||
if(final)
|
||||
allqueue(REDRAWHEADERS, 0);
|
||||
}
|
||||
|
||||
static void imagepaint_compute_uvco(short *mval, float *uv)
|
||||
{
|
||||
areamouseco_to_ipoco(G.v2d, mval, &uv[0], &uv[1]);
|
||||
}
|
||||
|
||||
static void imagepaint_paint_tool(IMG_BrushPtr *brush, IMG_CanvasPtr *canvas, IMG_CanvasPtr *clonecanvas, float *prevuv, float *uv)
|
||||
{
|
||||
int torus = Gip.flag & IMAGEPAINT_TORUS;
|
||||
ImagePaintTool *tool= &Gip.tool[Gip.current];
|
||||
|
||||
if(Gip.current == IMAGEPAINT_SOFTEN)
|
||||
IMG_CanvasSoftenAt(canvas, prevuv[0], prevuv[1], tool->size, tool->rgba[3], tool->innerradius, torus);
|
||||
else if(Gip.current == IMAGEPAINT_SMEAR)
|
||||
IMG_CanvasSmear(canvas, prevuv[0], prevuv[1], uv[0], uv[1], tool->size, tool->rgba[3], tool->innerradius, torus);
|
||||
else if(Gip.current == IMAGEPAINT_CLONE) {
|
||||
float offx= Gip.clone.offset[0];
|
||||
float offy= Gip.clone.offset[1];
|
||||
|
||||
IMG_CanvasCloneAt(canvas, clonecanvas, prevuv[0], prevuv[1], offx, offy, tool->size, tool->rgba[3], tool->innerradius);
|
||||
}
|
||||
else
|
||||
IMG_CanvasDrawLineUVEX(canvas, brush, prevuv[0], prevuv[1], uv[0], uv[1], torus);
|
||||
}
|
||||
|
||||
void imagepaint_paint(short mousebutton)
|
||||
{
|
||||
IMG_BrushPtr *brush;
|
||||
IMG_CanvasPtr *canvas, *clonecanvas;
|
||||
short prevmval[2], mval[2];
|
||||
double prevtime, curtime;
|
||||
float prevuv[2], uv[2];
|
||||
int paint= 0, moved= 0;
|
||||
ImagePaintTool *tool= &Gip.tool[Gip.current];
|
||||
|
||||
if(!imagepaint_init(&brush, &canvas, &clonecanvas))
|
||||
return;
|
||||
|
||||
getmouseco_areawin(prevmval);
|
||||
prevtime = PIL_check_seconds_timer();
|
||||
|
||||
Gip.flag |= IMAGEPAINT_DRAWING;
|
||||
|
||||
while(get_mbut() & mousebutton) {
|
||||
getmouseco_areawin(mval);
|
||||
|
||||
moved= paint= (prevmval[0] != mval[0]) || (prevmval[1] != mval[1]);
|
||||
|
||||
if(Gip.flag & IMAGEPAINT_TIMED) {
|
||||
/* see if need to draw because of timer */
|
||||
curtime = PIL_check_seconds_timer();
|
||||
|
||||
if((curtime - prevtime) > (5.0/tool->timing)) {
|
||||
prevtime= curtime;
|
||||
paint= 1;
|
||||
}
|
||||
}
|
||||
else if(paint) {
|
||||
/* check if we moved enough to draw */
|
||||
float dmval[2], d, dlimit;
|
||||
|
||||
dmval[0]= prevmval[0] - mval[0];
|
||||
dmval[1]= prevmval[1] - mval[1];
|
||||
|
||||
d= sqrt(dmval[0]*dmval[0] + dmval[1]*dmval[1]);
|
||||
dlimit= tool->size*G.sima->zoom*tool->timing/200.0;
|
||||
|
||||
if (d < dlimit)
|
||||
paint= 0;
|
||||
}
|
||||
|
||||
if(paint) {
|
||||
/* do the actual painting */
|
||||
imagepaint_compute_uvco(prevmval, prevuv);
|
||||
imagepaint_compute_uvco(mval, uv);
|
||||
|
||||
imagepaint_paint_tool(brush, canvas, clonecanvas, prevuv, uv);
|
||||
|
||||
prevmval[0]= mval[0];
|
||||
prevmval[1]= mval[1];
|
||||
}
|
||||
|
||||
if(paint)
|
||||
imagepaint_redraw(0, paint);
|
||||
else if(moved && (Gip.flag & IMAGEPAINT_DRAW_TOOL))
|
||||
imagepaint_redraw(0, paint);
|
||||
}
|
||||
|
||||
Gip.flag &= ~IMAGEPAINT_DRAWING;
|
||||
|
||||
imagepaint_free(brush, canvas, clonecanvas);
|
||||
G.sima->image->ibuf->userflags |= IB_BITMAPDIRTY;
|
||||
|
||||
imagepaint_redraw(1, 0);
|
||||
}
|
||||
|
||||
void imagepaint_pick(short mousebutton)
|
||||
{
|
||||
ImagePaintTool *tool= &Gip.tool[Gip.current];
|
||||
|
||||
if(Gip.current == IMAGEPAINT_CLONE) {
|
||||
if(Gip.clone.image && Gip.clone.image->ibuf) {
|
||||
short prevmval[2], mval[2];
|
||||
float prevuv[2], uv[2];
|
||||
|
||||
getmouseco_areawin(prevmval);
|
||||
|
||||
while(get_mbut() & mousebutton) {
|
||||
getmouseco_areawin(mval);
|
||||
|
||||
if((prevmval[0] != mval[0]) || (prevmval[1] != mval[1]) ) {
|
||||
/* mouse moved, so move the clone image */
|
||||
imagepaint_compute_uvco(prevmval, prevuv);
|
||||
imagepaint_compute_uvco(mval, uv);
|
||||
|
||||
Gip.clone.offset[0] += uv[0] - prevuv[0];
|
||||
Gip.clone.offset[1] += uv[1] - prevuv[1];
|
||||
|
||||
force_draw(0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
xy_prev[0] = xy_curr[0];
|
||||
xy_prev[1] = xy_curr[1];
|
||||
|
||||
prevmval[0]= mval[0];
|
||||
prevmval[1]= mval[1];
|
||||
}
|
||||
}
|
||||
else sample_vpaint();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
extern VPaint Gvp;
|
||||
|
||||
sample_vpaint();
|
||||
tool->rgba[0]= Gvp.r;
|
||||
tool->rgba[1]= Gvp.g;
|
||||
tool->rgba[2]= Gvp.b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
#include "BDR_editface.h"
|
||||
#include "BDR_drawmesh.h"
|
||||
#include "BDR_drawobject.h"
|
||||
#include "BDR_imagepaint.h"
|
||||
#include "BDR_unwrapper.h"
|
||||
|
||||
#include "BLO_readfile.h" /* for BLO_blendhandle_close */
|
||||
@@ -147,11 +148,8 @@
|
||||
|
||||
#include "BKE_depsgraph.h"
|
||||
|
||||
#include "TPT_DependKludge.h"
|
||||
#ifdef NAN_TPT
|
||||
#include "BSE_trans_types.h"
|
||||
#include "IMG_Api.h"
|
||||
#endif /* NAN_TPT */
|
||||
|
||||
#include "SYS_System.h" /* for the user def menu ... should move elsewhere. */
|
||||
|
||||
@@ -673,6 +671,8 @@ void BIF_undo(void)
|
||||
wpaint_undo();
|
||||
else if(G.f & G_VERTEXPAINT)
|
||||
vpaint_undo();
|
||||
else if(G.f & G_TEXTUREPAINT); /* no texture paint undo yet */
|
||||
else if(curarea->spacetype==SPACE_IMAGE && (G.sima->flag & SI_DRAWTOOL));
|
||||
else {
|
||||
/* now also in faceselect mode */
|
||||
if(U.uiflag & USER_GLOBALUNDO) BKE_undo_step(1);
|
||||
@@ -3747,22 +3747,14 @@ void free_soundspace(SpaceSound *ssound)
|
||||
|
||||
static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
{
|
||||
unsigned short event= evt->event;
|
||||
unsigned short event= evt->event, origevent= evt->event;
|
||||
short val= evt->val;
|
||||
SpaceImage *sima= curarea->spacedata.first;
|
||||
short paintmousebut=0;
|
||||
|
||||
if(val==0) return;
|
||||
|
||||
if(uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
|
||||
|
||||
/* swap mouse buttons based on user preference */
|
||||
if (event == LEFTMOUSE) {
|
||||
paintmousebut = L_MOUSE;
|
||||
} else if (event == RIGHTMOUSE) {
|
||||
paintmousebut = R_MOUSE;
|
||||
}
|
||||
|
||||
if (U.flag & USER_LMOUSESELECT) {
|
||||
if (event == LEFTMOUSE) {
|
||||
event = RIGHTMOUSE;
|
||||
@@ -3771,24 +3763,22 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sima->flag & SI_DRAWTOOL) {
|
||||
switch(event) {
|
||||
case CKEY:
|
||||
add_blockhandler(curarea, IMAGE_HANDLER_PAINT, UI_PNL_UNSTOW);
|
||||
scrarea_queue_winredraw(curarea);
|
||||
break;
|
||||
default:
|
||||
UVTexturePaintMsg(spacedata,event,val,paintmousebut);
|
||||
case LEFTMOUSE:
|
||||
imagepaint_paint(origevent==LEFTMOUSE? L_MOUSE: R_MOUSE);
|
||||
break;
|
||||
case RIGHTMOUSE:
|
||||
imagepaint_pick(origevent==LEFTMOUSE? L_MOUSE: R_MOUSE);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
/* Draw tool is inactive */
|
||||
// #ifdef BM_TEXTUREPAINT
|
||||
texturepaintoff();
|
||||
// #endif /* else BM_TEXTUREPAINT*/
|
||||
|
||||
switch(event) {
|
||||
case LEFTMOUSE:
|
||||
if(G.qual & LR_SHIFTKEY) mouseco_to_curtile();
|
||||
|
||||
@@ -918,7 +918,7 @@ void weight_paint(void)
|
||||
/* this happens on a Bone select, when no vgroup existed yet */
|
||||
if(ob->actdef==0) {
|
||||
Object *modob;
|
||||
if(modob = modifiers_isDeformedByArmature(ob)) {
|
||||
if((modob = modifiers_isDeformedByArmature(ob))) {
|
||||
bPoseChannel *pchan;
|
||||
for(pchan= modob->pose->chanbase.first; pchan; pchan= pchan->next)
|
||||
if(pchan->bone->flag & SELECT)
|
||||
|
||||
Reference in New Issue
Block a user