- fixed the code to compile on win32

This commit is contained in:
Mikko Mononen 2010-09-10 06:53:33 +00:00
parent 581b02bdbb
commit 7ee6e96e5a
9 changed files with 60 additions and 23 deletions

View File

@ -322,11 +322,21 @@ inline void vsub(float* dest, const float* v1, const float* v2)
dest[2] = v1[2]-v2[2]; dest[2] = v1[2]-v2[2];
} }
inline float vdistSqr(const float* v1, const float* v2)
{
const float x = v1[0]-v2[0];
const float y = v1[1]-v2[1];
const float z = v1[2]-v2[2];
return x*x + y*y + z*z;
}
void appendArrowHead(struct duDebugDraw* dd, const float* p, const float* q, void appendArrowHead(struct duDebugDraw* dd, const float* p, const float* q,
const float s, unsigned int col) const float s, unsigned int col)
{ {
const float eps = 0.001f;
if (!dd) return; if (!dd) return;
if (vdistSqr(p,q) < eps*eps) return;
float ax[3], ay[3] = {0,1,0}, az[3]; float ax[3], ay[3] = {0,1,0}, az[3];
vsub(az, q, p); vsub(az, q, p);
vnormalize(az); vnormalize(az);

View File

@ -24,7 +24,7 @@
#ifdef NDEBUG #ifdef NDEBUG
// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/ // From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
# define dtAssert(x) do { (void)sizeof(x); } while(0) # define dtAssert(x) do { (void)sizeof(x); } while(__LINE__==-1,false)
#else #else
# include <assert.h> # include <assert.h>
# define dtAssert assert # define dtAssert assert

View File

@ -24,7 +24,7 @@
#ifdef NDEBUG #ifdef NDEBUG
// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/ // From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
# define rcAssert(x) do { (void)sizeof(x); } while(0) # define rcAssert(x) do { (void)sizeof(x); } while(__LINE__==-1,false)
#else #else
# include <assert.h> # include <assert.h>
# define rcAssert assert # define rcAssert assert

Binary file not shown.

View File

@ -271,6 +271,10 @@
RelativePath="..\..\..\Detour\Include\DetourNode.h" RelativePath="..\..\..\Detour\Include\DetourNode.h"
> >
</File> </File>
<File
RelativePath="..\..\..\Detour\Include\DetourObstacleAvoidance.h"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Source" Name="Source"
@ -299,6 +303,10 @@
RelativePath="..\..\..\Detour\Source\DetourNode.cpp" RelativePath="..\..\..\Detour\Source\DetourNode.cpp"
> >
</File> </File>
<File
RelativePath="..\..\..\Detour\Source\DetourObstacleAvoidance.cpp"
>
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
@ -347,6 +355,10 @@
RelativePath="..\..\Include\OffMeshConnectionTool.h" RelativePath="..\..\Include\OffMeshConnectionTool.h"
> >
</File> </File>
<File
RelativePath="..\..\Include\PerfTimer.h"
>
</File>
<File <File
RelativePath="..\..\Include\Sample.h" RelativePath="..\..\Include\Sample.h"
> >
@ -387,6 +399,10 @@
RelativePath="..\..\Include\TestCase.h" RelativePath="..\..\Include\TestCase.h"
> >
</File> </File>
<File
RelativePath="..\..\Include\ValueHistory.h"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Source" Name="Source"
@ -435,6 +451,10 @@
RelativePath="..\..\Source\OffMeshConnectionTool.cpp" RelativePath="..\..\Source\OffMeshConnectionTool.cpp"
> >
</File> </File>
<File
RelativePath="..\..\Source\PerfTimer.cpp"
>
</File>
<File <File
RelativePath="..\..\Source\Sample.cpp" RelativePath="..\..\Source\Sample.cpp"
> >
@ -467,6 +487,10 @@
RelativePath="..\..\Source\TestCase.cpp" RelativePath="..\..\Source\TestCase.cpp"
> >
</File> </File>
<File
RelativePath="..\..\Source\ValueHistory.cpp"
>
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter

View File

@ -717,7 +717,7 @@ void CrowdManager::update(const float dt, unsigned int flags, dtNavMeshQuery* na
} }
} }
m_sampleCount.addSample(ns); m_sampleCount.addSample((float)ns);
m_totalTime.addSample(getPerfDeltaTimeUsec(startTime, endTime) / 1000.0f); m_totalTime.addSample(getPerfDeltaTimeUsec(startTime, endTime) / 1000.0f);
m_rvoTime.addSample(getPerfDeltaTimeUsec(rvoStartTime, rvoEndTime) / 1000.0f); m_rvoTime.addSample(getPerfDeltaTimeUsec(rvoStartTime, rvoEndTime) / 1000.0f);
} }

