svn merge ^/trunk/blender -r46966:46979
This commit is contained in:
@@ -46,22 +46,22 @@
|
||||
#include "GHOST_C-api.h"
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#else /* WIN32 */
|
||||
/* __APPLE__ is defined */
|
||||
#include <AGL/gl.h>
|
||||
#endif /* WIN32 */
|
||||
# ifdef WIN32
|
||||
# include <windows.h>
|
||||
# include <GL/gl.h>
|
||||
# else /* WIN32 */
|
||||
/* __APPLE__ is defined */
|
||||
# include <AGL/gl.h>
|
||||
# endif /* WIN32 */
|
||||
#else /* defined(WIN32) || defined(__APPLE__) */
|
||||
#include <GL/gl.h>
|
||||
# include <GL/gl.h>
|
||||
#endif /* defined(WIN32) || defined(__APPLE__) */
|
||||
|
||||
|
||||
static void gearsTimerProc(GHOST_TimerTaskHandle task, GHOST_TUns64 time);
|
||||
int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData);
|
||||
|
||||
static GLfloat view_rotx=20.0, view_roty=30.0, view_rotz=0.0;
|
||||
static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
|
||||
static GLfloat fAngle = 0.0;
|
||||
static int sExitRequested = 0;
|
||||
static GHOST_SystemHandle shSystem = NULL;
|
||||
@@ -87,34 +87,34 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL
|
||||
const double pi = 3.14159264;
|
||||
|
||||
r0 = inner_radius;
|
||||
r1 = (float)(outer_radius - tooth_depth/2.0);
|
||||
r2 = (float)(outer_radius + tooth_depth/2.0);
|
||||
r1 = (float)(outer_radius - tooth_depth / 2.0);
|
||||
r2 = (float)(outer_radius + tooth_depth / 2.0);
|
||||
|
||||
da = (float)(2.0*pi / teeth / 4.0);
|
||||
da = (float)(2.0 * pi / teeth / 4.0);
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
|
||||
/* draw front face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i=0;i<=teeth;i++) {
|
||||
angle = (float)(i * 2.0*pi / teeth);
|
||||
glVertex3f((float)(r0*cos(angle)), (float)(r0*sin(angle)), (float)(width*0.5));
|
||||
glVertex3f((float)(r1*cos(angle)), (float)(r1*sin(angle)), (float)(width*0.5));
|
||||
glVertex3f((float)(r0*cos(angle)), (float)(r0*sin(angle)), (float)(width*0.5));
|
||||
glVertex3f((float)(r1*cos(angle+3*da)), (float)(r1*sin(angle+3*da)), (float)(width*0.5));
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = (float)(i * 2.0 * pi / teeth);
|
||||
glVertex3f((float)(r0 * cos(angle)), (float)(r0 * sin(angle)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r1 * cos(angle)), (float)(r1 * sin(angle)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r0 * cos(angle)), (float)(r0 * sin(angle)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r1 * cos(angle + 3 * da)), (float)(r1 * sin(angle + 3 * da)), (float)(width * 0.5));
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw front sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = (float)(2.0*pi / teeth / 4.0);
|
||||
for (i=0;i<teeth;i++) {
|
||||
angle = (float)(i * 2.0*pi / teeth);
|
||||
glVertex3f((float)(r1*cos(angle)), (float)(r1*sin(angle)), (float)(width*0.5));
|
||||
glVertex3f((float)(r2*cos(angle+da)), (float)(r2*sin(angle+da)), (float)(width*0.5));
|
||||
glVertex3f((float)(r2*cos(angle+2*da)), (float)(r2*sin(angle+2*da)), (float)(width*0.5));
|
||||
glVertex3f((float)(r1*cos(angle+3*da)), (float)(r1*sin(angle+3*da)), (float)(width*0.5));
|
||||
da = (float)(2.0 * pi / teeth / 4.0);
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = (float)(i * 2.0 * pi / teeth);
|
||||
glVertex3f((float)(r1 * cos(angle)), (float)(r1 * sin(angle)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r2 * cos(angle + da)), (float)(r2 * sin(angle + da)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r2 * cos(angle + 2 * da)), (float)(r2 * sin(angle + 2 * da)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r1 * cos(angle + 3 * da)), (float)(r1 * sin(angle + 3 * da)), (float)(width * 0.5));
|
||||
}
|
||||
glEnd();
|
||||
|
||||
@@ -122,64 +122,64 @@ static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GL
|
||||
|
||||
/* draw back face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i=0;i<=teeth;i++) {
|
||||
angle = (float)(i * 2.0*pi / teeth);
|
||||
glVertex3f((float)(r1*cos(angle)), (float)(r1*sin(angle)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r0*cos(angle)), (float)(r0*sin(angle)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r1*cos(angle+3*da)), (float)(r1*sin(angle+3*da)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r0*cos(angle)), (float)(r0*sin(angle)), (float)(-width*0.5));
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = (float)(i * 2.0 * pi / teeth);
|
||||
glVertex3f((float)(r1 * cos(angle)), (float)(r1 * sin(angle)), (float)(-width * 0.5));
|
||||
glVertex3f((float)(r0 * cos(angle)), (float)(r0 * sin(angle)), (float)(-width * 0.5));
|
||||
glVertex3f((float)(r1 * cos(angle + 3 * da)), (float)(r1 * sin(angle + 3 * da)), (float)(-width * 0.5));
|
||||
glVertex3f((float)(r0 * cos(angle)), (float)(r0 * sin(angle)), (float)(-width * 0.5));
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = (float)(2.0*pi / teeth / 4.0);
|
||||
for (i=0;i<teeth;i++) {
|
||||
angle = (float)(i * 2.0*pi / teeth);
|
||||
glVertex3f((float)(r1*cos(angle+3*da)), (float)(r1*sin(angle+3*da)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r2*cos(angle+2*da)), (float)(r2*sin(angle+2*da)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r2*cos(angle+da)), (float)(r2*sin(angle+da)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r1*cos(angle)), (float)(r1*sin(angle)), (float)(-width*0.5));
|
||||
da = (float)(2.0 * pi / teeth / 4.0);
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = (float)(i * 2.0 * pi / teeth);
|
||||
glVertex3f((float)(r1 * cos(angle + 3 * da)), (float)(r1 * sin(angle + 3 * da)), (float)(-width * 0.5));
|
||||
glVertex3f((float)(r2 * cos(angle + 2 * da)), (float)(r2 * sin(angle + 2 * da)), (float)(-width * 0.5));
|
||||
glVertex3f((float)(r2 * cos(angle + da)), (float)(r2 * sin(angle + da)), (float)(-width * 0.5));
|
||||
glVertex3f((float)(r1 * cos(angle)), (float)(r1 * sin(angle)), (float)(-width * 0.5));
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw outward faces of teeth */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i=0;i<teeth;i++) {
|
||||
angle = (float)(i * 2.0*pi / teeth);
|
||||
glVertex3f((float)(r1*cos(angle)), (float)(r1*sin(angle)), (float)(width*0.5));
|
||||
glVertex3f((float)(r1*cos(angle)), (float)(r1*sin(angle)), (float)(-width*0.5));
|
||||
u = (float)(r2*cos(angle+da) - r1*cos(angle));
|
||||
v = (float)(r2*sin(angle+da) - r1*sin(angle));
|
||||
len = (float)(sqrt(u*u + v*v));
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = (float)(i * 2.0 * pi / teeth);
|
||||
glVertex3f((float)(r1 * cos(angle)), (float)(r1 * sin(angle)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r1 * cos(angle)), (float)(r1 * sin(angle)), (float)(-width * 0.5));
|
||||
u = (float)(r2 * cos(angle + da) - r1 * cos(angle));
|
||||
v = (float)(r2 * sin(angle + da) - r1 * sin(angle));
|
||||
len = (float)(sqrt(u * u + v * v));
|
||||
u /= len;
|
||||
v /= len;
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f((float)(r2*cos(angle+da)), (float)(r2*sin(angle+da)), (float)(width*0.5));
|
||||
glVertex3f((float)(r2*cos(angle+da)), (float)(r2*sin(angle+da)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r2 * cos(angle + da)), (float)(r2 * sin(angle + da)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r2 * cos(angle + da)), (float)(r2 * sin(angle + da)), (float)(-width * 0.5));
|
||||
glNormal3f((float)(cos(angle)), (float)(sin(angle)), 0.0);
|
||||
glVertex3f((float)(r2*cos(angle+2*da)), (float)(r2*sin(angle+2*da)), (float)(width*0.5));
|
||||
glVertex3f((float)(r2*cos(angle+2*da)), (float)(r2*sin(angle+2*da)), (float)(-width*0.5));
|
||||
u = (float)(r1*cos(angle+3*da) - r2*cos(angle+2*da));
|
||||
v = (float)(r1*sin(angle+3*da) - r2*sin(angle+2*da));
|
||||
glVertex3f((float)(r2 * cos(angle + 2 * da)), (float)(r2 * sin(angle + 2 * da)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r2 * cos(angle + 2 * da)), (float)(r2 * sin(angle + 2 * da)), (float)(-width * 0.5));
|
||||
u = (float)(r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da));
|
||||
v = (float)(r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da));
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f((float)(r1*cos(angle+3*da)), (float)(r1*sin(angle+3*da)), (float)(width*0.5));
|
||||
glVertex3f((float)(r1*cos(angle+3*da)), (float)(r1*sin(angle+3*da)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r1 * cos(angle + 3 * da)), (float)(r1 * sin(angle + 3 * da)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r1 * cos(angle + 3 * da)), (float)(r1 * sin(angle + 3 * da)), (float)(-width * 0.5));
|
||||
glNormal3f((float)(cos(angle)), (float)(sin(angle)), 0.0);
|
||||
}
|
||||
glVertex3f((float)(r1*cos(0.0)), (float)(r1*sin(0.0)), (float)(width*0.5));
|
||||
glVertex3f((float)(r1*cos(0.0)), (float)(r1*sin(0.0)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r1 * cos(0.0)), (float)(r1 * sin(0.0)), (float)(width * 0.5));
|
||||
glVertex3f((float)(r1 * cos(0.0)), (float)(r1 * sin(0.0)), (float)(-width * 0.5));
|
||||
glEnd();
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/* draw inside radius cylinder */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i=0;i<=teeth;i++) {
|
||||
angle = (float)(i * 2.0*pi / teeth);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = (float)(i * 2.0 * pi / teeth);
|
||||
glNormal3f((float)(-cos(angle)), (float)(-sin(angle)), 0.0);
|
||||
glVertex3f((float)(r0*cos(angle)), (float)(r0*sin(angle)), (float)(-width*0.5));
|
||||
glVertex3f((float)(r0*cos(angle)), (float)(r0*sin(angle)), (float)(width*0.5));
|
||||
glVertex3f((float)(r0 * cos(angle)), (float)(r0 * sin(angle)), (float)(-width * 0.5));
|
||||
glVertex3f((float)(r0 * cos(angle)), (float)(r0 * sin(angle)), (float)(width * 0.5));
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
@@ -201,20 +201,20 @@ static void drawGearGL(int id)
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case 1:
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ared);
|
||||
gearGL(1.0f, 4.0f, 1.0f, 20, 0.7f);
|
||||
break;
|
||||
case 2:
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, agreen);
|
||||
gearGL(0.5f, 2.0f, 2.0f, 10, 0.7f);
|
||||
break;
|
||||
case 3:
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ablue);
|
||||
gearGL(1.3f, 2.0f, 0.5f, 10, 0.7f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 1:
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ared);
|
||||
gearGL(1.0f, 4.0f, 1.0f, 20, 0.7f);
|
||||
break;
|
||||
case 2:
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, agreen);
|
||||
gearGL(0.5f, 2.0f, 2.0f, 10, 0.7f);
|
||||
break;
|
||||
case 3:
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ablue);
|
||||
gearGL(1.3f, 2.0f, 0.5f, 10, 0.7f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
glEnable(GL_NORMALIZE);
|
||||
}
|
||||
@@ -238,14 +238,14 @@ static void drawGL(void)
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(3.1f, -2.0f, 0.0f);
|
||||
glRotatef((float)(-2.0*fAngle-9.0), 0.0, 0.0, 1.0);
|
||||
glRotatef((float)(-2.0 * fAngle - 9.0), 0.0, 0.0, 1.0);
|
||||
drawGearGL(2);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.1f, 2.2f, -1.8f);
|
||||
glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef((float)(2.0*fAngle-2.0), 0.0, 0.0, 1.0);
|
||||
glRotatef((float)(2.0 * fAngle - 2.0), 0.0, 0.0, 1.0);
|
||||
drawGearGL(3);
|
||||
glPopMatrix();
|
||||
|
||||
@@ -274,7 +274,7 @@ static void setViewPortGL(GHOST_WindowHandle hWindow)
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -40.0);
|
||||
|
||||
glClearColor(.2f,0.0f,0.0f,0.0f);
|
||||
glClearColor(.2f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
GHOST_DisposeRectangle(hRect);
|
||||
@@ -287,44 +287,43 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
int handled = 1;
|
||||
int cursor;
|
||||
int visibility;
|
||||
GHOST_TEventKeyData* keyData = NULL;
|
||||
GHOST_TEventWheelData* wheelData = NULL;
|
||||
GHOST_TEventKeyData *keyData = NULL;
|
||||
GHOST_TEventWheelData *wheelData = NULL;
|
||||
GHOST_DisplaySetting setting;
|
||||
GHOST_WindowHandle window = GHOST_GetEventWindow(hEvent);
|
||||
|
||||
switch (GHOST_GetEventType(hEvent))
|
||||
{
|
||||
/*
|
||||
case GHOST_kEventUnknown:
|
||||
break;
|
||||
case GHOST_kEventCursorButton:
|
||||
break;
|
||||
case GHOST_kEventCursorMove:
|
||||
break;
|
||||
*/
|
||||
case GHOST_kEventWheel:
|
||||
/*
|
||||
case GHOST_kEventUnknown:
|
||||
break;
|
||||
case GHOST_kEventCursorButton:
|
||||
break;
|
||||
case GHOST_kEventCursorMove:
|
||||
break;
|
||||
*/
|
||||
case GHOST_kEventWheel:
|
||||
{
|
||||
wheelData = (GHOST_TEventWheelData*)GHOST_GetEventData(hEvent);
|
||||
if (wheelData->z > 0)
|
||||
{
|
||||
view_rotz += 5.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
view_rotz -= 5.f;
|
||||
}
|
||||
wheelData = (GHOST_TEventWheelData *)GHOST_GetEventData(hEvent);
|
||||
if (wheelData->z > 0)
|
||||
{
|
||||
view_rotz += 5.f;
|
||||
}
|
||||
else {
|
||||
view_rotz -= 5.f;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GHOST_kEventKeyUp:
|
||||
break;
|
||||
case GHOST_kEventKeyUp:
|
||||
break;
|
||||
|
||||
case GHOST_kEventKeyDown:
|
||||
case GHOST_kEventKeyDown:
|
||||
{
|
||||
keyData = (GHOST_TEventKeyData*)GHOST_GetEventData(hEvent);
|
||||
keyData = (GHOST_TEventKeyData *)GHOST_GetEventData(hEvent);
|
||||
switch (keyData->key)
|
||||
{
|
||||
case GHOST_kKeyC:
|
||||
case GHOST_kKeyC:
|
||||
{
|
||||
cursor = sCursor;
|
||||
cursor++;
|
||||
@@ -336,62 +335,60 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
GHOST_SetCursorShape(window, sCursor);
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyF:
|
||||
if (!GHOST_GetFullScreen(shSystem))
|
||||
{
|
||||
/* Begin fullscreen mode */
|
||||
setting.bpp = 24;
|
||||
setting.frequency = 85;
|
||||
setting.xPixels = 640;
|
||||
setting.yPixels = 480;
|
||||
|
||||
/*
|
||||
setting.bpp = 16;
|
||||
setting.frequency = 75;
|
||||
setting.xPixels = 640;
|
||||
setting.yPixels = 480;
|
||||
*/
|
||||
case GHOST_kKeyF:
|
||||
if (!GHOST_GetFullScreen(shSystem))
|
||||
{
|
||||
/* Begin fullscreen mode */
|
||||
setting.bpp = 24;
|
||||
setting.frequency = 85;
|
||||
setting.xPixels = 640;
|
||||
setting.yPixels = 480;
|
||||
|
||||
sFullScreenWindow = GHOST_BeginFullScreen(shSystem, &setting,
|
||||
/*
|
||||
setting.bpp = 16;
|
||||
setting.frequency = 75;
|
||||
setting.xPixels = 640;
|
||||
setting.yPixels = 480;
|
||||
*/
|
||||
|
||||
FALSE /* stereo flag */);
|
||||
}
|
||||
else
|
||||
{
|
||||
GHOST_EndFullScreen(shSystem);
|
||||
sFullScreenWindow = 0;
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyH:
|
||||
sFullScreenWindow = GHOST_BeginFullScreen(shSystem, &setting,
|
||||
|
||||
FALSE /* stereo flag */);
|
||||
}
|
||||
else {
|
||||
GHOST_EndFullScreen(shSystem);
|
||||
sFullScreenWindow = 0;
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyH:
|
||||
{
|
||||
visibility = GHOST_GetCursorVisibility(window);
|
||||
GHOST_SetCursorVisibility(window, !visibility);
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyQ:
|
||||
if (GHOST_GetFullScreen(shSystem))
|
||||
{
|
||||
GHOST_EndFullScreen(shSystem);
|
||||
sFullScreenWindow = 0;
|
||||
}
|
||||
sExitRequested = 1;
|
||||
case GHOST_kKeyT:
|
||||
if (!sTestTimer)
|
||||
{
|
||||
sTestTimer = GHOST_InstallTimer(shSystem, 0, 1000, testTimerProc, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GHOST_RemoveTimer(shSystem, sTestTimer);
|
||||
sTestTimer = 0;
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyW:
|
||||
case GHOST_kKeyQ:
|
||||
if (GHOST_GetFullScreen(shSystem))
|
||||
{
|
||||
GHOST_EndFullScreen(shSystem);
|
||||
sFullScreenWindow = 0;
|
||||
}
|
||||
sExitRequested = 1;
|
||||
case GHOST_kKeyT:
|
||||
if (!sTestTimer)
|
||||
{
|
||||
sTestTimer = GHOST_InstallTimer(shSystem, 0, 1000, testTimerProc, NULL);
|
||||
}
|
||||
else {
|
||||
GHOST_RemoveTimer(shSystem, sTestTimer);
|
||||
sTestTimer = 0;
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyW:
|
||||
{
|
||||
if (sMainWindow)
|
||||
{
|
||||
char *title = GHOST_GetTitle(sMainWindow);
|
||||
char *ntitle = malloc(strlen(title)+2);
|
||||
char *ntitle = malloc(strlen(title) + 2);
|
||||
|
||||
sprintf(ntitle, "%s-", title);
|
||||
GHOST_SetTitle(sMainWindow, ntitle);
|
||||
@@ -401,21 +398,20 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GHOST_kEventWindowClose:
|
||||
case GHOST_kEventWindowClose:
|
||||
{
|
||||
GHOST_WindowHandle window2 = GHOST_GetEventWindow(hEvent);
|
||||
if (window2 == sMainWindow)
|
||||
{
|
||||
sExitRequested = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (sGearsTimer)
|
||||
{
|
||||
GHOST_RemoveTimer(shSystem, sGearsTimer);
|
||||
@@ -426,13 +422,13 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
}
|
||||
break;
|
||||
|
||||
case GHOST_kEventWindowActivate:
|
||||
handled = 0;
|
||||
break;
|
||||
case GHOST_kEventWindowDeactivate:
|
||||
handled = 0;
|
||||
break;
|
||||
case GHOST_kEventWindowUpdate:
|
||||
case GHOST_kEventWindowActivate:
|
||||
handled = 0;
|
||||
break;
|
||||
case GHOST_kEventWindowDeactivate:
|
||||
handled = 0;
|
||||
break;
|
||||
case GHOST_kEventWindowUpdate:
|
||||
{
|
||||
GHOST_WindowHandle window2 = GHOST_GetEventWindow(hEvent);
|
||||
if (!GHOST_ValidWindow(shSystem, window2))
|
||||
@@ -443,18 +439,18 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
handled = 0;
|
||||
break;
|
||||
default:
|
||||
handled = 0;
|
||||
break;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char* title1 = "gears - main window";
|
||||
char* title2 = "gears - secondary window";
|
||||
char *title1 = "gears - main window";
|
||||
char *title2 = "gears - secondary window";
|
||||
GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(processEvent, NULL);
|
||||
|
||||
/* Create the system */
|
||||
@@ -465,15 +461,15 @@ int main(int argc, char** argv)
|
||||
{
|
||||
/* Create the main window */
|
||||
sMainWindow = GHOST_CreateWindow(shSystem,
|
||||
title1,
|
||||
10,
|
||||
64,
|
||||
320,
|
||||
200,
|
||||
GHOST_kWindowStateNormal,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
FALSE,
|
||||
FALSE);
|
||||
title1,
|
||||
10,
|
||||
64,
|
||||
320,
|
||||
200,
|
||||
GHOST_kWindowStateNormal,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
FALSE,
|
||||
FALSE);
|
||||
if (!sMainWindow)
|
||||
{
|
||||
printf("could not create main window\n");
|
||||
@@ -482,15 +478,15 @@ int main(int argc, char** argv)
|
||||
|
||||
/* Create a secondary window */
|
||||
sSecondaryWindow = GHOST_CreateWindow(shSystem,
|
||||
title2,
|
||||
340,
|
||||
64,
|
||||
320,
|
||||
200,
|
||||
GHOST_kWindowStateNormal,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
FALSE,
|
||||
FALSE);
|
||||
title2,
|
||||
340,
|
||||
64,
|
||||
320,
|
||||
200,
|
||||
GHOST_kWindowStateNormal,
|
||||
GHOST_kDrawingContextTypeOpenGL,
|
||||
FALSE,
|
||||
FALSE);
|
||||
if (!sSecondaryWindow)
|
||||
{
|
||||
printf("could not create secondary window\n");
|
||||
@@ -498,11 +494,11 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
/* Install a timer to have the gears running */
|
||||
sGearsTimer = GHOST_InstallTimer(shSystem,
|
||||
0,
|
||||
10,
|
||||
gearsTimerProc,
|
||||
sMainWindow);
|
||||
sGearsTimer = GHOST_InstallTimer(shSystem,
|
||||
0,
|
||||
10,
|
||||
gearsTimerProc,
|
||||
sMainWindow);
|
||||
|
||||
/* Enter main loop */
|
||||
while (!sExitRequested)
|
||||
@@ -547,8 +543,7 @@ static void gearsTimerProc(GHOST_TimerTaskHandle hTask, GHOST_TUns64 time)
|
||||
/* Running full screen */
|
||||
GHOST_InvalidateWindow(sFullScreenWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (GHOST_ValidWindow(shSystem, hWindow))
|
||||
{
|
||||
GHOST_InvalidateWindow(hWindow);
|
||||
|
||||
@@ -40,17 +40,17 @@
|
||||
#include <math.h>
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <atlbase.h>
|
||||
# ifdef WIN32
|
||||
# include <windows.h>
|
||||
# include <atlbase.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#else // WIN32
|
||||
# include <GL/gl.h>
|
||||
# else // WIN32
|
||||
// __APPLE__ is defined
|
||||
#include <AGL/gl.h>
|
||||
#endif // WIN32
|
||||
# include <AGL/gl.h>
|
||||
# endif // WIN32
|
||||
#else // defined(WIN32) || defined(__APPLE__)
|
||||
#include <GL/gl.h>
|
||||
# include <GL/gl.h>
|
||||
#endif // defined(WIN32) || defined(__APPLE__)
|
||||
|
||||
#include "STR_String.h"
|
||||
|
||||
@@ -27,37 +27,47 @@
|
||||
|
||||
#include "Basic.h"
|
||||
|
||||
int min_i(int a, int b) {
|
||||
return (a<b)?a:b;
|
||||
int min_i(int a, int b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
int max_i(int a, int b) {
|
||||
return (b<a)?a:b;
|
||||
int max_i(int a, int b)
|
||||
{
|
||||
return (b < a) ? a : b;
|
||||
}
|
||||
int clamp_i(int val, int min, int max) {
|
||||
int clamp_i(int val, int min, int max)
|
||||
{
|
||||
return min_i(max_i(val, min), max);
|
||||
}
|
||||
|
||||
float min_f(float a, float b) {
|
||||
return (a<b)?a:b;
|
||||
float min_f(float a, float b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
float max_f(float a, float b) {
|
||||
return (b<a)?a:b;
|
||||
float max_f(float a, float b)
|
||||
{
|
||||
return (b < a) ? a : b;
|
||||
}
|
||||
float clamp_f(float val, float min, float max) {
|
||||
float clamp_f(float val, float min, float max)
|
||||
{
|
||||
return min_f(max_f(val, min), max);
|
||||
}
|
||||
|
||||
void rect_copy(int dst[2][2], int src[2][2]) {
|
||||
dst[0][0]= src[0][0], dst[0][1]= src[0][1];
|
||||
dst[1][0]= src[1][0], dst[1][1]= src[1][1];
|
||||
void rect_copy(int dst[2][2], int src[2][2])
|
||||
{
|
||||
dst[0][0] = src[0][0], dst[0][1] = src[0][1];
|
||||
dst[1][0] = src[1][0], dst[1][1] = src[1][1];
|
||||
}
|
||||
int rect_contains_pt(int rect[2][2], int pt[2]){
|
||||
int rect_contains_pt(int rect[2][2], int pt[2])
|
||||
{
|
||||
return ((rect[0][0] <= pt[0] && pt[0] <= rect[1][0]) &&
|
||||
(rect[0][1] <= pt[1] && pt[1] <= rect[1][1]));
|
||||
(rect[0][1] <= pt[1] && pt[1] <= rect[1][1]));
|
||||
}
|
||||
int rect_width(int rect[2][2]) {
|
||||
return (rect[1][0]-rect[0][0]);
|
||||
int rect_width(int rect[2][2])
|
||||
{
|
||||
return (rect[1][0] - rect[0][0]);
|
||||
}
|
||||
int rect_height(int rect[2][2]) {
|
||||
return (rect[1][1]-rect[0][1]);
|
||||
int rect_height(int rect[2][2])
|
||||
{
|
||||
return (rect[1][1] - rect[0][1]);
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
# include "BMF_Api.h"
|
||||
#else
|
||||
# include "BLF_api.h"
|
||||
extern int datatoc_bfont_ttf_size;
|
||||
extern char datatoc_bfont_ttf[];
|
||||
extern int datatoc_bfont_ttf_size;
|
||||
extern char datatoc_bfont_ttf[];
|
||||
|
||||
/* cheat */
|
||||
char U[1024]= {0};
|
||||
/* cheat */
|
||||
char U[1024] = {0};
|
||||
#endif
|
||||
|
||||
#include "Util.h"
|
||||
@@ -76,47 +76,47 @@ void multitestapp_exit(MultiTestApp *app);
|
||||
/**/
|
||||
|
||||
void rect_bevel_side(int rect[2][2], int side, float *lt, float *dk, float *col, int width) {
|
||||
int ltidx= (side/2)%4;
|
||||
int dkidx= (ltidx + 1 + (side&1))%4;
|
||||
int ltidx = (side / 2) % 4;
|
||||
int dkidx = (ltidx + 1 + (side & 1)) % 4;
|
||||
int i, corner;
|
||||
|
||||
glBegin(GL_LINES);
|
||||
for (i=0; i<width; i++) {
|
||||
float ltf= pow(lt[i], 1.0/2.2), dkf= pow(dk[i], 1.0/2.2);
|
||||
float stf= (dkidx>ltidx)?dkf:ltf;
|
||||
int lx= rect[1][0]-i-1;
|
||||
int ly= rect[0][1]+i;
|
||||
|
||||
glColor3f(col[0]*stf, col[1]*stf, col[2]*stf);
|
||||
for (corner=0; corner<4; corner++) {
|
||||
int x= (corner==0 || corner==1)?(rect[0][0]+i):(rect[1][0]-i-1);
|
||||
int y= (corner==0 || corner==3)?(rect[0][1]+i):(rect[1][1]-i-1);
|
||||
for (i = 0; i < width; i++) {
|
||||
float ltf = pow(lt[i], 1.0 / 2.2), dkf = pow(dk[i], 1.0 / 2.2);
|
||||
float stf = (dkidx > ltidx) ? dkf : ltf;
|
||||
int lx = rect[1][0] - i - 1;
|
||||
int ly = rect[0][1] + i;
|
||||
|
||||
if (ltidx==corner)
|
||||
glColor3f(col[0]*ltf, col[1]*ltf, col[2]*ltf);
|
||||
if (dkidx==corner)
|
||||
glColor3f(col[0]*dkf, col[1]*dkf, col[2]*dkf);
|
||||
glColor3f(col[0] * stf, col[1] * stf, col[2] * stf);
|
||||
for (corner = 0; corner < 4; corner++) {
|
||||
int x = (corner == 0 || corner == 1) ? (rect[0][0] + i) : (rect[1][0] - i - 1);
|
||||
int y = (corner == 0 || corner == 3) ? (rect[0][1] + i) : (rect[1][1] - i - 1);
|
||||
|
||||
if (ltidx == corner)
|
||||
glColor3f(col[0] * ltf, col[1] * ltf, col[2] * ltf);
|
||||
if (dkidx == corner)
|
||||
glColor3f(col[0] * dkf, col[1] * dkf, col[2] * dkf);
|
||||
|
||||
glVertex2i(lx, ly);
|
||||
glVertex2i(lx= x, ly= y);
|
||||
glVertex2i(lx = x, ly = y);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glColor3fv(col);
|
||||
glRecti(rect[0][0]+width, rect[0][1]+width, rect[1][0]-width, rect[1][1]-width);
|
||||
glRecti(rect[0][0] + width, rect[0][1] + width, rect[1][0] - width, rect[1][1] - width);
|
||||
}
|
||||
|
||||
void rect_bevel_smooth(int rect[2][2], int width) {
|
||||
float *lt= malloc(sizeof(*lt)*width);
|
||||
float *dk= malloc(sizeof(*dk)*width);
|
||||
float *lt = malloc(sizeof(*lt) * width);
|
||||
float *dk = malloc(sizeof(*dk) * width);
|
||||
float col[4];
|
||||
int i;
|
||||
|
||||
for (i=0; i<width; i++) {
|
||||
float v= width-1?((float) i/(width-1)):0;
|
||||
lt[i]= 1.2 + (1.0-1.2)*v;
|
||||
dk[i]= 0.2 + (1.0-0.2)*v;
|
||||
for (i = 0; i < width; i++) {
|
||||
float v = width - 1 ? ((float) i / (width - 1)) : 0;
|
||||
lt[i] = 1.2 + (1.0 - 1.2) * v;
|
||||
dk[i] = 0.2 + (1.0 - 0.2) * v;
|
||||
}
|
||||
|
||||
glGetFloatv(GL_CURRENT_COLOR, col);
|
||||
@@ -127,20 +127,20 @@ void rect_bevel_smooth(int rect[2][2], int width) {
|
||||
free(dk);
|
||||
}
|
||||
|
||||
/*
|
||||
* MainWindow
|
||||
*/
|
||||
/*
|
||||
* MainWindow
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
MultiTestApp *app;
|
||||
MultiTestApp *app;
|
||||
|
||||
GHOST_WindowHandle win;
|
||||
GHOST_WindowHandle win;
|
||||
|
||||
int size[2];
|
||||
int size[2];
|
||||
|
||||
int lmouse[2], lmbut[3];
|
||||
int lmouse[2], lmbut[3];
|
||||
|
||||
int tmouse[2];
|
||||
int tmouse[2];
|
||||
} MainWindow;
|
||||
|
||||
static void mainwindow_log(MainWindow *mw, char *str) {
|
||||
@@ -152,24 +152,25 @@ static void mainwindow_do_draw(MainWindow *mw) {
|
||||
|
||||
if (mw->lmbut[0]) {
|
||||
glClearColor(0.5, 0.5, 0.5, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
glClearColor(1, 1, 1, 1);
|
||||
}
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glColor3f(0.5, 0.6, 0.8);
|
||||
glRecti(mw->tmouse[0]-5, mw->tmouse[1]-5, mw->tmouse[0]+5, mw->tmouse[1]+5);
|
||||
glRecti(mw->tmouse[0] - 5, mw->tmouse[1] - 5, mw->tmouse[0] + 5, mw->tmouse[1] + 5);
|
||||
|
||||
GHOST_SwapWindowBuffers(mw->win);
|
||||
}
|
||||
|
||||
static void mainwindow_do_reshape(MainWindow *mw) {
|
||||
GHOST_RectangleHandle bounds= GHOST_GetClientBounds(mw->win);
|
||||
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(mw->win);
|
||||
|
||||
GHOST_ActivateWindowDrawingContext(mw->win);
|
||||
|
||||
mw->size[0]= GHOST_GetWidthRectangle(bounds);
|
||||
mw->size[1]= GHOST_GetHeightRectangle(bounds);
|
||||
mw->size[0] = GHOST_GetWidthRectangle(bounds);
|
||||
mw->size[1] = GHOST_GetHeightRectangle(bounds);
|
||||
|
||||
glViewport(0, 0, mw->size[0], mw->size[1]);
|
||||
|
||||
@@ -183,176 +184,179 @@ static void mainwindow_do_reshape(MainWindow *mw) {
|
||||
}
|
||||
|
||||
static void mainwindow_do_key(MainWindow *mw, GHOST_TKey key, int press) {
|
||||
switch(key) {
|
||||
case GHOST_kKeyC:
|
||||
if (press)
|
||||
GHOST_SetCursorShape(mw->win, (GHOST_TStandardCursor) (rand()%(GHOST_kStandardCursorNumCursors)));
|
||||
break;
|
||||
case GHOST_kKeyLeftBracket:
|
||||
if (press)
|
||||
GHOST_SetCursorVisibility(mw->win, 0);
|
||||
break;
|
||||
case GHOST_kKeyRightBracket:
|
||||
if (press)
|
||||
GHOST_SetCursorVisibility(mw->win, 1);
|
||||
break;
|
||||
case GHOST_kKeyE:
|
||||
if (press)
|
||||
multitestapp_toggle_extra_window(mw->app);
|
||||
break;
|
||||
case GHOST_kKeyQ:
|
||||
if (press)
|
||||
multitestapp_exit(mw->app);
|
||||
break;
|
||||
case GHOST_kKeyT:
|
||||
if (press)
|
||||
mainwindow_log(mw, "TextTest~|`hello`\"world\",<>/");
|
||||
break;
|
||||
case GHOST_kKeyR:
|
||||
if (press) {
|
||||
int i;
|
||||
|
||||
mainwindow_log(mw, "Invalidating window 10 times");
|
||||
for (i=0; i<10; i++)
|
||||
GHOST_InvalidateWindow(mw->win);
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyF11:
|
||||
if (press) {
|
||||
GHOST_SetWindowOrder(mw->win, GHOST_kWindowOrderBottom);
|
||||
}
|
||||
break;
|
||||
switch (key) {
|
||||
case GHOST_kKeyC:
|
||||
if (press)
|
||||
GHOST_SetCursorShape(mw->win, (GHOST_TStandardCursor) (rand() % (GHOST_kStandardCursorNumCursors)));
|
||||
break;
|
||||
case GHOST_kKeyLeftBracket:
|
||||
if (press)
|
||||
GHOST_SetCursorVisibility(mw->win, 0);
|
||||
break;
|
||||
case GHOST_kKeyRightBracket:
|
||||
if (press)
|
||||
GHOST_SetCursorVisibility(mw->win, 1);
|
||||
break;
|
||||
case GHOST_kKeyE:
|
||||
if (press)
|
||||
multitestapp_toggle_extra_window(mw->app);
|
||||
break;
|
||||
case GHOST_kKeyQ:
|
||||
if (press)
|
||||
multitestapp_exit(mw->app);
|
||||
break;
|
||||
case GHOST_kKeyT:
|
||||
if (press)
|
||||
mainwindow_log(mw, "TextTest~|`hello`\"world\",<>/");
|
||||
break;
|
||||
case GHOST_kKeyR:
|
||||
if (press) {
|
||||
int i;
|
||||
|
||||
mainwindow_log(mw, "Invalidating window 10 times");
|
||||
for (i = 0; i < 10; i++)
|
||||
GHOST_InvalidateWindow(mw->win);
|
||||
}
|
||||
break;
|
||||
case GHOST_kKeyF11:
|
||||
if (press) {
|
||||
GHOST_SetWindowOrder(mw->win, GHOST_kWindowOrderBottom);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void mainwindow_do_move(MainWindow *mw, int x, int y) {
|
||||
mw->lmouse[0]= x, mw->lmouse[1]= y;
|
||||
mw->lmouse[0] = x, mw->lmouse[1] = y;
|
||||
|
||||
if (mw->lmbut[0]) {
|
||||
mw->tmouse[0]= x, mw->tmouse[1]= y;
|
||||
mw->tmouse[0] = x, mw->tmouse[1] = y;
|
||||
GHOST_InvalidateWindow(mw->win);
|
||||
}
|
||||
}
|
||||
|
||||
static void mainwindow_do_button(MainWindow *mw, int which, int press) {
|
||||
if (which==GHOST_kButtonMaskLeft) {
|
||||
mw->lmbut[0]= press;
|
||||
mw->tmouse[0]= mw->lmouse[0], mw->tmouse[1]= mw->lmouse[1];
|
||||
if (which == GHOST_kButtonMaskLeft) {
|
||||
mw->lmbut[0] = press;
|
||||
mw->tmouse[0] = mw->lmouse[0], mw->tmouse[1] = mw->lmouse[1];
|
||||
GHOST_InvalidateWindow(mw->win);
|
||||
} else if (which==GHOST_kButtonMaskLeft) {
|
||||
mw->lmbut[1]= press;
|
||||
} else if (which==GHOST_kButtonMaskLeft) {
|
||||
mw->lmbut[2]= press;
|
||||
}
|
||||
else if (which == GHOST_kButtonMaskLeft) {
|
||||
mw->lmbut[1] = press;
|
||||
}
|
||||
else if (which == GHOST_kButtonMaskLeft) {
|
||||
mw->lmbut[2] = press;
|
||||
}
|
||||
}
|
||||
|
||||
static void mainwindow_handle(void *priv, GHOST_EventHandle evt) {
|
||||
MainWindow *mw= priv;
|
||||
GHOST_TEventType type= GHOST_GetEventType(evt);
|
||||
MainWindow *mw = priv;
|
||||
GHOST_TEventType type = GHOST_GetEventType(evt);
|
||||
char buf[256];
|
||||
|
||||
event_to_buf(evt, buf);
|
||||
mainwindow_log(mw, buf);
|
||||
|
||||
switch (type) {
|
||||
case GHOST_kEventCursorMove: {
|
||||
GHOST_TEventCursorData *cd= GHOST_GetEventData(evt);
|
||||
int x, y;
|
||||
GHOST_ScreenToClient(mw->win, cd->x, cd->y, &x, &y);
|
||||
mainwindow_do_move(mw, x, mw->size[1]-y-1);
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventButtonDown:
|
||||
case GHOST_kEventButtonUp: {
|
||||
GHOST_TEventButtonData *bd= GHOST_GetEventData(evt);
|
||||
mainwindow_do_button(mw, bd->button, (type == GHOST_kEventButtonDown));
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventKeyDown:
|
||||
case GHOST_kEventKeyUp: {
|
||||
GHOST_TEventKeyData *kd= GHOST_GetEventData(evt);
|
||||
mainwindow_do_key(mw, kd->key, (type == GHOST_kEventKeyDown));
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventCursorMove: {
|
||||
GHOST_TEventCursorData *cd = GHOST_GetEventData(evt);
|
||||
int x, y;
|
||||
GHOST_ScreenToClient(mw->win, cd->x, cd->y, &x, &y);
|
||||
mainwindow_do_move(mw, x, mw->size[1] - y - 1);
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventButtonDown:
|
||||
case GHOST_kEventButtonUp: {
|
||||
GHOST_TEventButtonData *bd = GHOST_GetEventData(evt);
|
||||
mainwindow_do_button(mw, bd->button, (type == GHOST_kEventButtonDown));
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventKeyDown:
|
||||
case GHOST_kEventKeyUp: {
|
||||
GHOST_TEventKeyData *kd = GHOST_GetEventData(evt);
|
||||
mainwindow_do_key(mw, kd->key, (type == GHOST_kEventKeyDown));
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventWindowUpdate:
|
||||
mainwindow_do_draw(mw);
|
||||
break;
|
||||
case GHOST_kEventWindowSize:
|
||||
mainwindow_do_reshape(mw);
|
||||
break;
|
||||
case GHOST_kEventWindowUpdate:
|
||||
mainwindow_do_draw(mw);
|
||||
break;
|
||||
case GHOST_kEventWindowSize:
|
||||
mainwindow_do_reshape(mw);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
static void mainwindow_timer_proc(GHOST_TimerTaskHandle task, GHOST_TUns64 time) {
|
||||
MainWindow *mw= GHOST_GetTimerTaskUserData(task);
|
||||
MainWindow *mw = GHOST_GetTimerTaskUserData(task);
|
||||
char buf[64];
|
||||
|
||||
sprintf(buf, "timer: %6.2f", (double) ((GHOST_TInt64) time)/1000);
|
||||
sprintf(buf, "timer: %6.2f", (double) ((GHOST_TInt64) time) / 1000);
|
||||
mainwindow_log(mw, buf);
|
||||
}
|
||||
|
||||
MainWindow *mainwindow_new(MultiTestApp *app) {
|
||||
GHOST_SystemHandle sys= multitestapp_get_system(app);
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(app);
|
||||
GHOST_WindowHandle win;
|
||||
|
||||
win= GHOST_CreateWindow(sys, "MultiTest:Main", 40, 40, 400, 400,
|
||||
GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL,
|
||||
FALSE, FALSE);
|
||||
win = GHOST_CreateWindow(sys, "MultiTest:Main", 40, 40, 400, 400,
|
||||
GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL,
|
||||
FALSE, FALSE);
|
||||
|
||||
if (win) {
|
||||
MainWindow *mw= MEM_callocN(sizeof(*mw), "mainwindow_new");
|
||||
mw->app= app;
|
||||
mw->win= win;
|
||||
MainWindow *mw = MEM_callocN(sizeof(*mw), "mainwindow_new");
|
||||
mw->app = app;
|
||||
mw->win = win;
|
||||
|
||||
GHOST_SetWindowUserData(mw->win, windowdata_new(mw, mainwindow_handle));
|
||||
|
||||
GHOST_InstallTimer(sys, 1000, 10000, mainwindow_timer_proc, mw);
|
||||
|
||||
return mw;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void mainwindow_free(MainWindow *mw) {
|
||||
GHOST_SystemHandle sys= multitestapp_get_system(mw->app);
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(mw->app);
|
||||
|
||||
windowdata_free(GHOST_GetWindowUserData(mw->win));
|
||||
GHOST_DisposeWindow(sys, mw->win);
|
||||
MEM_freeN(mw);
|
||||
}
|
||||
|
||||
/*
|
||||
* LoggerWindow
|
||||
*/
|
||||
/*
|
||||
* LoggerWindow
|
||||
*/
|
||||
|
||||
struct _LoggerWindow {
|
||||
MultiTestApp *app;
|
||||
MultiTestApp *app;
|
||||
|
||||
GHOST_WindowHandle win;
|
||||
GHOST_WindowHandle win;
|
||||
|
||||
#ifdef USE_BMF
|
||||
BMF_Font *font;
|
||||
BMF_Font *font;
|
||||
#else
|
||||
int font;
|
||||
int font;
|
||||
#endif
|
||||
int fonttexid;
|
||||
int fontheight;
|
||||
int fonttexid;
|
||||
int fontheight;
|
||||
|
||||
int size[2];
|
||||
int size[2];
|
||||
|
||||
int ndisplines;
|
||||
int textarea[2][2];
|
||||
ScrollBar *scroll;
|
||||
int ndisplines;
|
||||
int textarea[2][2];
|
||||
ScrollBar *scroll;
|
||||
|
||||
char **loglines;
|
||||
int nloglines, logsize;
|
||||
char **loglines;
|
||||
int nloglines, logsize;
|
||||
|
||||
int lmbut[3];
|
||||
int lmouse[2];
|
||||
int lmbut[3];
|
||||
int lmouse[2];
|
||||
};
|
||||
|
||||
#define SCROLLBAR_PAD 2
|
||||
@@ -361,19 +365,19 @@ struct _LoggerWindow {
|
||||
static void loggerwindow_recalc_regions(LoggerWindow *lw) {
|
||||
int nscroll[2][2];
|
||||
|
||||
nscroll[0][0]= SCROLLBAR_PAD;
|
||||
nscroll[0][1]= SCROLLBAR_PAD;
|
||||
nscroll[1][0]= nscroll[0][0] + SCROLLBAR_WIDTH;
|
||||
nscroll[1][1]= lw->size[1] - SCROLLBAR_PAD - 1;
|
||||
nscroll[0][0] = SCROLLBAR_PAD;
|
||||
nscroll[0][1] = SCROLLBAR_PAD;
|
||||
nscroll[1][0] = nscroll[0][0] + SCROLLBAR_WIDTH;
|
||||
nscroll[1][1] = lw->size[1] - SCROLLBAR_PAD - 1;
|
||||
|
||||
lw->textarea[0][0]= nscroll[1][0] + TEXTAREA_PAD;
|
||||
lw->textarea[0][1]= TEXTAREA_PAD;
|
||||
lw->textarea[1][0]= lw->size[0] - TEXTAREA_PAD - 1;
|
||||
lw->textarea[1][1]= lw->size[1] - TEXTAREA_PAD - 1;
|
||||
lw->textarea[0][0] = nscroll[1][0] + TEXTAREA_PAD;
|
||||
lw->textarea[0][1] = TEXTAREA_PAD;
|
||||
lw->textarea[1][0] = lw->size[0] - TEXTAREA_PAD - 1;
|
||||
lw->textarea[1][1] = lw->size[1] - TEXTAREA_PAD - 1;
|
||||
|
||||
lw->ndisplines= (lw->textarea[1][1]-lw->textarea[0][1])/lw->fontheight;
|
||||
lw->ndisplines = (lw->textarea[1][1] - lw->textarea[0][1]) / lw->fontheight;
|
||||
|
||||
scrollbar_set_thumbpct(lw->scroll, (float) lw->ndisplines/lw->nloglines);
|
||||
scrollbar_set_thumbpct(lw->scroll, (float) lw->ndisplines / lw->nloglines);
|
||||
scrollbar_set_rect(lw->scroll, nscroll);
|
||||
}
|
||||
|
||||
@@ -390,12 +394,12 @@ static void loggerwindow_setup_window_gl(LoggerWindow *lw) {
|
||||
}
|
||||
|
||||
static void loggerwindow_do_reshape(LoggerWindow *lw) {
|
||||
GHOST_RectangleHandle bounds= GHOST_GetClientBounds(lw->win);
|
||||
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(lw->win);
|
||||
|
||||
GHOST_ActivateWindowDrawingContext(lw->win);
|
||||
|
||||
lw->size[0]= GHOST_GetWidthRectangle(bounds);
|
||||
lw->size[1]= GHOST_GetHeightRectangle(bounds);
|
||||
lw->size[0] = GHOST_GetWidthRectangle(bounds);
|
||||
lw->size[1] = GHOST_GetHeightRectangle(bounds);
|
||||
|
||||
loggerwindow_recalc_regions(lw);
|
||||
loggerwindow_setup_window_gl(lw);
|
||||
@@ -421,15 +425,16 @@ static void loggerwindow_do_draw(LoggerWindow *lw) {
|
||||
|
||||
if (scrollbar_is_scrolling(lw->scroll)) {
|
||||
glColor3f(0.6, 0.7, 0.5);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
glColor3f(0.9, 0.9, 0.92);
|
||||
}
|
||||
rect_bevel_smooth(sb_thumb, 1);
|
||||
|
||||
startline= scrollbar_get_thumbpos(lw->scroll)*(lw->nloglines-1);
|
||||
ndisplines= min_i(lw->ndisplines, lw->nloglines-startline);
|
||||
startline = scrollbar_get_thumbpos(lw->scroll) * (lw->nloglines - 1);
|
||||
ndisplines = min_i(lw->ndisplines, lw->nloglines - startline);
|
||||
|
||||
if (lw->fonttexid!=-1) {
|
||||
if (lw->fonttexid != -1) {
|
||||
glBindTexture(GL_TEXTURE_2D, lw->fonttexid);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -437,17 +442,18 @@ static void loggerwindow_do_draw(LoggerWindow *lw) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
glColor3f(0, 0, 0);
|
||||
for (i=0; i<ndisplines; i++) {
|
||||
/* stored in reverse order */
|
||||
char *line= lw->loglines[(lw->nloglines-1)-(i+startline)];
|
||||
int x_pos= lw->textarea[0][0] + 4;
|
||||
int y_pos= lw->textarea[0][1] + 4 + i*lw->fontheight;
|
||||
for (i = 0; i < ndisplines; i++) {
|
||||
/* stored in reverse order */
|
||||
char *line = lw->loglines[(lw->nloglines - 1) - (i + startline)];
|
||||
int x_pos = lw->textarea[0][0] + 4;
|
||||
int y_pos = lw->textarea[0][1] + 4 + i * lw->fontheight;
|
||||
|
||||
#ifdef USE_BMF
|
||||
if (lw->fonttexid==-1) {
|
||||
if (lw->fonttexid == -1) {
|
||||
glRasterPos2i(x_pos, y_pos);
|
||||
BMF_DrawString(lw->font, line);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BMF_DrawStringTexture(lw->font, line, x_pos, y_pos, 0.0);
|
||||
}
|
||||
#else
|
||||
@@ -457,7 +463,7 @@ static void loggerwindow_do_draw(LoggerWindow *lw) {
|
||||
}
|
||||
|
||||
#ifdef USE_BMF
|
||||
if (lw->fonttexid!=-1) {
|
||||
if (lw->fonttexid != -1) {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
@@ -467,7 +473,7 @@ static void loggerwindow_do_draw(LoggerWindow *lw) {
|
||||
}
|
||||
|
||||
static void loggerwindow_do_move(LoggerWindow *lw, int x, int y) {
|
||||
lw->lmouse[0]= x, lw->lmouse[1]= y;
|
||||
lw->lmouse[0] = x, lw->lmouse[1] = y;
|
||||
|
||||
if (scrollbar_is_scrolling(lw->scroll)) {
|
||||
scrollbar_keep_scrolling(lw->scroll, y);
|
||||
@@ -476,8 +482,8 @@ static void loggerwindow_do_move(LoggerWindow *lw, int x, int y) {
|
||||
}
|
||||
|
||||
static void loggerwindow_do_button(LoggerWindow *lw, int which, int press) {
|
||||
if (which==GHOST_kButtonMaskLeft) {
|
||||
lw->lmbut[0]= press;
|
||||
if (which == GHOST_kButtonMaskLeft) {
|
||||
lw->lmbut[0] = press;
|
||||
|
||||
if (press) {
|
||||
if (scrollbar_contains_pt(lw->scroll, lw->lmouse)) {
|
||||
@@ -485,124 +491,128 @@ static void loggerwindow_do_button(LoggerWindow *lw, int which, int press) {
|
||||
GHOST_SetCursorShape(lw->win, GHOST_kStandardCursorUpDown);
|
||||
GHOST_InvalidateWindow(lw->win);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (scrollbar_is_scrolling(lw->scroll)) {
|
||||
scrollbar_stop_scrolling(lw->scroll);
|
||||
GHOST_SetCursorShape(lw->win, GHOST_kStandardCursorDefault);
|
||||
GHOST_InvalidateWindow(lw->win);
|
||||
}
|
||||
}
|
||||
} else if (which==GHOST_kButtonMaskMiddle) {
|
||||
lw->lmbut[1]= press;
|
||||
} else if (which==GHOST_kButtonMaskRight) {
|
||||
lw->lmbut[2]= press;
|
||||
}
|
||||
else if (which == GHOST_kButtonMaskMiddle) {
|
||||
lw->lmbut[1] = press;
|
||||
}
|
||||
else if (which == GHOST_kButtonMaskRight) {
|
||||
lw->lmbut[2] = press;
|
||||
}
|
||||
}
|
||||
|
||||
static void loggerwindow_do_key(LoggerWindow *lw, GHOST_TKey key, int press) {
|
||||
switch (key) {
|
||||
case GHOST_kKeyQ:
|
||||
if (press)
|
||||
multitestapp_exit(lw->app);
|
||||
break;
|
||||
case GHOST_kKeyQ:
|
||||
if (press)
|
||||
multitestapp_exit(lw->app);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void loggerwindow_handle(void *priv, GHOST_EventHandle evt) {
|
||||
LoggerWindow *lw= priv;
|
||||
GHOST_TEventType type= GHOST_GetEventType(evt);
|
||||
LoggerWindow *lw = priv;
|
||||
GHOST_TEventType type = GHOST_GetEventType(evt);
|
||||
|
||||
switch(type) {
|
||||
case GHOST_kEventCursorMove: {
|
||||
GHOST_TEventCursorData *cd= GHOST_GetEventData(evt);
|
||||
int x, y;
|
||||
GHOST_ScreenToClient(lw->win, cd->x, cd->y, &x, &y);
|
||||
loggerwindow_do_move(lw, x, lw->size[1]-y-1);
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventButtonDown:
|
||||
case GHOST_kEventButtonUp: {
|
||||
GHOST_TEventButtonData *bd= GHOST_GetEventData(evt);
|
||||
loggerwindow_do_button(lw, bd->button, (type == GHOST_kEventButtonDown));
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventKeyDown:
|
||||
case GHOST_kEventKeyUp: {
|
||||
GHOST_TEventKeyData *kd= GHOST_GetEventData(evt);
|
||||
loggerwindow_do_key(lw, kd->key, (type == GHOST_kEventKeyDown));
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventWindowUpdate:
|
||||
loggerwindow_do_draw(lw);
|
||||
break;
|
||||
case GHOST_kEventWindowSize:
|
||||
loggerwindow_do_reshape(lw);
|
||||
break;
|
||||
switch (type) {
|
||||
case GHOST_kEventCursorMove: {
|
||||
GHOST_TEventCursorData *cd = GHOST_GetEventData(evt);
|
||||
int x, y;
|
||||
GHOST_ScreenToClient(lw->win, cd->x, cd->y, &x, &y);
|
||||
loggerwindow_do_move(lw, x, lw->size[1] - y - 1);
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventButtonDown:
|
||||
case GHOST_kEventButtonUp: {
|
||||
GHOST_TEventButtonData *bd = GHOST_GetEventData(evt);
|
||||
loggerwindow_do_button(lw, bd->button, (type == GHOST_kEventButtonDown));
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventKeyDown:
|
||||
case GHOST_kEventKeyUp: {
|
||||
GHOST_TEventKeyData *kd = GHOST_GetEventData(evt);
|
||||
loggerwindow_do_key(lw, kd->key, (type == GHOST_kEventKeyDown));
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventWindowUpdate:
|
||||
loggerwindow_do_draw(lw);
|
||||
break;
|
||||
case GHOST_kEventWindowSize:
|
||||
loggerwindow_do_reshape(lw);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
LoggerWindow *loggerwindow_new(MultiTestApp *app) {
|
||||
GHOST_SystemHandle sys= multitestapp_get_system(app);
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(app);
|
||||
GHOST_TUns32 screensize[2];
|
||||
GHOST_WindowHandle win;
|
||||
|
||||
GHOST_GetMainDisplayDimensions(sys, &screensize[0], &screensize[1]);
|
||||
win= GHOST_CreateWindow(sys, "MultiTest:Logger", 40, screensize[1]-432,
|
||||
800, 300, GHOST_kWindowStateNormal,
|
||||
GHOST_kDrawingContextTypeOpenGL, FALSE, FALSE);
|
||||
win = GHOST_CreateWindow(sys, "MultiTest:Logger", 40, screensize[1] - 432,
|
||||
800, 300, GHOST_kWindowStateNormal,
|
||||
GHOST_kDrawingContextTypeOpenGL, FALSE, FALSE);
|
||||
|
||||
if (win) {
|
||||
LoggerWindow *lw= MEM_callocN(sizeof(*lw), "loggerwindow_new");
|
||||
LoggerWindow *lw = MEM_callocN(sizeof(*lw), "loggerwindow_new");
|
||||
int bbox[2][2];
|
||||
lw->app= app;
|
||||
lw->win= win;
|
||||
lw->app = app;
|
||||
lw->win = win;
|
||||
|
||||
#ifdef USE_BMF
|
||||
lw->font= BMF_GetFont(BMF_kScreen12);
|
||||
lw->fonttexid= BMF_GetFontTexture(lw->font);
|
||||
lw->font = BMF_GetFont(BMF_kScreen12);
|
||||
lw->fonttexid = BMF_GetFontTexture(lw->font);
|
||||
|
||||
BMF_GetBoundingBox(lw->font, &bbox[0][0], &bbox[0][1], &bbox[1][0], &bbox[1][1]);
|
||||
lw->fontheight= rect_height(bbox);
|
||||
lw->fontheight = rect_height(bbox);
|
||||
#else
|
||||
lw->font= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
|
||||
lw->font = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
|
||||
BLF_size(lw->font, 11, 72);
|
||||
lw->fontheight= BLF_height(lw->font, "A_");
|
||||
lw->fontheight = BLF_height(lw->font, "A_");
|
||||
#endif
|
||||
|
||||
lw->nloglines= lw->logsize= 0;
|
||||
lw->loglines= MEM_mallocN(sizeof(*lw->loglines)*lw->nloglines, "loglines");
|
||||
lw->nloglines = lw->logsize = 0;
|
||||
lw->loglines = MEM_mallocN(sizeof(*lw->loglines) * lw->nloglines, "loglines");
|
||||
|
||||
lw->scroll= scrollbar_new(2, 40);
|
||||
lw->scroll = scrollbar_new(2, 40);
|
||||
|
||||
GHOST_SetWindowUserData(lw->win, windowdata_new(lw, loggerwindow_handle));
|
||||
|
||||
loggerwindow_do_reshape(lw);
|
||||
|
||||
return lw;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void loggerwindow_log(LoggerWindow *lw, char *line) {
|
||||
if (lw->nloglines==lw->logsize) {
|
||||
lw->loglines= memdbl(lw->loglines, &lw->logsize, sizeof(*lw->loglines));
|
||||
if (lw->nloglines == lw->logsize) {
|
||||
lw->loglines = memdbl(lw->loglines, &lw->logsize, sizeof(*lw->loglines));
|
||||
}
|
||||
|
||||
lw->loglines[lw->nloglines++]= string_dup(line);
|
||||
scrollbar_set_thumbpct(lw->scroll, (float) lw->ndisplines/lw->nloglines);
|
||||
lw->loglines[lw->nloglines++] = string_dup(line);
|
||||
scrollbar_set_thumbpct(lw->scroll, (float) lw->ndisplines / lw->nloglines);
|
||||
|
||||
GHOST_InvalidateWindow(lw->win);
|
||||
}
|
||||
|
||||
void loggerwindow_free(LoggerWindow *lw) {
|
||||
GHOST_SystemHandle sys= multitestapp_get_system(lw->app);
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(lw->app);
|
||||
int i;
|
||||
|
||||
for (i=0; i<lw->nloglines; i++) {
|
||||
for (i = 0; i < lw->nloglines; i++) {
|
||||
MEM_freeN(lw->loglines[i]);
|
||||
}
|
||||
MEM_freeN(lw->loglines);
|
||||
@@ -612,17 +622,17 @@ void loggerwindow_free(LoggerWindow *lw) {
|
||||
MEM_freeN(lw);
|
||||
}
|
||||
|
||||
/*
|
||||
* ExtraWindow
|
||||
*/
|
||||
/*
|
||||
* ExtraWindow
|
||||
*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
MultiTestApp *app;
|
||||
MultiTestApp *app;
|
||||
|
||||
GHOST_WindowHandle win;
|
||||
GHOST_WindowHandle win;
|
||||
|
||||
int size[2];
|
||||
int size[2];
|
||||
} ExtraWindow;
|
||||
|
||||
static void extrawindow_do_draw(ExtraWindow *ew) {
|
||||
@@ -632,18 +642,18 @@ static void extrawindow_do_draw(ExtraWindow *ew) {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glColor3f(0.8, 0.8, 0.8);
|
||||
glRecti(10, 10, ew->size[0]-10, ew->size[1]-10);
|
||||
glRecti(10, 10, ew->size[0] - 10, ew->size[1] - 10);
|
||||
|
||||
GHOST_SwapWindowBuffers(ew->win);
|
||||
}
|
||||
|
||||
static void extrawindow_do_reshape(ExtraWindow *ew) {
|
||||
GHOST_RectangleHandle bounds= GHOST_GetClientBounds(ew->win);
|
||||
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(ew->win);
|
||||
|
||||
GHOST_ActivateWindowDrawingContext(ew->win);
|
||||
|
||||
ew->size[0]= GHOST_GetWidthRectangle(bounds);
|
||||
ew->size[1]= GHOST_GetHeightRectangle(bounds);
|
||||
ew->size[0] = GHOST_GetWidthRectangle(bounds);
|
||||
ew->size[1] = GHOST_GetHeightRectangle(bounds);
|
||||
|
||||
glViewport(0, 0, ew->size[0], ew->size[1]);
|
||||
|
||||
@@ -658,18 +668,18 @@ static void extrawindow_do_reshape(ExtraWindow *ew) {
|
||||
|
||||
static void extrawindow_do_key(ExtraWindow *ew, GHOST_TKey key, int press) {
|
||||
switch (key) {
|
||||
case GHOST_kKeyE:
|
||||
if (press)
|
||||
multitestapp_toggle_extra_window(ew->app);
|
||||
break;
|
||||
case GHOST_kKeyE:
|
||||
if (press)
|
||||
multitestapp_toggle_extra_window(ew->app);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void extrawindow_spin_cursor(ExtraWindow *ew, GHOST_TUns64 time) {
|
||||
GHOST_TUns8 bitmap[16][2];
|
||||
GHOST_TUns8 mask[16][2];
|
||||
double ftime= (double) ((GHOST_TInt64) time)/1000;
|
||||
float angle= fmod(ftime, 1.0) * 3.1415*2;
|
||||
double ftime = (double) ((GHOST_TInt64) time) / 1000;
|
||||
float angle = fmod(ftime, 1.0) * 3.1415 * 2;
|
||||
int i;
|
||||
|
||||
memset(&bitmap, 0, sizeof(bitmap));
|
||||
@@ -680,128 +690,130 @@ static void extrawindow_spin_cursor(ExtraWindow *ew, GHOST_TUns64 time) {
|
||||
bitmap[2][0] |= mask[2][0] |= 0xF;
|
||||
bitmap[3][0] |= mask[3][0] |= 0xF;
|
||||
|
||||
for (i=0; i<7; i++) {
|
||||
int x = 7 + cos(angle)*i;
|
||||
int y = 7 + sin(angle)*i;
|
||||
|
||||
mask[y][x/8] |= (1 << (x%8));
|
||||
for (i = 0; i < 7; i++) {
|
||||
int x = 7 + cos(angle) * i;
|
||||
int y = 7 + sin(angle) * i;
|
||||
|
||||
mask[y][x / 8] |= (1 << (x % 8));
|
||||
}
|
||||
for (i=0; i<64; i++) {
|
||||
float v= (i/63.0) * 3.1415*2;
|
||||
int x = 7 + cos(v)*7;
|
||||
int y = 7 + sin(v)*7;
|
||||
for (i = 0; i < 64; i++) {
|
||||
float v = (i / 63.0) * 3.1415 * 2;
|
||||
int x = 7 + cos(v) * 7;
|
||||
int y = 7 + sin(v) * 7;
|
||||
|
||||
mask[y][x/8] |= (1 << (x%8));
|
||||
mask[y][x / 8] |= (1 << (x % 8));
|
||||
}
|
||||
|
||||
GHOST_SetCustomCursorShape(ew->win, bitmap, mask, 0, 0);
|
||||
}
|
||||
|
||||
static void extrawindow_handle(void *priv, GHOST_EventHandle evt) {
|
||||
ExtraWindow *ew= priv;
|
||||
GHOST_TEventType type= GHOST_GetEventType(evt);
|
||||
ExtraWindow *ew = priv;
|
||||
GHOST_TEventType type = GHOST_GetEventType(evt);
|
||||
char buf[256];
|
||||
|
||||
event_to_buf(evt, buf);
|
||||
loggerwindow_log(multitestapp_get_logger(ew->app), buf);
|
||||
|
||||
switch (type) {
|
||||
case GHOST_kEventKeyDown:
|
||||
case GHOST_kEventKeyUp: {
|
||||
GHOST_TEventKeyData *kd= GHOST_GetEventData(evt);
|
||||
extrawindow_do_key(ew, kd->key, (type == GHOST_kEventKeyDown));
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventKeyDown:
|
||||
case GHOST_kEventKeyUp: {
|
||||
GHOST_TEventKeyData *kd = GHOST_GetEventData(evt);
|
||||
extrawindow_do_key(ew, kd->key, (type == GHOST_kEventKeyDown));
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventCursorMove: {
|
||||
extrawindow_spin_cursor(ew, GHOST_GetEventTime(evt));
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventWindowClose:
|
||||
multitestapp_free_extrawindow(ew->app);
|
||||
break;
|
||||
case GHOST_kEventWindowUpdate:
|
||||
extrawindow_do_draw(ew);
|
||||
break;
|
||||
case GHOST_kEventWindowSize:
|
||||
extrawindow_do_reshape(ew);
|
||||
break;
|
||||
case GHOST_kEventCursorMove: {
|
||||
extrawindow_spin_cursor(ew, GHOST_GetEventTime(evt));
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventWindowClose:
|
||||
multitestapp_free_extrawindow(ew->app);
|
||||
break;
|
||||
case GHOST_kEventWindowUpdate:
|
||||
extrawindow_do_draw(ew);
|
||||
break;
|
||||
case GHOST_kEventWindowSize:
|
||||
extrawindow_do_reshape(ew);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
ExtraWindow *extrawindow_new(MultiTestApp *app) {
|
||||
GHOST_SystemHandle sys= multitestapp_get_system(app);
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(app);
|
||||
GHOST_WindowHandle win;
|
||||
|
||||
win= GHOST_CreateWindow(sys, "MultiTest:Extra", 500, 40, 400, 400,
|
||||
GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL,
|
||||
FALSE, FALSE);
|
||||
win = GHOST_CreateWindow(sys, "MultiTest:Extra", 500, 40, 400, 400,
|
||||
GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL,
|
||||
FALSE, FALSE);
|
||||
|
||||
if (win) {
|
||||
ExtraWindow *ew= MEM_callocN(sizeof(*ew), "mainwindow_new");
|
||||
ew->app= app;
|
||||
ew->win= win;
|
||||
ExtraWindow *ew = MEM_callocN(sizeof(*ew), "mainwindow_new");
|
||||
ew->app = app;
|
||||
ew->win = win;
|
||||
|
||||
GHOST_SetWindowUserData(ew->win, windowdata_new(ew, extrawindow_handle));
|
||||
|
||||
return ew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void extrawindow_free(ExtraWindow *ew) {
|
||||
GHOST_SystemHandle sys= multitestapp_get_system(ew->app);
|
||||
GHOST_SystemHandle sys = multitestapp_get_system(ew->app);
|
||||
|
||||
windowdata_free(GHOST_GetWindowUserData(ew->win));
|
||||
GHOST_DisposeWindow(sys, ew->win);
|
||||
MEM_freeN(ew);
|
||||
}
|
||||
|
||||
/*
|
||||
* MultiTestApp
|
||||
*/
|
||||
/*
|
||||
* MultiTestApp
|
||||
*/
|
||||
|
||||
struct _MultiTestApp {
|
||||
GHOST_SystemHandle sys;
|
||||
MainWindow *main;
|
||||
LoggerWindow *logger;
|
||||
ExtraWindow *extra;
|
||||
GHOST_SystemHandle sys;
|
||||
MainWindow *main;
|
||||
LoggerWindow *logger;
|
||||
ExtraWindow *extra;
|
||||
|
||||
int exit;
|
||||
int exit;
|
||||
};
|
||||
|
||||
static int multitest_event_handler(GHOST_EventHandle evt, GHOST_TUserDataPtr data) {
|
||||
MultiTestApp *app= data;
|
||||
MultiTestApp *app = data;
|
||||
GHOST_WindowHandle win;
|
||||
|
||||
win= GHOST_GetEventWindow(evt);
|
||||
win = GHOST_GetEventWindow(evt);
|
||||
if (win && !GHOST_ValidWindow(app->sys, win)) {
|
||||
loggerwindow_log(app->logger, "WARNING: bad event, non-valid window\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (win) {
|
||||
WindowData *wb= GHOST_GetWindowUserData(win);
|
||||
WindowData *wb = GHOST_GetWindowUserData(win);
|
||||
|
||||
windowdata_handle(wb, evt);
|
||||
} else {
|
||||
GHOST_TEventType type= GHOST_GetEventType(evt);
|
||||
|
||||
/* GHOST_kEventQuit are the only 'system' events,
|
||||
* that is, events without a window.
|
||||
*/
|
||||
switch(type) {
|
||||
case GHOST_kEventQuit:
|
||||
app->exit= 1;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
GHOST_TEventType type = GHOST_GetEventType(evt);
|
||||
|
||||
default:
|
||||
fatal("Unhandled system event: %d (%s)\n", type, eventtype_to_string(type));
|
||||
break;
|
||||
/* GHOST_kEventQuit are the only 'system' events,
|
||||
* that is, events without a window.
|
||||
*/
|
||||
switch (type) {
|
||||
case GHOST_kEventQuit:
|
||||
app->exit = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
fatal("Unhandled system event: %d (%s)\n", type, eventtype_to_string(type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -811,26 +823,26 @@ static int multitest_event_handler(GHOST_EventHandle evt, GHOST_TUserDataPtr dat
|
||||
/**/
|
||||
|
||||
MultiTestApp *multitestapp_new(void) {
|
||||
MultiTestApp *app= MEM_mallocN(sizeof(*app), "multitestapp_new");
|
||||
GHOST_EventConsumerHandle consumer= GHOST_CreateEventConsumer(multitest_event_handler, app);
|
||||
MultiTestApp *app = MEM_mallocN(sizeof(*app), "multitestapp_new");
|
||||
GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(multitest_event_handler, app);
|
||||
|
||||
app->sys= GHOST_CreateSystem();
|
||||
app->sys = GHOST_CreateSystem();
|
||||
if (!app->sys)
|
||||
fatal("Unable to create ghost system");
|
||||
|
||||
if (!GHOST_AddEventConsumer(app->sys, consumer))
|
||||
fatal("Unable to add multitest event consumer ");
|
||||
|
||||
app->main= mainwindow_new(app);
|
||||
app->main = mainwindow_new(app);
|
||||
if (!app->main)
|
||||
fatal("Unable to create main window");
|
||||
|
||||
app->logger= loggerwindow_new(app);
|
||||
app->logger = loggerwindow_new(app);
|
||||
if (!app->logger)
|
||||
fatal("Unable to create logger window");
|
||||
|
||||
app->extra= NULL;
|
||||
app->exit= 0;
|
||||
app->extra = NULL;
|
||||
app->exit = 0;
|
||||
|
||||
return app;
|
||||
}
|
||||
@@ -845,19 +857,20 @@ GHOST_SystemHandle multitestapp_get_system(MultiTestApp *app) {
|
||||
|
||||
void multitestapp_free_extrawindow(MultiTestApp *app) {
|
||||
extrawindow_free(app->extra);
|
||||
app->extra= NULL;
|
||||
app->extra = NULL;
|
||||
}
|
||||
|
||||
void multitestapp_toggle_extra_window(MultiTestApp *app) {
|
||||
if (app->extra) {
|
||||
multitestapp_free_extrawindow(app);
|
||||
} else {
|
||||
app->extra= extrawindow_new(app);
|
||||
}
|
||||
else {
|
||||
app->extra = extrawindow_new(app);
|
||||
}
|
||||
}
|
||||
|
||||
void multitestapp_exit(MultiTestApp *app) {
|
||||
app->exit= 1;
|
||||
app->exit = 1;
|
||||
}
|
||||
|
||||
void multitestapp_run(MultiTestApp *app) {
|
||||
@@ -874,14 +887,14 @@ void multitestapp_free(MultiTestApp *app) {
|
||||
MEM_freeN(app);
|
||||
}
|
||||
|
||||
/***/
|
||||
/***/
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#ifndef USE_BMF
|
||||
BLF_init(11, 72);
|
||||
#endif
|
||||
|
||||
MultiTestApp *app= multitestapp_new();
|
||||
MultiTestApp *app = multitestapp_new();
|
||||
|
||||
multitestapp_run(app);
|
||||
multitestapp_free(app);
|
||||
|
||||
@@ -35,107 +35,124 @@
|
||||
#include "ScrollBar.h"
|
||||
|
||||
struct _ScrollBar {
|
||||
int rect[2][2];
|
||||
float thumbpos, thumbpct;
|
||||
int rect[2][2];
|
||||
float thumbpos, thumbpct;
|
||||
|
||||
int inset;
|
||||
int minthumb;
|
||||
int inset;
|
||||
int minthumb;
|
||||
|
||||
int scrolling;
|
||||
float scrolloffs;
|
||||
int scrolling;
|
||||
float scrolloffs;
|
||||
};
|
||||
|
||||
static int scrollbar_get_thumbH(ScrollBar *sb) {
|
||||
int scrollable_h= rect_height(sb->rect) - 2*sb->inset;
|
||||
static int scrollbar_get_thumbH(ScrollBar *sb)
|
||||
{
|
||||
int scrollable_h = rect_height(sb->rect) - 2 * sb->inset;
|
||||
|
||||
return clamp_i(sb->thumbpct*scrollable_h, sb->minthumb, scrollable_h);
|
||||
return clamp_i(sb->thumbpct * scrollable_h, sb->minthumb, scrollable_h);
|
||||
}
|
||||
static int scrollbar_get_thumbableH(ScrollBar *sb) {
|
||||
int scrollable_h= rect_height(sb->rect) - 2*sb->inset;
|
||||
int thumb_h= scrollbar_get_thumbH(sb);
|
||||
|
||||
static int scrollbar_get_thumbableH(ScrollBar *sb)
|
||||
{
|
||||
int scrollable_h = rect_height(sb->rect) - 2 * sb->inset;
|
||||
int thumb_h = scrollbar_get_thumbH(sb);
|
||||
|
||||
return scrollable_h - thumb_h;
|
||||
}
|
||||
|
||||
static float scrollbar_co_to_pos(ScrollBar *sb, int yco) {
|
||||
int thumb_h= scrollbar_get_thumbH(sb);
|
||||
int thumbable_h= scrollbar_get_thumbableH(sb);
|
||||
int thumbable_y= (sb->rect[0][1]+sb->inset) + thumb_h/2;
|
||||
static float scrollbar_co_to_pos(ScrollBar *sb, int yco)
|
||||
{
|
||||
int thumb_h = scrollbar_get_thumbH(sb);
|
||||
int thumbable_h = scrollbar_get_thumbableH(sb);
|
||||
int thumbable_y = (sb->rect[0][1] + sb->inset) + thumb_h / 2;
|
||||
|
||||
return (float) (yco-thumbable_y)/thumbable_h;
|
||||
return (float) (yco - thumbable_y) / thumbable_h;
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
ScrollBar *scrollbar_new(int inset, int minthumb) {
|
||||
ScrollBar *sb= MEM_callocN(sizeof(*sb), "scrollbar_new");
|
||||
sb->inset= inset;
|
||||
sb->minthumb= minthumb;
|
||||
ScrollBar *scrollbar_new(int inset, int minthumb)
|
||||
{
|
||||
ScrollBar *sb = MEM_callocN(sizeof(*sb), "scrollbar_new");
|
||||
sb->inset = inset;
|
||||
sb->minthumb = minthumb;
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
void scrollbar_get_thumb(ScrollBar *sb, int thumb_r[2][2]) {
|
||||
int thumb_h= scrollbar_get_thumbH(sb);
|
||||
int thumbable_h= scrollbar_get_thumbableH(sb);
|
||||
void scrollbar_get_thumb(ScrollBar *sb, int thumb_r[2][2])
|
||||
{
|
||||
int thumb_h = scrollbar_get_thumbH(sb);
|
||||
int thumbable_h = scrollbar_get_thumbableH(sb);
|
||||
|
||||
thumb_r[0][0]= sb->rect[0][0]+sb->inset;
|
||||
thumb_r[1][0]= sb->rect[1][0]-sb->inset;
|
||||
thumb_r[0][0] = sb->rect[0][0] + sb->inset;
|
||||
thumb_r[1][0] = sb->rect[1][0] - sb->inset;
|
||||
|
||||
thumb_r[0][1]= sb->rect[0][1]+sb->inset + sb->thumbpos*thumbable_h;
|
||||
thumb_r[1][1]= thumb_r[0][1] + thumb_h;
|
||||
thumb_r[0][1] = sb->rect[0][1] + sb->inset + sb->thumbpos * thumbable_h;
|
||||
thumb_r[1][1] = thumb_r[0][1] + thumb_h;
|
||||
}
|
||||
|
||||
int scrollbar_is_scrolling(ScrollBar *sb) {
|
||||
int scrollbar_is_scrolling(ScrollBar *sb)
|
||||
{
|
||||
return sb->scrolling;
|
||||
}
|
||||
int scrollbar_contains_pt(ScrollBar *sb, int pt[2]) {
|
||||
return rect_contains_pt(sb->rect, pt);
|
||||
}
|
||||
|
||||
void scrollbar_start_scrolling(ScrollBar *sb, int yco) {
|
||||
int thumb_h_2= scrollbar_get_thumbH(sb)/2;
|
||||
int thumbable_h= scrollbar_get_thumbableH(sb);
|
||||
float npos= scrollbar_co_to_pos(sb, yco);
|
||||
void scrollbar_start_scrolling(ScrollBar *sb, int yco)
|
||||
{
|
||||
int thumb_h_2 = scrollbar_get_thumbH(sb) / 2;
|
||||
int thumbable_h = scrollbar_get_thumbableH(sb);
|
||||
float npos = scrollbar_co_to_pos(sb, yco);
|
||||
|
||||
sb->scrolloffs= sb->thumbpos - npos;
|
||||
if (fabs(sb->scrolloffs) >= (float) thumb_h_2/thumbable_h) {
|
||||
sb->scrolloffs= 0.0;
|
||||
sb->scrolloffs = sb->thumbpos - npos;
|
||||
if (fabs(sb->scrolloffs) >= (float) thumb_h_2 / thumbable_h) {
|
||||
sb->scrolloffs = 0.0;
|
||||
}
|
||||
|
||||
sb->scrolling= 1;
|
||||
sb->thumbpos= clamp_f(npos + sb->scrolloffs, 0.0, 1.0);
|
||||
sb->scrolling = 1;
|
||||
sb->thumbpos = clamp_f(npos + sb->scrolloffs, 0.0, 1.0);
|
||||
}
|
||||
void scrollbar_keep_scrolling(ScrollBar *sb, int yco) {
|
||||
float npos= scrollbar_co_to_pos(sb, yco);
|
||||
void scrollbar_keep_scrolling(ScrollBar *sb, int yco)
|
||||
{
|
||||
float npos = scrollbar_co_to_pos(sb, yco);
|
||||
|
||||
sb->thumbpos= clamp_f(npos + sb->scrolloffs, 0.0, 1.0);
|
||||
sb->thumbpos = clamp_f(npos + sb->scrolloffs, 0.0, 1.0);
|
||||
}
|
||||
void scrollbar_stop_scrolling(ScrollBar *sb) {
|
||||
sb->scrolling= 0;
|
||||
sb->scrolloffs= 0.0;
|
||||
void scrollbar_stop_scrolling(ScrollBar *sb)
|
||||
{
|
||||
sb->scrolling = 0;
|
||||
sb->scrolloffs = 0.0;
|
||||
}
|
||||
|
||||
void scrollbar_set_thumbpct(ScrollBar *sb, float pct) {
|
||||
sb->thumbpct= pct;
|
||||
void scrollbar_set_thumbpct(ScrollBar *sb, float pct)
|
||||
{
|
||||
sb->thumbpct = pct;
|
||||
}
|
||||
void scrollbar_set_thumbpos(ScrollBar *sb, float pos) {
|
||||
sb->thumbpos= clamp_f(pos, 0.0, 1.0);
|
||||
void scrollbar_set_thumbpos(ScrollBar *sb, float pos)
|
||||
{
|
||||
sb->thumbpos = clamp_f(pos, 0.0, 1.0);
|
||||
}
|
||||
void scrollbar_set_rect(ScrollBar *sb, int rect[2][2]) {
|
||||
void scrollbar_set_rect(ScrollBar *sb, int rect[2][2])
|
||||
{
|
||||
rect_copy(sb->rect, rect);
|
||||
}
|
||||
|
||||
float scrollbar_get_thumbpct(ScrollBar *sb) {
|
||||
float scrollbar_get_thumbpct(ScrollBar *sb)
|
||||
{
|
||||
return sb->thumbpct;
|
||||
}
|
||||
float scrollbar_get_thumbpos(ScrollBar *sb) {
|
||||
float scrollbar_get_thumbpos(ScrollBar *sb)
|
||||
{
|
||||
return sb->thumbpos;
|
||||
}
|
||||
void scrollbar_get_rect(ScrollBar *sb, int rect_r[2][2]) {
|
||||
void scrollbar_get_rect(ScrollBar *sb, int rect_r[2][2])
|
||||
{
|
||||
rect_copy(rect_r, sb->rect);
|
||||
}
|
||||
|
||||
void scrollbar_free(ScrollBar *sb) {
|
||||
void scrollbar_free(ScrollBar *sb)
|
||||
{
|
||||
MEM_freeN(sb);
|
||||
}
|
||||
|
||||
@@ -35,28 +35,31 @@
|
||||
|
||||
#include "Util.h"
|
||||
|
||||
void* memdbl(void *mem, int *size_pr, int item_size) {
|
||||
int cur_size= *size_pr;
|
||||
int new_size= cur_size?(cur_size*2):1;
|
||||
void *nmem= MEM_mallocN(new_size*item_size, "memdbl");
|
||||
void *memdbl(void *mem, int *size_pr, int item_size)
|
||||
{
|
||||
int cur_size = *size_pr;
|
||||
int new_size = cur_size ? (cur_size * 2) : 1;
|
||||
void *nmem = MEM_mallocN(new_size * item_size, "memdbl");
|
||||
|
||||
memcpy(nmem, mem, cur_size*item_size);
|
||||
memcpy(nmem, mem, cur_size * item_size);
|
||||
MEM_freeN(mem);
|
||||
|
||||
*size_pr= new_size;
|
||||
*size_pr = new_size;
|
||||
return nmem;
|
||||
}
|
||||
|
||||
char* string_dup(char *str) {
|
||||
int len= strlen(str);
|
||||
char *nstr= MEM_mallocN(len + 1, "string_dup");
|
||||
char *string_dup(char *str)
|
||||
{
|
||||
int len = strlen(str);
|
||||
char *nstr = MEM_mallocN(len + 1, "string_dup");
|
||||
|
||||
memcpy(nstr, str, len+1);
|
||||
memcpy(nstr, str, len + 1);
|
||||
|
||||
return nstr;
|
||||
}
|
||||
|
||||
void fatal(char *fmt, ...) {
|
||||
void fatal(char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "FATAL: ");
|
||||
|
||||
@@ -34,22 +34,25 @@
|
||||
#include "WindowData.h"
|
||||
|
||||
struct _WindowData {
|
||||
void *data;
|
||||
WindowDataHandler handler;
|
||||
void *data;
|
||||
WindowDataHandler handler;
|
||||
};
|
||||
|
||||
WindowData *windowdata_new(void *data, WindowDataHandler handler) {
|
||||
WindowData *wb= MEM_mallocN(sizeof(*wb), "windowdata_new");
|
||||
wb->data= data;
|
||||
wb->handler= handler;
|
||||
WindowData *windowdata_new(void *data, WindowDataHandler handler)
|
||||
{
|
||||
WindowData *wb = MEM_mallocN(sizeof(*wb), "windowdata_new");
|
||||
wb->data = data;
|
||||
wb->handler = handler;
|
||||
|
||||
return wb;
|
||||
}
|
||||
|
||||
void windowdata_handle(WindowData *wb, GHOST_EventHandle evt) {
|
||||
void windowdata_handle(WindowData *wb, GHOST_EventHandle evt)
|
||||
{
|
||||
wb->handler(wb->data, evt);
|
||||
}
|
||||
|
||||
void windowdata_free(WindowData *wb) {
|
||||
void windowdata_free(WindowData *wb)
|
||||
{
|
||||
MEM_freeN(wb);
|
||||
}
|
||||
|
||||
@@ -32,19 +32,19 @@
|
||||
/* ******************** GLOBAL VARIABLES ***************** */
|
||||
|
||||
|
||||
char name[24]= "Blur";
|
||||
char name[24] = "Blur";
|
||||
|
||||
/* structure for buttons,
|
||||
* butcode name default min max 0
|
||||
*/
|
||||
|
||||
VarStruct varstr[]= {
|
||||
LABEL, "Input: 1 strip", 0.0, 0.0, 0.0, "",
|
||||
NUMSLI|FLO, "Blur", 0.5, 0.0, 10.0, "Maximum filtersize",
|
||||
NUMSLI|FLO, "Gamma", 1.0, 0.4, 2.0, "Gamma correction",
|
||||
TOG|INT, "Animated", 0.0, 0.0, 1.0, "For (Ipo) animated blur",
|
||||
NUM|INT, "debug", 0.0, 0.0, 2.0,
|
||||
"0:off 1: show primary blur buffer 2: show 2nd blur buffer",
|
||||
VarStruct varstr[] = {
|
||||
LABEL, "Input: 1 strip", 0.0, 0.0, 0.0, "",
|
||||
NUMSLI | FLO, "Blur", 0.5, 0.0, 10.0, "Maximum filtersize",
|
||||
NUMSLI | FLO, "Gamma", 1.0, 0.4, 2.0, "Gamma correction",
|
||||
TOG | INT, "Animated", 0.0, 0.0, 1.0, "For (Ipo) animated blur",
|
||||
NUM | INT, "debug", 0.0, 0.0, 2.0,
|
||||
"0:off 1: show primary blur buffer 2: show 2nd blur buffer",
|
||||
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ VarStruct varstr[]= {
|
||||
Varstr and Cast must have the same variables in the same order */
|
||||
|
||||
typedef struct Cast {
|
||||
int dummy; /* because of the 'label' button */
|
||||
int dummy; /* because of the 'label' button */
|
||||
float blur;
|
||||
float gamma;
|
||||
float use_ipo;
|
||||
@@ -83,15 +83,15 @@ void plugin_init(void)
|
||||
|
||||
void plugin_getinfo(PluginInfo *info)
|
||||
{
|
||||
info->name= name;
|
||||
info->nvars= sizeof(varstr)/sizeof(VarStruct);
|
||||
info->cfra= &cfra;
|
||||
info->name = name;
|
||||
info->nvars = sizeof(varstr) / sizeof(VarStruct);
|
||||
info->cfra = &cfra;
|
||||
|
||||
info->varstr= varstr;
|
||||
info->varstr = varstr;
|
||||
|
||||
info->init= plugin_init;
|
||||
info->seq_doit= (SeqDoit) plugin_seq_doit;
|
||||
info->callback= plugin_but_changed;
|
||||
info->init = plugin_init;
|
||||
info->seq_doit = (SeqDoit) plugin_seq_doit;
|
||||
info->callback = plugin_but_changed;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,24 +102,24 @@ void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast)
|
||||
struct ImBuf *tbuf, *ttbuf;
|
||||
int i, x4;
|
||||
|
||||
tbuf= dupImBuf(ibuf);
|
||||
x4= ibuf->x/4;
|
||||
tbuf = dupImBuf(ibuf);
|
||||
x4 = ibuf->x / 4;
|
||||
|
||||
/* This doesn't seem to work... paprmh */
|
||||
if (cast->gamma != 1.0) gamwarp(tbuf, cast->gamma);
|
||||
|
||||
/* reduce */
|
||||
for (i=0; i<nr; i++) {
|
||||
for (i = 0; i < nr; i++) {
|
||||
ttbuf = onehalf(tbuf);
|
||||
if (ttbuf) {
|
||||
freeImBuf(tbuf);
|
||||
tbuf = ttbuf;
|
||||
}
|
||||
if (tbuf->x<4 || tbuf->y<4) break;
|
||||
if (tbuf->x < 4 || tbuf->y < 4) break;
|
||||
}
|
||||
|
||||
/* enlarge */
|
||||
for (i=0; i<nr; i++) {
|
||||
for (i = 0; i < nr; i++) {
|
||||
ttbuf = double_x(tbuf);
|
||||
if (ttbuf) {
|
||||
freeImBuf(tbuf);
|
||||
@@ -139,10 +139,10 @@ void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast)
|
||||
/* this doesn't seem to work...paprmh*/
|
||||
if (cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma);
|
||||
|
||||
if (ibuf->rect)memcpy(ibuf->rect, tbuf->rect, 4*ibuf->x*ibuf->y);
|
||||
if (ibuf->rect) memcpy(ibuf->rect, tbuf->rect, 4 * ibuf->x * ibuf->y);
|
||||
|
||||
if (ibuf->rect_float)
|
||||
memcpy(ibuf->rect_float, tbuf->rect_float, 4*ibuf->x*ibuf->y*sizeof(float));
|
||||
memcpy(ibuf->rect_float, tbuf->rect_float, 4 * ibuf->x * ibuf->y * sizeof(float));
|
||||
|
||||
freeImBuf(tbuf);
|
||||
|
||||
@@ -161,79 +161,79 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
||||
|
||||
/* which buffers ? */
|
||||
|
||||
if (fac>7.0) fac= 7.0;
|
||||
if (fac<=1.0) return;
|
||||
if (fac > 7.0) fac = 7.0;
|
||||
if (fac <= 1.0) return;
|
||||
|
||||
pfac= 2.0;
|
||||
pbuf= dupImBuf(mbuf);
|
||||
n= 1;
|
||||
pfac = 2.0;
|
||||
pbuf = dupImBuf(mbuf);
|
||||
n = 1;
|
||||
while (pfac < fac) {
|
||||
blurbuf(pbuf, n, cast);
|
||||
blurbuf(pbuf, n, cast);
|
||||
|
||||
n++;
|
||||
pfac+= 1.0;
|
||||
pfac += 1.0;
|
||||
}
|
||||
|
||||
ifac= pfac;
|
||||
pfac-= 1.0;
|
||||
ifac = pfac;
|
||||
pfac -= 1.0;
|
||||
|
||||
ibuf= dupImBuf(pbuf);
|
||||
ibuf = dupImBuf(pbuf);
|
||||
blurbuf(ibuf, n, cast);
|
||||
blurbuf(ibuf, n, cast);
|
||||
|
||||
fac= (fac-pfac)/(ifac-pfac);
|
||||
n= mbuf->x*mbuf->y;
|
||||
fac = (fac - pfac) / (ifac - pfac);
|
||||
n = mbuf->x * mbuf->y;
|
||||
|
||||
if (cast->show) fac=cast->show-1;
|
||||
if (cast->show) fac = cast->show - 1;
|
||||
|
||||
if (mbuf->rect_float){
|
||||
if (fac>=1) {
|
||||
memcpy(mbuf->rect_float, ibuf->rect_float, 4*n*sizeof(float));
|
||||
if (mbuf->rect_float) {
|
||||
if (fac >= 1) {
|
||||
memcpy(mbuf->rect_float, ibuf->rect_float, 4 * n * sizeof(float));
|
||||
}
|
||||
else if(fac<=0) {
|
||||
memcpy(mbuf->rect_float, pbuf->rect_float, 4*n*sizeof(float));
|
||||
else if (fac <= 0) {
|
||||
memcpy(mbuf->rect_float, pbuf->rect_float, 4 * n * sizeof(float));
|
||||
}
|
||||
else { /* interpolate */
|
||||
infac= 1-fac;
|
||||
else { /* interpolate */
|
||||
infac = 1 - fac;
|
||||
|
||||
irectf= (float *)ibuf->rect_float;
|
||||
prectf= (float *)pbuf->rect_float;
|
||||
mrectf= (float *)mbuf->rect_float;
|
||||
irectf = (float *)ibuf->rect_float;
|
||||
prectf = (float *)pbuf->rect_float;
|
||||
mrectf = (float *)mbuf->rect_float;
|
||||
while (n--) {
|
||||
mrectf[0]= irectf[0]*fac+ prectf[0]*infac;
|
||||
mrectf[1]= irectf[1]*fac+ prectf[1]*infac;
|
||||
mrectf[2]= irectf[2]*fac+ prectf[2]*infac;
|
||||
mrectf[3]= irectf[3]*fac+ prectf[3]*infac;
|
||||
mrectf+= 4;
|
||||
irectf+= 4;
|
||||
prectf+= 4;
|
||||
mrectf[0] = irectf[0] * fac + prectf[0] * infac;
|
||||
mrectf[1] = irectf[1] * fac + prectf[1] * infac;
|
||||
mrectf[2] = irectf[2] * fac + prectf[2] * infac;
|
||||
mrectf[3] = irectf[3] * fac + prectf[3] * infac;
|
||||
mrectf += 4;
|
||||
irectf += 4;
|
||||
prectf += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mbuf->rect){
|
||||
b1= (int)fac*255.0;
|
||||
if (b1>255) b1= 255;
|
||||
b2= 255-b1;
|
||||
|
||||
if (b1==255) {
|
||||
memcpy(mbuf->rect, ibuf->rect, 4*n);
|
||||
else if (mbuf->rect) {
|
||||
b1 = (int)fac * 255.0;
|
||||
if (b1 > 255) b1 = 255;
|
||||
b2 = 255 - b1;
|
||||
|
||||
if (b1 == 255) {
|
||||
memcpy(mbuf->rect, ibuf->rect, 4 * n);
|
||||
}
|
||||
else if(b1==0) {
|
||||
memcpy(mbuf->rect, pbuf->rect, 4*n);
|
||||
else if (b1 == 0) {
|
||||
memcpy(mbuf->rect, pbuf->rect, 4 * n);
|
||||
}
|
||||
else { /* interpolate */
|
||||
irect= (char *)ibuf->rect;
|
||||
prect= (char *)pbuf->rect;
|
||||
mrect= (char *)mbuf->rect;
|
||||
else { /* interpolate */
|
||||
irect = (char *)ibuf->rect;
|
||||
prect = (char *)pbuf->rect;
|
||||
mrect = (char *)mbuf->rect;
|
||||
while (n--) {
|
||||
mrect[0]= (irect[0]*b1+ prect[0]*b2)>>8;
|
||||
mrect[1]= (irect[1]*b1+ prect[1]*b2)>>8;
|
||||
mrect[2]= (irect[2]*b1+ prect[2]*b2)>>8;
|
||||
mrect[3]= (irect[3]*b1+ prect[3]*b2)>>8;
|
||||
mrect+= 4;
|
||||
irect+= 4;
|
||||
prect+= 4;
|
||||
mrect[0] = (irect[0] * b1 + prect[0] * b2) >> 8;
|
||||
mrect[1] = (irect[1] * b1 + prect[1] * b2) >> 8;
|
||||
mrect[2] = (irect[2] * b1 + prect[2] * b2) >> 8;
|
||||
mrect[3] = (irect[3] * b1 + prect[3] * b2) >> 8;
|
||||
mrect += 4;
|
||||
irect += 4;
|
||||
prect += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,18 +245,18 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
||||
|
||||
void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use)
|
||||
{
|
||||
float bfacf0, bfacf1;
|
||||
float bfacf0, bfacf1;
|
||||
|
||||
if (cast->use_ipo==0) {
|
||||
bfacf0= bfacf1= cast->blur+1.0;
|
||||
if (cast->use_ipo == 0) {
|
||||
bfacf0 = bfacf1 = cast->blur + 1.0;
|
||||
}
|
||||
else {
|
||||
bfacf0 = (facf0 * 6.0) + 1.0;
|
||||
bfacf1 = (facf1 * 6.0) + 1.0;
|
||||
}
|
||||
|
||||
if (out->rect) memcpy(out->rect, ibuf1->rect, 4*out->x*out->y);
|
||||
if (out->rect_float) memcpy(out->rect_float, ibuf1->rect_float, 4*out->x*out->y*sizeof(float));
|
||||
if (out->rect) memcpy(out->rect, ibuf1->rect, 4 * out->x * out->y);
|
||||
if (out->rect_float) memcpy(out->rect_float, ibuf1->rect_float, 4 * out->x * out->y * sizeof(float));
|
||||
|
||||
/****************I can't get this field code to work... works ok without...paprmh****************/
|
||||
|
||||
@@ -270,15 +270,15 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
|
||||
doblur(out, bfacf0, cast); /*fieldA*/
|
||||
|
||||
/* if (out->rect)out->rect += out->x * out->y;
|
||||
if (out->rect_float)out->rect_float += out->x * out->y;
|
||||
if (out->rect_float)out->rect_float += out->x * out->y;
|
||||
|
||||
doblur(out, bfacf1, cast);*/ /*fieldB*/
|
||||
doblur(out, bfacf1, cast);*/ /*fieldB*/
|
||||
|
||||
/* if (out->rect)out->rect -= out->x * out->y;
|
||||
if (out->rect_float)out->rect_float -= out->x * out->y;
|
||||
out->flags |= IB_fields;
|
||||
if (out->rect_float)out->rect_float -= out->x * out->y;
|
||||
out->flags |= IB_fields;
|
||||
|
||||
interlace(out);*/
|
||||
interlace(out);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -132,8 +132,9 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
|
||||
d->last_level = cast->level;
|
||||
}
|
||||
|
||||
if (width != d->last_width || height != d->last_height
|
||||
|| cfra != d->last_cfra + 1) {
|
||||
if (width != d->last_width || height != d->last_height ||
|
||||
cfra != d->last_cfra + 1)
|
||||
{
|
||||
free(d->last_frame);
|
||||
d->last_frame = (unsigned char*) calloc(width * height, 4);
|
||||
|
||||
|
||||
@@ -31,25 +31,25 @@
|
||||
/* ******************** GLOBAL VARIABLES ***************** */
|
||||
|
||||
|
||||
char name[24]= "scatter";
|
||||
char name[24] = "scatter";
|
||||
|
||||
/* structure for buttons,
|
||||
* butcode name default min max 0
|
||||
*/
|
||||
|
||||
VarStruct varstr[]= {
|
||||
LABEL, "Input: 1 strip", 0.0, 0.0, 0.0, "",
|
||||
NUM|INT, "seed: ", 1.0, 0.0, 10.0, "Offset in random table",
|
||||
NUMSLI|FLO, "swing: ", 1.0, 0.0, 3.0, "The amplitude, width of the effect",
|
||||
TOG|INT, "wrap", 0.0, 0.0, 1.0, "Cyclic wrap around the left/right edges",
|
||||
NUM|INT, "type: ", 1.0, 0.0, 1.0, "Type 1 is random for each frame",
|
||||
VarStruct varstr[] = {
|
||||
LABEL, "Input: 1 strip", 0.0, 0.0, 0.0, "",
|
||||
NUM | INT, "seed: ", 1.0, 0.0, 10.0, "Offset in random table",
|
||||
NUMSLI | FLO, "swing: ", 1.0, 0.0, 3.0, "The amplitude, width of the effect",
|
||||
TOG | INT, "wrap", 0.0, 0.0, 1.0, "Cyclic wrap around the left/right edges",
|
||||
NUM | INT, "type: ", 1.0, 0.0, 1.0, "Type 1 is random for each frame",
|
||||
};
|
||||
|
||||
/* The cast struct is for input in the main doit function
|
||||
Varstr and Cast must have the same variables in the same order */
|
||||
|
||||
typedef struct Cast {
|
||||
int dummy; /* because of the 'label' button */
|
||||
int dummy; /* because of the 'label' button */
|
||||
int seed;
|
||||
float swing;
|
||||
int wrap;
|
||||
@@ -80,57 +80,57 @@ void plugin_init()
|
||||
|
||||
void plugin_getinfo(PluginInfo *info)
|
||||
{
|
||||
info->name= name;
|
||||
info->nvars= sizeof(varstr)/sizeof(VarStruct);
|
||||
info->cfra= &cfra;
|
||||
info->name = name;
|
||||
info->nvars = sizeof(varstr) / sizeof(VarStruct);
|
||||
info->cfra = &cfra;
|
||||
|
||||
info->varstr= varstr;
|
||||
info->varstr = varstr;
|
||||
|
||||
info->init= plugin_init;
|
||||
info->seq_doit= (SeqDoit) plugin_seq_doit;
|
||||
info->callback= plugin_but_changed;
|
||||
info->init = plugin_init;
|
||||
info->seq_doit = (SeqDoit) plugin_seq_doit;
|
||||
info->callback = plugin_but_changed;
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************
|
||||
Scatter
|
||||
Scatter
|
||||
|
||||
************************************************************ */
|
||||
************************************************************ */
|
||||
|
||||
static void rectcpy(ImBuf *dbuf, ImBuf *sbuf,
|
||||
int destx, int desty,
|
||||
int srcx, int srcy, int width, int height)
|
||||
int destx, int desty,
|
||||
int srcx, int srcy, int width, int height)
|
||||
{
|
||||
uint *drect,*srect;
|
||||
uint *drect, *srect;
|
||||
float *dfrect, *sfrect;
|
||||
int tmp;
|
||||
|
||||
if (dbuf == 0) return;
|
||||
|
||||
if (destx < 0){
|
||||
srcx -= destx ;
|
||||
width += destx ;
|
||||
if (destx < 0) {
|
||||
srcx -= destx;
|
||||
width += destx;
|
||||
destx = 0;
|
||||
}
|
||||
if (srcx < 0){
|
||||
destx -= srcx ;
|
||||
width += destx ;
|
||||
if (srcx < 0) {
|
||||
destx -= srcx;
|
||||
width += destx;
|
||||
srcx = 0;
|
||||
}
|
||||
if (desty < 0){
|
||||
srcy -= desty ;
|
||||
height += desty ;
|
||||
if (desty < 0) {
|
||||
srcy -= desty;
|
||||
height += desty;
|
||||
desty = 0;
|
||||
}
|
||||
if (srcy < 0){
|
||||
desty -= srcy ;
|
||||
height += desty ;
|
||||
if (srcy < 0) {
|
||||
desty -= srcy;
|
||||
height += desty;
|
||||
srcy = 0;
|
||||
}
|
||||
|
||||
if (width > dbuf->x - destx) width = dbuf->x - destx;
|
||||
if (height > dbuf->y - desty) height = dbuf->y - desty;
|
||||
if (sbuf){
|
||||
if (sbuf) {
|
||||
if (width > sbuf->x - srcx) width = sbuf->x - srcx;
|
||||
if (height > sbuf->y - srcy) height = sbuf->y - srcy;
|
||||
srect = sbuf->rect;
|
||||
@@ -151,23 +151,25 @@ static void rectcpy(ImBuf *dbuf, ImBuf *sbuf,
|
||||
destx = dbuf->x;
|
||||
|
||||
if (sbuf) {
|
||||
tmp = (srcy * sbuf->x + srcx );
|
||||
tmp = (srcy * sbuf->x + srcx);
|
||||
if (dbuf->rect_float) sfrect += 4 * tmp;
|
||||
else srect += tmp;
|
||||
srcx = sbuf->x;
|
||||
} else{
|
||||
}
|
||||
else {
|
||||
if (dbuf->rect_float) sfrect = dfrect;
|
||||
else srect = drect;
|
||||
srcx = destx;
|
||||
}
|
||||
|
||||
for (;height > 0; height--){
|
||||
for (; height > 0; height--) {
|
||||
if (dbuf->rect_float) {
|
||||
memcpy(dfrect,sfrect, 4 * width * sizeof(float));
|
||||
memcpy(dfrect, sfrect, 4 * width * sizeof(float));
|
||||
dfrect += destx;
|
||||
sfrect += srcx;
|
||||
} else {
|
||||
memcpy(drect,srect, width * sizeof(int));
|
||||
}
|
||||
else {
|
||||
memcpy(drect, srect, width * sizeof(int));
|
||||
drect += destx;
|
||||
srect += srcx;
|
||||
}
|
||||
@@ -176,21 +178,22 @@ static void rectcpy(ImBuf *dbuf, ImBuf *sbuf,
|
||||
|
||||
static void fill_out(ImBuf *out, float r, float g, float b, float a)
|
||||
{
|
||||
int tot,x;
|
||||
int tot, x;
|
||||
float *rectf = out->rect_float;
|
||||
unsigned char *rect = (unsigned char *)out->rect;
|
||||
|
||||
tot = out->x * out->y;
|
||||
if (out->rect_float) {
|
||||
for (x = 0;x < tot; x++) {
|
||||
for (x = 0; x < tot; x++) {
|
||||
rectf[0] = r;
|
||||
rectf[1] = g;
|
||||
rectf[2] = b;
|
||||
rectf[3] = a;
|
||||
rectf += 4;
|
||||
}
|
||||
} else {
|
||||
for (x=0;x < tot;x++) {
|
||||
}
|
||||
else {
|
||||
for (x = 0; x < tot; x++) {
|
||||
rect[0] = (int)(r * 255);
|
||||
rect[1] = (int)(g * 255);
|
||||
rect[2] = (int)(b * 255);
|
||||
@@ -207,7 +210,7 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int sx, int sy, ImBuf
|
||||
int x, y, lr;
|
||||
|
||||
/* fill imbuf 'out' with black */
|
||||
fill_out(out, 0,0,0,0);
|
||||
fill_out(out, 0, 0, 0, 0);
|
||||
|
||||
|
||||
switch (cast->type) {
|
||||
@@ -228,9 +231,10 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int sx, int sy, ImBuf
|
||||
f1 = cast->swing * f1;
|
||||
f2 = cast->swing * f2;
|
||||
if (cast->wrap) f2 += 1.0;
|
||||
lr = drand48()>0.5;
|
||||
lr = drand48() > 0.5;
|
||||
t1 = facf0;
|
||||
} else t1 = facf1;
|
||||
}
|
||||
else t1 = facf1;
|
||||
|
||||
t2 = 1.0 - t1;
|
||||
t3 = 3.0 * (f1 * t1 * t1 * t2 + f2 * t1 * t2 * t2);
|
||||
|
||||
@@ -218,7 +218,7 @@ void calc_fcurve_range(struct FCurve *fcu, float *min, float *max,
|
||||
|
||||
/* get the bounding-box extents for F-Curve */
|
||||
void calc_fcurve_bounds(struct FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax,
|
||||
const short do_sel_only);
|
||||
const short do_sel_only, const short include_handles);
|
||||
|
||||
/* .............. */
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ static void get_fcurve_end_keyframes(FCurve *fcu, BezTriple **first, BezTriple *
|
||||
|
||||
/* Calculate the extents of F-Curve's data */
|
||||
void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax,
|
||||
const short do_sel_only)
|
||||
const short do_sel_only, const short include_handles)
|
||||
{
|
||||
float xminv = 999999999.0f, xmaxv = -999999999.0f;
|
||||
float yminv = 999999999.0f, ymaxv = -999999999.0f;
|
||||
@@ -495,8 +495,14 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa
|
||||
if (bezt_first) {
|
||||
BLI_assert(bezt_last != NULL);
|
||||
|
||||
xminv = MIN2(xminv, bezt_first->vec[1][0]);
|
||||
xmaxv = MAX2(xmaxv, bezt_last->vec[1][0]);
|
||||
if (include_handles) {
|
||||
xminv = MIN3(xminv, bezt_first->vec[0][0], bezt_first->vec[1][0]);
|
||||
xmaxv = MAX3(xmaxv, bezt_last->vec[1][0], bezt_last->vec[2][0]);
|
||||
}
|
||||
else {
|
||||
xminv = MIN2(xminv, bezt_first->vec[1][0]);
|
||||
xmaxv = MAX2(xmaxv, bezt_last->vec[1][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,10 +512,15 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa
|
||||
|
||||
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
|
||||
if ((do_sel_only == FALSE) || BEZSELECTED(bezt)) {
|
||||
if (bezt->vec[1][1] < yminv)
|
||||
yminv = bezt->vec[1][1];
|
||||
if (bezt->vec[1][1] > ymaxv)
|
||||
ymaxv = bezt->vec[1][1];
|
||||
if (include_handles) {
|
||||
yminv = MIN4(yminv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]);
|
||||
ymaxv = MAX4(ymaxv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]);
|
||||
}
|
||||
else {
|
||||
yminv = MIN2(yminv, bezt->vec[1][1]);
|
||||
ymaxv = MAX2(ymaxv, bezt->vec[1][1]);
|
||||
}
|
||||
|
||||
foundvert = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -531,7 +542,7 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa
|
||||
yminv = fpt->vec[1];
|
||||
if (fpt->vec[1] > ymaxv)
|
||||
ymaxv = fpt->vec[1];
|
||||
|
||||
|
||||
foundvert = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -570,20 +581,20 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end,
|
||||
|
||||
/* get endpoint keyframes */
|
||||
get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only);
|
||||
|
||||
|
||||
if (bezt_first) {
|
||||
BLI_assert(bezt_last != NULL);
|
||||
|
||||
|
||||
min = MIN2(min, bezt_first->vec[1][0]);
|
||||
max = MAX2(max, bezt_last->vec[1][0]);
|
||||
|
||||
|
||||
foundvert = TRUE;
|
||||
}
|
||||
}
|
||||
else if (fcu->fpt) {
|
||||
min = MIN2(min, fcu->fpt[0].vec[0]);
|
||||
max = MAX2(max, fcu->fpt[fcu->totvert - 1].vec[0]);
|
||||
|
||||
|
||||
foundvert = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -4444,7 +4444,8 @@ static void psys_prepare_physics(ParticleSimulationData *sim)
|
||||
static int hair_needs_recalc(ParticleSystem *psys)
|
||||
{
|
||||
if (!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) &&
|
||||
((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET || (psys->part->flag & PART_HAIR_REGROW && !psys->edit))) {
|
||||
((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET || (psys->part->flag & PART_HAIR_REGROW && !psys->edit)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -2190,8 +2190,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
|
||||
BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
|
||||
frame = atoi(num);
|
||||
|
||||
if ((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
|
||||
(mode==PTCACHE_CLEAR_AFTER && frame > cfra) ) {
|
||||
if ((mode == PTCACHE_CLEAR_BEFORE && frame < cfra) ||
|
||||
(mode == PTCACHE_CLEAR_AFTER && frame > cfra))
|
||||
{
|
||||
|
||||
BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
|
||||
BLI_delete(path_full, 0, 0);
|
||||
@@ -2226,8 +2227,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
|
||||
}
|
||||
else {
|
||||
while (pm) {
|
||||
if ((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
|
||||
(mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) {
|
||||
if ((mode == PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
|
||||
(mode == PTCACHE_CLEAR_AFTER && pm->frame > cfra))
|
||||
{
|
||||
link = pm;
|
||||
if (pid->cache->cached_frames && pm->frame >=sta && pm->frame <= end)
|
||||
pid->cache->cached_frames[pm->frame-sta] = 0;
|
||||
|
||||
@@ -1054,11 +1054,12 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), unsigned int U
|
||||
a = ccdm->totface;
|
||||
#endif
|
||||
if ((aabbmax[0] < ccdm->bbmin[0]) ||
|
||||
(aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) ||
|
||||
(aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
(aabbmin[1] > ccdm->bbmax[1]) ||
|
||||
(aabbmin[2] > ccdm->bbmax[2]) ) {
|
||||
(aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) ||
|
||||
(aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
(aabbmin[1] > ccdm->bbmax[1]) ||
|
||||
(aabbmin[2] > ccdm->bbmax[2]) )
|
||||
{
|
||||
/* boxes don't intersect */
|
||||
BLI_ghashIterator_step(ihash);
|
||||
continue;
|
||||
@@ -1125,11 +1126,12 @@ static int sb_detect_face_pointCached(float face_v1[3], float face_v2[3], float
|
||||
mprevvert= ccdm->mprevvert;
|
||||
outerfacethickness = ob->pd->pdef_sboft;
|
||||
if ((aabbmax[0] < ccdm->bbmin[0]) ||
|
||||
(aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) ||
|
||||
(aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
(aabbmin[1] > ccdm->bbmax[1]) ||
|
||||
(aabbmin[2] > ccdm->bbmax[2]) ) {
|
||||
(aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) ||
|
||||
(aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
(aabbmin[1] > ccdm->bbmax[1]) ||
|
||||
(aabbmin[2] > ccdm->bbmax[2]) )
|
||||
{
|
||||
/* boxes don't intersect */
|
||||
BLI_ghashIterator_step(ihash);
|
||||
continue;
|
||||
@@ -1220,11 +1222,12 @@ static int sb_detect_face_collisionCached(float face_v1[3], float face_v2[3], fl
|
||||
a = ccdm->totface;
|
||||
|
||||
if ((aabbmax[0] < ccdm->bbmin[0]) ||
|
||||
(aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) ||
|
||||
(aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
(aabbmin[1] > ccdm->bbmax[1]) ||
|
||||
(aabbmin[2] > ccdm->bbmax[2]) ) {
|
||||
(aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) ||
|
||||
(aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
(aabbmin[1] > ccdm->bbmax[1]) ||
|
||||
(aabbmin[2] > ccdm->bbmax[2]) )
|
||||
{
|
||||
/* boxes don't intersect */
|
||||
BLI_ghashIterator_step(ihash);
|
||||
continue;
|
||||
@@ -1447,11 +1450,12 @@ static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], fl
|
||||
a = ccdm->totface;
|
||||
|
||||
if ((aabbmax[0] < ccdm->bbmin[0]) ||
|
||||
(aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) ||
|
||||
(aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
(aabbmin[1] > ccdm->bbmax[1]) ||
|
||||
(aabbmin[2] > ccdm->bbmax[2]) ) {
|
||||
(aabbmax[1] < ccdm->bbmin[1]) ||
|
||||
(aabbmax[2] < ccdm->bbmin[2]) ||
|
||||
(aabbmin[0] > ccdm->bbmax[0]) ||
|
||||
(aabbmin[1] > ccdm->bbmax[1]) ||
|
||||
(aabbmin[2] > ccdm->bbmax[2]) )
|
||||
{
|
||||
/* boxes don't intersect */
|
||||
BLI_ghashIterator_step(ihash);
|
||||
continue;
|
||||
@@ -1785,14 +1789,15 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
|
||||
maxz = ccdm->bbmax[2];
|
||||
|
||||
if ((opco[0] < minx) ||
|
||||
(opco[1] < miny) ||
|
||||
(opco[2] < minz) ||
|
||||
(opco[0] > maxx) ||
|
||||
(opco[1] > maxy) ||
|
||||
(opco[2] > maxz) ) {
|
||||
/* outside the padded boundbox --> collision object is too far away */
|
||||
BLI_ghashIterator_step(ihash);
|
||||
continue;
|
||||
(opco[1] < miny) ||
|
||||
(opco[2] < minz) ||
|
||||
(opco[0] > maxx) ||
|
||||
(opco[1] > maxy) ||
|
||||
(opco[2] > maxz) )
|
||||
{
|
||||
/* outside the padded boundbox --> collision object is too far away */
|
||||
BLI_ghashIterator_step(ihash);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -623,7 +623,7 @@ static void do_version_constraints_radians_degrees_250(ListBase *lb)
|
||||
{
|
||||
bConstraint *con;
|
||||
|
||||
for (con = lb->first; con; con = con->next) {
|
||||
for (con = lb->first; con; con = con->next) {
|
||||
if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) {
|
||||
bRigidBodyJointConstraint *data = con->data;
|
||||
data->axX *= (float)(M_PI / 180.0);
|
||||
|
||||
@@ -32,6 +32,7 @@ struct ExportSettings
|
||||
public:
|
||||
bool selected;
|
||||
bool apply_modifiers;
|
||||
bool include_bone_children;
|
||||
bool second_life;
|
||||
char *filepath;
|
||||
};
|
||||
|
||||
@@ -79,25 +79,28 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
|
||||
bool is_skinned_mesh = arm_exporter->is_skinned_mesh(ob);
|
||||
std::list<Object*> child_objects;
|
||||
|
||||
// list child objects
|
||||
Base *b = (Base*) sce->base.first;
|
||||
while (b) {
|
||||
// cob - child object
|
||||
Object *cob = b->object;
|
||||
|
||||
if (cob->parent == ob) {
|
||||
switch (cob->type) {
|
||||
case OB_MESH:
|
||||
case OB_CAMERA:
|
||||
case OB_LAMP:
|
||||
case OB_EMPTY:
|
||||
case OB_ARMATURE:
|
||||
child_objects.push_back(cob);
|
||||
break;
|
||||
if (this->export_settings->include_bone_children) {
|
||||
// list child objects
|
||||
Base *b = (Base*) sce->base.first;
|
||||
while (b) {
|
||||
// cob - child object
|
||||
Object *cob = b->object;
|
||||
|
||||
if (cob->parent == ob) {
|
||||
switch (cob->type) {
|
||||
case OB_MESH:
|
||||
case OB_CAMERA:
|
||||
case OB_LAMP:
|
||||
case OB_EMPTY:
|
||||
case OB_ARMATURE:
|
||||
child_objects.push_back(cob);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b = b->next;
|
||||
b = b->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,14 +49,21 @@ extern "C"
|
||||
return 0;
|
||||
}
|
||||
|
||||
int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life)
|
||||
int collada_export(
|
||||
Scene *sce,
|
||||
const char *filepath,
|
||||
int selected,
|
||||
int apply_modifiers,
|
||||
int include_bone_children,
|
||||
int second_life)
|
||||
{
|
||||
ExportSettings export_settings;
|
||||
|
||||
export_settings.selected = selected != 0;
|
||||
export_settings.apply_modifiers = apply_modifiers != 0;
|
||||
export_settings.second_life = second_life != 0;
|
||||
export_settings.filepath = (char *)filepath;
|
||||
export_settings.selected = selected != 0;
|
||||
export_settings.apply_modifiers = apply_modifiers != 0;
|
||||
export_settings.include_bone_children = include_bone_children != 0;
|
||||
export_settings.second_life = second_life != 0;
|
||||
export_settings.filepath = (char *)filepath;
|
||||
|
||||
/* annoying, collada crashes if file cant be created! [#27162] */
|
||||
if (!BLI_exists(filepath)) {
|
||||
|
||||
@@ -37,7 +37,13 @@ extern "C" {
|
||||
* both return 1 on success, 0 on error
|
||||
*/
|
||||
int collada_import(bContext *C, const char *filepath);
|
||||
int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life);
|
||||
int collada_export(
|
||||
Scene *sce,
|
||||
const char *filepath,
|
||||
int selected,
|
||||
int apply_modifiers,
|
||||
int include_bone_children,
|
||||
int second_life);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float
|
||||
{
|
||||
float inputColor[4];
|
||||
inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers);
|
||||
outputValue[0] = (inputColor[0]*0.35f + inputColor[1]*0.45f + inputColor[2]*0.2f)*inputColor[3];
|
||||
outputValue[0] = inputColor[0]*0.35f + inputColor[1]*0.45f + inputColor[2]*0.2f;
|
||||
}
|
||||
|
||||
void ConvertColorToBWOperation::deinitExecution()
|
||||
|
||||
@@ -38,7 +38,7 @@ void ConvertColourToValueProg::executePixel(float *outputValue, float x, float y
|
||||
{
|
||||
float inputColor[4];
|
||||
inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers);
|
||||
outputValue[0] = ((inputColor[0] + inputColor[1] + inputColor[2])/3.0f)*inputColor[3];
|
||||
outputValue[0] = (inputColor[0] + inputColor[1] + inputColor[2])/3.0f;
|
||||
}
|
||||
|
||||
void ConvertColourToValueProg::deinitExecution()
|
||||
|
||||
@@ -3494,7 +3494,8 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
|
||||
pset->flag &= ~PE_LOCK_FIRST;
|
||||
|
||||
if (((pset->brushtype == PE_BRUSH_ADD) ?
|
||||
(sqrt(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) : (dx != 0 || dy != 0)) || bedit->first) {
|
||||
(sqrt(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) : (dx != 0 || dy != 0)) || bedit->first)
|
||||
{
|
||||
PEData data= bedit->data;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
||||
@@ -881,8 +881,8 @@ static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2])
|
||||
{
|
||||
float d1, d2, d3, d4;
|
||||
float p[2] = {co[0] - pos[0], co[1] - pos[1]};
|
||||
float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]},
|
||||
v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]};
|
||||
float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]};
|
||||
float v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]};
|
||||
|
||||
d1 = dist_to_line_segment_v2(p, v1, v2);
|
||||
d2 = dist_to_line_segment_v2(p, v2, v3);
|
||||
|
||||
@@ -83,7 +83,8 @@
|
||||
|
||||
/* Get the min/max keyframes*/
|
||||
/* note: it should return total boundbox, filter for selection only can be argument... */
|
||||
void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short selOnly)
|
||||
void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax,
|
||||
const short do_sel_only, const short include_handles)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
@@ -109,7 +110,7 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
|
||||
float unitFac;
|
||||
|
||||
/* get range */
|
||||
calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax, selOnly);
|
||||
calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax, do_sel_only, include_handles);
|
||||
|
||||
/* apply NLA scaling */
|
||||
if (adt) {
|
||||
@@ -169,7 +170,7 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
scene = ac.scene;
|
||||
|
||||
/* set the range directly */
|
||||
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, FALSE);
|
||||
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, FALSE, FALSE);
|
||||
scene->r.flag |= SCER_PRV_RANGE;
|
||||
scene->r.psfra = (int)floor(min + 0.5f);
|
||||
scene->r.pefra = (int)floor(max + 0.5f);
|
||||
@@ -198,7 +199,7 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot)
|
||||
|
||||
/* ****************** View-All Operator ****************** */
|
||||
|
||||
static int graphkeys_viewall(bContext *C, const short selOnly)
|
||||
static int graphkeys_viewall(bContext *C, const short do_sel_only, const short include_handles)
|
||||
{
|
||||
bAnimContext ac;
|
||||
View2D *v2d;
|
||||
@@ -210,7 +211,10 @@ static int graphkeys_viewall(bContext *C, const short selOnly)
|
||||
v2d = &ac.ar->v2d;
|
||||
|
||||
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
|
||||
get_graph_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax, selOnly);
|
||||
get_graph_keyframe_extents(&ac,
|
||||
&v2d->cur.xmin, &v2d->cur.xmax,
|
||||
&v2d->cur.ymin, &v2d->cur.ymax,
|
||||
do_sel_only, include_handles);
|
||||
|
||||
extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
v2d->cur.xmin -= extra;
|
||||
@@ -231,16 +235,20 @@ static int graphkeys_viewall(bContext *C, const short selOnly)
|
||||
|
||||
/* ......... */
|
||||
|
||||
static int graphkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int graphkeys_viewall_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
short include_handles = RNA_boolean_get(op->ptr, "include_handles");
|
||||
|
||||
/* whole range */
|
||||
return graphkeys_viewall(C, FALSE);
|
||||
return graphkeys_viewall(C, FALSE, include_handles);
|
||||
}
|
||||
|
||||
static int graphkeys_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int graphkeys_view_selected_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
short include_handles = RNA_boolean_get(op->ptr, "include_handles");
|
||||
|
||||
/* only selected */
|
||||
return graphkeys_viewall(C, TRUE);
|
||||
return graphkeys_viewall(C, TRUE, include_handles);
|
||||
}
|
||||
|
||||
void GRAPH_OT_view_all(wmOperatorType *ot)
|
||||
@@ -256,6 +264,10 @@ void GRAPH_OT_view_all(wmOperatorType *ot)
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
ot->prop = RNA_def_boolean(ot->srna, "include_handles", TRUE, "Include Handles",
|
||||
"Include handles of keyframes when calculating extents");
|
||||
}
|
||||
|
||||
void GRAPH_OT_view_selected(wmOperatorType *ot)
|
||||
@@ -271,6 +283,10 @@ void GRAPH_OT_view_selected(wmOperatorType *ot)
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
ot->prop = RNA_def_boolean(ot->srna, "include_handles", TRUE, "Include Handles",
|
||||
"Include handles of keyframes when calculating extents");
|
||||
}
|
||||
|
||||
/* ******************** Create Ghost-Curves Operator *********************** */
|
||||
|
||||
@@ -86,7 +86,8 @@ enum {
|
||||
/* ***************************************** */
|
||||
/* graph_edit.c */
|
||||
|
||||
void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short do_selected);
|
||||
void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax,
|
||||
const short do_selected, const short include_handles);
|
||||
|
||||
void GRAPH_OT_previewrange_set(struct wmOperatorType *ot);
|
||||
void GRAPH_OT_view_all(struct wmOperatorType *ot);
|
||||
|
||||
@@ -250,7 +250,7 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
|
||||
graph_draw_curves(&ac, sipo, ar, grid, 1);
|
||||
|
||||
/* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
|
||||
get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax, FALSE);
|
||||
get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax, FALSE, TRUE);
|
||||
/* extra offset so that these items are visible */
|
||||
v2d->tot.xmin -= 10.0f;
|
||||
v2d->tot.xmax += 10.0f;
|
||||
|
||||
@@ -175,7 +175,8 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
|
||||
node_from = NULL;
|
||||
|
||||
if (node_prev && node_prev->type == ntemp->type &&
|
||||
(ntemp->type != NODE_GROUP || node_prev->id == &ntemp->ngroup->id)) {
|
||||
(ntemp->type != NODE_GROUP || node_prev->id == &ntemp->ngroup->id))
|
||||
{
|
||||
/* keep the previous node if it's the same type */
|
||||
node_from = node_prev;
|
||||
}
|
||||
|
||||
@@ -380,8 +380,9 @@ static void initSnappingMode(TransInfo *t)
|
||||
|
||||
t->tsnap.mode = ts->snap_mode;
|
||||
|
||||
if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && // Only 3D view or UV
|
||||
(t->flag & T_CAMERA) == 0) { // Not with camera selected in camera view
|
||||
if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && /* Only 3D view or UV */
|
||||
(t->flag & T_CAMERA) == 0) /* Not with camera selected in camera view */
|
||||
{
|
||||
setSnappingCallback(t);
|
||||
|
||||
/* Edit mode */
|
||||
|
||||
@@ -387,7 +387,8 @@ static void codegen_set_unique_ids(ListBase *nodes)
|
||||
|
||||
/* set texid used for settings texture slot with multitexture */
|
||||
if (codegen_input_has_texture(input) &&
|
||||
((input->source == GPU_SOURCE_TEX) || (input->source == GPU_SOURCE_TEX_PIXEL))) {
|
||||
((input->source == GPU_SOURCE_TEX) || (input->source == GPU_SOURCE_TEX_PIXEL)))
|
||||
{
|
||||
if (input->link) {
|
||||
/* input is texture from buffer, assign only one texid per
|
||||
* buffer to avoid sampling the same texture twice */
|
||||
|
||||
@@ -766,8 +766,9 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
|
||||
ibuf = BKE_image_get_ibuf(ima, NULL);
|
||||
|
||||
if (ima->repbind || (gpu_get_mipmap() && mipmap) || !ima->bindcode || !ibuf ||
|
||||
(!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) ||
|
||||
(w == 0) || (h == 0)) {
|
||||
(!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) ||
|
||||
(w == 0) || (h == 0))
|
||||
{
|
||||
/* these cases require full reload still */
|
||||
GPU_free_image(ima);
|
||||
}
|
||||
|
||||
@@ -1074,8 +1074,9 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU
|
||||
shader->object = glCreateProgramObjectARB();
|
||||
|
||||
if (!shader->object ||
|
||||
(vertexcode && !shader->vertex) ||
|
||||
(fragcode && !shader->fragment)) {
|
||||
(vertexcode && !shader->vertex) ||
|
||||
(fragcode && !shader->fragment))
|
||||
{
|
||||
fprintf(stderr, "GPUShader, object creation failed.\n");
|
||||
GPU_shader_free(shader);
|
||||
return NULL;
|
||||
|
||||
@@ -121,10 +121,11 @@ int
|
||||
logImageSetByteConversion(LogImageFile* logImage, const LogImageByteConversionParameters* params)
|
||||
{
|
||||
if ((params->gamma >= MIN_GAMMA) &&
|
||||
(params->gamma <= MAX_GAMMA) &&
|
||||
(params->blackPoint >= 0) &&
|
||||
(params->blackPoint < params->whitePoint) &&
|
||||
(params->whitePoint <= 1023)) {
|
||||
(params->gamma <= MAX_GAMMA) &&
|
||||
(params->blackPoint >= 0) &&
|
||||
(params->blackPoint < params->whitePoint) &&
|
||||
(params->whitePoint <= 1023))
|
||||
{
|
||||
logImage->params.gamma = params->gamma;
|
||||
logImage->params.blackPoint = params->blackPoint;
|
||||
logImage->params.whitePoint = params->whitePoint;
|
||||
|
||||
@@ -85,9 +85,15 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name
|
||||
/* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */
|
||||
#include "../../collada/collada.h"
|
||||
|
||||
static void rna_Scene_collada_export(Scene *scene, const char *filepath, int selected, int apply_modifiers, int second_life)
|
||||
static void rna_Scene_collada_export(
|
||||
Scene *scene,
|
||||
const char *filepath,
|
||||
int selected,
|
||||
int apply_modifiers,
|
||||
int include_bone_children,
|
||||
int second_life)
|
||||
{
|
||||
collada_export(scene, filepath, selected, apply_modifiers, second_life);
|
||||
collada_export(scene, filepath, selected, apply_modifiers, include_bone_children, second_life);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -117,6 +123,7 @@ void RNA_api_scene(StructRNA *srna)
|
||||
RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */
|
||||
parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements");
|
||||
parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (in Preview resolution)");
|
||||
parm = RNA_def_boolean(func, "include_bone_children", 0, "Include Bone Children", "Include all objects attached to bones of selected Armature(s)");
|
||||
parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life");
|
||||
RNA_def_function_ui_description(func, "Export to collada file");
|
||||
#endif
|
||||
|
||||
@@ -716,7 +716,8 @@ static int calc_edge_subdivisions(const MVert *mvert, const MVertSkin *nodes,
|
||||
/* If either end is a branch node marked 'loose', don't subdivide
|
||||
* the edge (or subdivide just twice if both are branches) */
|
||||
if ((v1_branch && (evs[0]->flag & MVERT_SKIN_LOOSE)) ||
|
||||
(v2_branch && (evs[1]->flag & MVERT_SKIN_LOOSE))) {
|
||||
(v2_branch && (evs[1]->flag & MVERT_SKIN_LOOSE)))
|
||||
{
|
||||
if (v1_branch && v2_branch)
|
||||
return 2;
|
||||
else
|
||||
|
||||
@@ -3790,7 +3790,8 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
|
||||
lar->area_sizey= lar->area_size;
|
||||
|
||||
if ((la->sun_effect_type & LA_SUN_EFFECT_SKY) ||
|
||||
(la->sun_effect_type & LA_SUN_EFFECT_AP)) {
|
||||
(la->sun_effect_type & LA_SUN_EFFECT_AP))
|
||||
{
|
||||
lar->sunsky = (struct SunSky*)MEM_callocN(sizeof(struct SunSky), "sunskyren");
|
||||
lar->sunsky->effect_type = la->sun_effect_type;
|
||||
|
||||
|
||||
@@ -2169,7 +2169,7 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua
|
||||
else {
|
||||
unsigned char *col= (unsigned char *)(bs->rect + bs->rectx*y + x);
|
||||
|
||||
if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE) && (R.r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
|
||||
if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE) && (R.r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
|
||||
linearrgb_to_srgb_uchar3(col, shr.combined);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2155,7 +2155,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED
|
||||
static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
char filename[FILE_MAX];
|
||||
int selected, second_life, apply_modifiers;
|
||||
int selected, second_life, apply_modifiers, include_bone_children;
|
||||
|
||||
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
BKE_report(op->reports, RPT_ERROR, "No filename given");
|
||||
@@ -2165,14 +2165,22 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
||||
RNA_string_get(op->ptr, "filepath", filename);
|
||||
|
||||
/* Options panel */
|
||||
selected = RNA_boolean_get(op->ptr, "selected");
|
||||
second_life = RNA_boolean_get(op->ptr, "second_life");
|
||||
apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
|
||||
selected = RNA_boolean_get(op->ptr, "selected");
|
||||
apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
|
||||
include_bone_children = RNA_boolean_get(op->ptr, "include_bone_children");
|
||||
|
||||
second_life = RNA_boolean_get(op->ptr, "second_life");
|
||||
|
||||
/* get editmode results */
|
||||
ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
|
||||
|
||||
if (collada_export(CTX_data_scene(C), filename, selected, apply_modifiers, second_life)) {
|
||||
if (collada_export(
|
||||
CTX_data_scene(C),
|
||||
filename,
|
||||
selected,
|
||||
apply_modifiers,
|
||||
include_bone_children,
|
||||
second_life)) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
@@ -2193,10 +2201,16 @@ static void WM_OT_collada_export(wmOperatorType *ot)
|
||||
ot->flag |= OPTYPE_PRESET;
|
||||
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
|
||||
|
||||
RNA_def_boolean(ot->srna, "selected", 0, "Selection Only",
|
||||
"Export only selected elements");
|
||||
|
||||
RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers",
|
||||
"Apply modifiers (Preview Resolution)");
|
||||
|
||||
RNA_def_boolean(ot->srna, "include_bone_children", 0, "Include Bone Children",
|
||||
"Include all objects attached to bones of selected Armature(s)");
|
||||
|
||||
RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life",
|
||||
"Compatibility mode for Second Life");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user