View File

@ -68,7 +68,7 @@ void BuildContext::doStartTimer(const rcTimerLabel label)
void BuildContext::doStopTimer(const rcTimerLabel label) void BuildContext::doStopTimer(const rcTimerLabel label)
{ {
const TimeVal endTime = getPerfTime(); const TimeVal endTime = getPerfTime();
const int deltaTime = endTime - m_startTime[label]; const int deltaTime = (int)(endTime - m_startTime[label]);
if (m_accTime[label] == -1) if (m_accTime[label] == -1)
m_accTime[label] = deltaTime; m_accTime[label] = deltaTime;
else else

View File

@ -3,6 +3,9 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#ifdef WIN32
# define snprintf _snprintf
#endif
ValueHistory::ValueHistory() : ValueHistory::ValueHistory() :
m_hsamples(0) m_hsamples(0)
@ -61,7 +64,7 @@ void GraphParams::setValueRange(float ivmin, float ivmax, int indiv, const char*
void drawGraphBackground(const GraphParams* p) void drawGraphBackground(const GraphParams* p)
{ {
// BG // BG
imguiDrawRoundedRect(p->x, p->y, p->w, p->h, p->pad, imguiRGBA(64,64,64,128)); imguiDrawRoundedRect((float)p->x, (float)p->y, (float)p->w, (float)p->h, (float)p->pad, imguiRGBA(64,64,64,128));
const float sy = (p->h-p->pad*2) / (p->vmax-p->vmin); const float sy = (p->h-p->pad*2) / (p->vmax-p->vmin);
const float oy = p->y+p->pad-p->vmin*sy; const float oy = p->y+p->pad-p->vmin*sy;
@ -76,7 +79,7 @@ void drawGraphBackground(const GraphParams* p)
snprintf(text, 64, "%.2f %s", v, p->units); snprintf(text, 64, "%.2f %s", v, p->units);
const float fy = oy + v*sy; const float fy = oy + v*sy;
imguiDrawText(p->x + p->w - p->pad, (int)fy-4, IMGUI_ALIGN_RIGHT, text, imguiRGBA(0,0,0,255)); imguiDrawText(p->x + p->w - p->pad, (int)fy-4, IMGUI_ALIGN_RIGHT, text, imguiRGBA(0,0,0,255));
imguiDrawLine(p->x + p->pad, fy, p->x + p->w - p->pad - 50, fy, 1.0f, imguiRGBA(0,0,0,64)); imguiDrawLine((float)p->x + (float)p->pad, fy, (float)p->x + (float)p->w - (float)p->pad - 50, fy, 1.0f, imguiRGBA(0,0,0,64));
} }
} }
@ -85,11 +88,11 @@ void drawGraph(const GraphParams* p, const ValueHistory* graph,
{ {
const float sx = (p->w - p->pad*2) / (float)graph->getSampleCount(); const float sx = (p->w - p->pad*2) / (float)graph->getSampleCount();
const float sy = (p->h - p->pad*2) / (p->vmax - p->vmin); const float sy = (p->h - p->pad*2) / (p->vmax - p->vmin);
const float ox = p->x + p->pad; const float ox = (float)p->x + (float)p->pad;
const float oy = p->y + p->pad - p->vmin*sy; const float oy = (float)p->y + (float)p->pad - p->vmin*sy;
// Values // Values
float px, py; float px=0, py=0;
for (int i = 0; i < graph->getSampleCount()-1; ++i) for (int i = 0; i < graph->getSampleCount()-1; ++i)
{ {
const float x = ox + i*sx; const float x = ox + i*sx;
@ -106,7 +109,7 @@ void drawGraph(const GraphParams* p, const ValueHistory* graph,
int ix = p->x + p->w + 5; int ix = p->x + p->w + 5;
int iy = p->y + p->h - (idx+1)*(size+spacing); int iy = p->y + p->h - (idx+1)*(size+spacing);
imguiDrawRoundedRect(ix, iy, size, size, 2.0f, col); imguiDrawRoundedRect((float)ix, (float)iy, (float)size, (float)size, 2.0f, col);
char text[64]; char text[64];
snprintf(text, 64, "%.2f %s", graph->getAverage(), p->units); snprintf(text, 64, "%.2f %s", graph->getAverage(), p->units);

View File

@ -343,7 +343,7 @@ bool imguiBeginScrollArea(const char* name, int x, int y, int w, int h, int* scr
g_insideScrollArea = inRect(x, y, w, h, false); g_insideScrollArea = inRect(x, y, w, h, false);
g_state.insideCurrentScroll = g_insideScrollArea; g_state.insideCurrentScroll = g_insideScrollArea;
addGfxCmdRoundedRect(x, y, w, h, 6, imguiRGBA(0,0,0,192)); addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 6, imguiRGBA(0,0,0,192));
addGfxCmdText(x+AREA_HEADER/2, y+h-AREA_HEADER/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, name, imguiRGBA(255,255,255,128)); addGfxCmdText(x+AREA_HEADER/2, y+h-AREA_HEADER/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, name, imguiRGBA(255,255,255,128));
@ -403,12 +403,12 @@ void imguiEndScrollArea()
} }
// BG // BG
addGfxCmdRoundedRect(x, y, w, h, w/2-1, imguiRGBA(0,0,0,196)); addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)w/2-1, imguiRGBA(0,0,0,196));
// Bar // Bar
if (isActive(hid)) if (isActive(hid))
addGfxCmdRoundedRect(hx, hy, hw, hh, w/2-1, imguiRGBA(255,196,0,196)); addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w/2-1, imguiRGBA(255,196,0,196));
else else
addGfxCmdRoundedRect(hx, hy, hw, hh, w/2-1, isHot(hid) ? imguiRGBA(255,196,0,96) : imguiRGBA(255,255,255,64)); addGfxCmdRoundedRect((float)hx, (float)hy, (float)hw, (float)hh, (float)w/2-1, isHot(hid) ? imguiRGBA(255,196,0,96) : imguiRGBA(255,255,255,64));
// Handle mouse scrolling. // Handle mouse scrolling.
if (g_insideScrollArea) // && !anyActive()) if (g_insideScrollArea) // && !anyActive())
@ -438,7 +438,7 @@ bool imguiButton(const char* text, bool enabled)
bool over = enabled && inRect(x, y, w, h); bool over = enabled && inRect(x, y, w, h);
bool res = buttonLogic(id, over); bool res = buttonLogic(id, over);
addGfxCmdRoundedRect(x, y, w, h, BUTTON_HEIGHT/2-1, imguiRGBA(128,128,128, isActive(id)?196:96)); addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, (float)BUTTON_HEIGHT/2-1, imguiRGBA(128,128,128, isActive(id)?196:96));
if (enabled) if (enabled)
addGfxCmdText(x+BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200)); addGfxCmdText(x+BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200));
else else
@ -462,7 +462,7 @@ bool imguiItem(const char* text, bool enabled)
bool res = buttonLogic(id, over); bool res = buttonLogic(id, over);
if (isHot(id)) if (isHot(id))
addGfxCmdRoundedRect(x, y, w, h, 2, imguiRGBA(255,196,0,isActive(id)?196:96)); addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 2.0f, imguiRGBA(255,196,0,isActive(id)?196:96));
if (enabled) if (enabled)
addGfxCmdText(x+BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(255,255,255,200)); addGfxCmdText(x+BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(255,255,255,200));
@ -488,13 +488,13 @@ bool imguiCheck(const char* text, bool checked, bool enabled)
const int cx = x+BUTTON_HEIGHT/2-CHECK_SIZE/2; const int cx = x+BUTTON_HEIGHT/2-CHECK_SIZE/2;
const int cy = y+BUTTON_HEIGHT/2-CHECK_SIZE/2; const int cy = y+BUTTON_HEIGHT/2-CHECK_SIZE/2;
addGfxCmdRoundedRect(cx-3, cy-3, CHECK_SIZE+6, CHECK_SIZE+6, 4, imguiRGBA(128,128,128, isActive(id)?196:96)); addGfxCmdRoundedRect((float)cx-3, (float)cy-3, (float)CHECK_SIZE+6, (float)CHECK_SIZE+6, 4, imguiRGBA(128,128,128, isActive(id)?196:96));
if (checked) if (checked)
{ {
if (enabled) if (enabled)
addGfxCmdRoundedRect(cx, cy, CHECK_SIZE, CHECK_SIZE, CHECK_SIZE/2-1, imguiRGBA(255,255,255,isActive(id)?255:200)); addGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE/2-1, imguiRGBA(255,255,255,isActive(id)?255:200));
else else
addGfxCmdRoundedRect(cx, cy, CHECK_SIZE, CHECK_SIZE, CHECK_SIZE/2-1, imguiRGBA(128,128,128,200)); addGfxCmdRoundedRect((float)cx, (float)cy, (float)CHECK_SIZE, (float)CHECK_SIZE, (float)CHECK_SIZE/2-1, imguiRGBA(128,128,128,200));
} }
if (enabled) if (enabled)
@ -567,7 +567,7 @@ bool imguiSlider(const char* text, float* val, float vmin, float vmax, float vin
int h = SLIDER_HEIGHT; int h = SLIDER_HEIGHT;
g_state.widgetY -= SLIDER_HEIGHT + DEFAULT_SPACING; g_state.widgetY -= SLIDER_HEIGHT + DEFAULT_SPACING;
addGfxCmdRoundedRect(x, y, w, h, 4, imguiRGBA(0,0,0,128)); addGfxCmdRoundedRect((float)x, (float)y, (float)w, (float)h, 4.0f, imguiRGBA(0,0,0,128));
const int range = w - SLIDER_MARKER_WIDTH; const int range = w - SLIDER_MARKER_WIDTH;
@ -600,9 +600,9 @@ bool imguiSlider(const char* text, float* val, float vmin, float vmax, float vin
} }
if (isActive(id)) if (isActive(id))
addGfxCmdRoundedRect(x+m, y, SLIDER_MARKER_WIDTH, SLIDER_HEIGHT, 4, imguiRGBA(255,255,255,255)); addGfxCmdRoundedRect((float)(x+m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, imguiRGBA(255,255,255,255));
else else
addGfxCmdRoundedRect(x+m, y, SLIDER_MARKER_WIDTH, SLIDER_HEIGHT, 4, isHot(id) ? imguiRGBA(255,196,0,128) : imguiRGBA(255,255,255,64)); addGfxCmdRoundedRect((float)(x+m), (float)y, (float)SLIDER_MARKER_WIDTH, (float)SLIDER_HEIGHT, 4.0f, isHot(id) ? imguiRGBA(255,196,0,128) : imguiRGBA(255,255,255,64));
// TODO: fix this, take a look at 'nicenum'. // TODO: fix this, take a look at 'nicenum'.
int digits = (int)(ceilf(log10f(vinc))); int digits = (int)(ceilf(log10f(vinc)));
@ -651,7 +651,7 @@ void imguiSeparatorLine()
int h = 1; int h = 1;
g_state.widgetY -= DEFAULT_SPACING*4; g_state.widgetY -= DEFAULT_SPACING*4;
addGfxCmdRect(x, y, w, h, imguiRGBA(255,255,255,32)); addGfxCmdRect((float)x, (float)y, (float)w, (float)h, imguiRGBA(255,255,255,32));
} }
void imguiDrawText(int x, int y, int align, const char* text, unsigned int color) void imguiDrawText(int x, int y, int align, const char* text, unsigned int color)