A couple of changes for Issue 52.

This commit is contained in:
Mikko Mononen 2010-04-15 07:46:50 +00:00
parent d5c65a220f
commit 07c5750e8a
4 changed files with 394 additions and 70 deletions

View File

@ -20,6 +20,7 @@
6BBB4BBE115B64E600CF791D /* Sample_TileMesh.cpp:592 */,
6BBB4C4C115B7BAD00CF791D /* Sample_TileMesh.cpp:264 */,
6BF5F32C11759C35000502A6 /* DetourNavMesh.cpp:144 */,
6BF5F54F1176FAFC000502A6 /* main.cpp:175 */,
);
codeSenseManager = 6B8632AA0F78115100E2684A /* Code sense */;
executables = (
@ -470,6 +471,31 @@
6BF5F5221176F5F8000502A6 /* PBXTextBookmark */ = 6BF5F5221176F5F8000502A6 /* PBXTextBookmark */;
6BF5F5231176F5F8000502A6 /* PBXTextBookmark */ = 6BF5F5231176F5F8000502A6 /* PBXTextBookmark */;
6BF5F5241176F5F8000502A6 /* PBXTextBookmark */ = 6BF5F5241176F5F8000502A6 /* PBXTextBookmark */;
6BF5F52C1176FA0B000502A6 /* PBXTextBookmark */ = 6BF5F52C1176FA0B000502A6 /* PBXTextBookmark */;
6BF5F52D1176FA0B000502A6 /* PBXTextBookmark */ = 6BF5F52D1176FA0B000502A6 /* PBXTextBookmark */;
6BF5F52E1176FA0B000502A6 /* PBXTextBookmark */ = 6BF5F52E1176FA0B000502A6 /* PBXTextBookmark */;
6BF5F52F1176FA0B000502A6 /* PBXTextBookmark */ = 6BF5F52F1176FA0B000502A6 /* PBXTextBookmark */;
6BF5F5301176FA19000502A6 /* PBXTextBookmark */ = 6BF5F5301176FA19000502A6 /* PBXTextBookmark */;
6BF5F5311176FA19000502A6 /* PBXTextBookmark */ = 6BF5F5311176FA19000502A6 /* PBXTextBookmark */;
6BF5F5321176FA1E000502A6 /* PBXTextBookmark */ = 6BF5F5321176FA1E000502A6 /* PBXTextBookmark */;
6BF5F5351176FA21000502A6 /* PBXTextBookmark */ = 6BF5F5351176FA21000502A6 /* PBXTextBookmark */;
6BF5F5361176FA21000502A6 /* PBXTextBookmark */ = 6BF5F5361176FA21000502A6 /* PBXTextBookmark */;
6BF5F5391176FA51000502A6 /* PBXTextBookmark */ = 6BF5F5391176FA51000502A6 /* PBXTextBookmark */;
6BF5F53A1176FA51000502A6 /* PBXTextBookmark */ = 6BF5F53A1176FA51000502A6 /* PBXTextBookmark */;
6BF5F53C1176FA7E000502A6 /* PBXTextBookmark */ = 6BF5F53C1176FA7E000502A6 /* PBXTextBookmark */;
6BF5F53D1176FA7E000502A6 /* PBXTextBookmark */ = 6BF5F53D1176FA7E000502A6 /* PBXTextBookmark */;
6BF5F53F1176FACA000502A6 /* PBXTextBookmark */ = 6BF5F53F1176FACA000502A6 /* PBXTextBookmark */;
6BF5F5401176FACA000502A6 /* PBXTextBookmark */ = 6BF5F5401176FACA000502A6 /* PBXTextBookmark */;
6BF5F5461176FAD9000502A6 /* PBXTextBookmark */ = 6BF5F5461176FAD9000502A6 /* PBXTextBookmark */;
6BF5F5471176FAD9000502A6 /* PBXTextBookmark */ = 6BF5F5471176FAD9000502A6 /* PBXTextBookmark */;
6BF5F54C1176FAF1000502A6 /* PBXTextBookmark */ = 6BF5F54C1176FAF1000502A6 /* PBXTextBookmark */;
6BF5F54D1176FAF1000502A6 /* PBXTextBookmark */ = 6BF5F54D1176FAF1000502A6 /* PBXTextBookmark */;
6BF5F5501176FAFE000502A6 /* PBXTextBookmark */ = 6BF5F5501176FAFE000502A6 /* PBXTextBookmark */;
6BF5F5511176FAFE000502A6 /* PBXTextBookmark */ = 6BF5F5511176FAFE000502A6 /* PBXTextBookmark */;
6BF5F5541176FB4D000502A6 /* PBXTextBookmark */ = 6BF5F5541176FB4D000502A6 /* PBXTextBookmark */;
6BF5F5551176FB4D000502A6 /* PBXTextBookmark */ = 6BF5F5551176FB4D000502A6 /* PBXTextBookmark */;
6BF5F5561176FB74000502A6 /* PBXTextBookmark */ = 6BF5F5561176FB74000502A6 /* PBXTextBookmark */;
6BF5F5571176FB74000502A6 /* PBXTextBookmark */ = 6BF5F5571176FB74000502A6 /* PBXTextBookmark */;
};
sourceControlManager = 6B8632A90F78115100E2684A /* Source Control */;
userBookmarkGroup = 6B8DE6F010A88F0500DF20FB /* PBXBookmarkGroup */;
@ -650,9 +676,9 @@
};
6B25B6180FFA62BE004F1BC4 /* main.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1195, 13600}}";
sepNavSelRange = "{20340, 0}";
sepNavVisRange = "{20166, 253}";
sepNavIntBoundsRect = "{{0, 0}, {909, 13760}}";
sepNavSelRange = "{10895, 0}";
sepNavVisRange = "{10443, 687}";
};
};
6B2AEC510FFB8946005BE9CC /* Sample_TileMesh.h */ = {
@ -1877,7 +1903,7 @@
ignoreCount = 0;
lineNumber = 559;
location = Recast;
modificationTime = 292920376.024392;
modificationTime = 293010172.768247;
state = 1;
};
6BBB4BBE115B64E600CF791D /* Sample_TileMesh.cpp:592 */ = {
@ -1894,7 +1920,7 @@
ignoreCount = 0;
lineNumber = 592;
location = Recast;
modificationTime = 292920376.024606;
modificationTime = 293010172.768615;
state = 1;
};
6BBB4C34115B7A3D00CF791D /* PBXTextBookmark */ = {
@ -1945,7 +1971,7 @@
ignoreCount = 0;
lineNumber = 264;
location = Recast;
modificationTime = 292920376.024748;
modificationTime = 293010172.768776;
state = 1;
};
6BCF32341104CD05009445BF /* OffMeshConnectionTool.h */ = {
@ -2311,7 +2337,7 @@
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 174";
rLen = 0;
rLoc = 4347;
rLoc = 4475;
rType = 0;
vrLen = 880;
vrLoc = 4268;
@ -2341,7 +2367,7 @@
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 605";
rLen = 0;
rLoc = 14641;
rLoc = 15086;
rType = 0;
vrLen = 833;
vrLoc = 14318;
@ -2351,7 +2377,7 @@
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 605";
rLen = 0;
rLoc = 14641;
rLoc = 15086;
rType = 0;
vrLen = 833;
vrLoc = 14318;
@ -2426,11 +2452,11 @@
delayBeforeContinue = 0;
fileReference = 6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */;
functionName = "dtNavMesh::raycast(dtPolyRef centerRef, const float* startPos, const float* endPos, dtQueryFilter* filter, float& t, float* hitNormal, dtPolyRef* path, const int pathSize)";
hitCount = 1;
hitCount = 0;
ignoreCount = 0;
lineNumber = 144;
location = Recast;
modificationTime = 292920411.683684;
modificationTime = 293010172.768971;
state = 1;
};
6BF5F32E11759C3C000502A6 /* PBXTextBookmark */ = {
@ -4536,6 +4562,273 @@
vrLen = 501;
vrLoc = 0;
};
6BF5F52C1176FA0B000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BA1E88910C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp */;
name = "Sample_SoloMeshTiled.cpp: 368";
rLen = 0;
rLoc = 11004;
rType = 0;
vrLen = 719;
vrLoc = 10617;
};
6BF5F52D1176FA0B000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 605";
rLen = 0;
rLoc = 15086;
rType = 0;
vrLen = 545;
vrLoc = 14606;
};
6BF5F52E1176FA0B000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BA1E88910C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp */;
name = "Sample_SoloMeshTiled.cpp: 368";
rLen = 0;
rLoc = 11004;
rType = 0;
vrLen = 719;
vrLoc = 10617;
};
6BF5F52F1176FA0B000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 288";
rLen = 0;
rLoc = 7099;
rType = 0;
vrLen = 691;
vrLoc = 6742;
};
6BF5F5301176FA19000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 288";
rLen = 0;
rLoc = 7099;
rType = 0;
vrLen = 691;
vrLoc = 6742;
};
6BF5F5311176FA19000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F5321176FA1E000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 290";
rLen = 0;
rLoc = 7108;
rType = 0;
vrLen = 533;
vrLoc = 6836;
};
6BF5F5351176FA21000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 292";
rLen = 0;
rLoc = 7153;
rType = 0;
vrLen = 639;
vrLoc = 6780;
};
6BF5F5361176FA21000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F5391176FA51000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 426";
rLen = 0;
rLoc = 10638;
rType = 0;
vrLen = 1201;
vrLoc = 9716;
};
6BF5F53A1176FA51000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F53C1176FA7E000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 277";
rLen = 0;
rLoc = 6890;
rType = 0;
vrLen = 617;
vrLoc = 6491;
};
6BF5F53D1176FA7E000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F53F1176FACA000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 255";
rLen = 0;
rLoc = 6446;
rType = 0;
vrLen = 777;
vrLoc = 5932;
};
6BF5F5401176FACA000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F5461176FAD9000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 255";
rLen = 0;
rLoc = 6425;
rType = 0;
vrLen = 777;
vrLoc = 5932;
};
6BF5F5471176FAD9000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F54C1176FAF1000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 251";
rLen = 0;
rLoc = 6354;
rType = 0;
vrLen = 778;
vrLoc = 5932;
};
6BF5F54D1176FAF1000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F54F1176FAFC000502A6 /* main.cpp:175 */ = {
isa = PBXFileBreakpoint;
actions = (
);
breakpointStyle = 0;
continueAfterActions = 0;
countType = 0;
delayBeforeContinue = 0;
fileReference = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
functionName = "main(int /*argc*/, char** /*argv*/)";
hitCount = 2;
ignoreCount = 0;
lineNumber = 175;
location = Recast;
modificationTime = 293010189.018543;
state = 1;
};
6BF5F5501176FAFE000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 175";
rLen = 0;
rLoc = 4413;
rType = 0;
vrLen = 696;
vrLoc = 4165;
};
6BF5F5511176FAFE000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F5541176FB4D000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 416";
rLen = 0;
rLoc = 10388;
rType = 0;
vrLen = 1226;
vrLoc = 9476;
};
6BF5F5551176FB4D000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 495;
vrLoc = 0;
};
6BF5F5561176FB74000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 437";
rLen = 0;
rLoc = 10895;
rType = 0;
vrLen = 687;
vrLoc = 10443;
};
6BF5F5571176FB74000502A6 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F2B911747E6F000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 501;
vrLoc = 0;
};
6BF7C13E11119520002B3F46 /* TestCase.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {815, 1264}}";

View File

@ -216,7 +216,7 @@
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>6BF5F5241176F5F8000502A6</string>
<string>6BF5F5571176FB74000502A6</string>
<key>history</key>
<array>
<string>6BF5F3751175AACB000502A6</string>
@ -323,14 +323,13 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>5</integer>
<integer>2</integer>
<integer>46</integer>
<integer>1</integer>
<integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 22}, {264, 643}}</string>
<string>{{0, 396}, {264, 643}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@ -365,7 +364,7 @@
<key>PBXProjectModuleGUID</key>
<string>6B8632A30F78115100E2684A</string>
<key>PBXProjectModuleLabel</key>
<string>Sample_SoloMeshTiled.cpp</string>
<string>main.cpp</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
@ -373,11 +372,11 @@
<key>PBXProjectModuleGUID</key>
<string>6B8632A40F78115100E2684A</string>
<key>PBXProjectModuleLabel</key>
<string>Sample_SoloMeshTiled.cpp</string>
<string>main.cpp</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>6BF5F5231176F5F8000502A6</string>
<string>6BF5F5561176FB74000502A6</string>
<key>history</key>
<array>
<string>6BBB4A96115B4F3400CF791D</string>
@ -411,7 +410,6 @@
<string>6BF5F2E611748884000502A6</string>
<string>6BF5F2E711748884000502A6</string>
<string>6BF5F2EA11748884000502A6</string>
<string>6BF5F30E1174904B000502A6</string>
<string>6BF5F31C117490A1000502A6</string>
<string>6BF5F32E11759C3C000502A6</string>
<string>6BF5F32F11759C3C000502A6</string>
@ -444,7 +442,8 @@
<string>6BF5F50B1176F5F8000502A6</string>
<string>6BF5F50C1176F5F8000502A6</string>
<string>6BF5F50D1176F5F8000502A6</string>
<string>6BF5F50E1176F5F8000502A6</string>
<string>6BF5F52C1176FA0B000502A6</string>
<string>6BF5F5321176FA1E000502A6</string>
</array>
<key>prevStack</key>
<array>
@ -596,6 +595,7 @@
<string>6BF5F5201176F5F8000502A6</string>
<string>6BF5F5211176F5F8000502A6</string>
<string>6BF5F5221176F5F8000502A6</string>
<string>6BF5F52E1176FA0B000502A6</string>
</array>
</dict>
<key>SplitCount</key>
@ -609,18 +609,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {970, 390}}</string>
<string>{{0, 0}, {970, 530}}</string>
<key>RubberWindowFrame</key>
<string>13 75 1256 702 0 0 1280 778 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>390pt</string>
<string>530pt</string>
</dict>
<dict>
<key>Proportion</key>
<string>266pt</string>
<string>126pt</string>
<key>Tabs</key>
<array>
<dict>
@ -688,7 +688,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {970, 239}}</string>
<string>{{10, 27}, {970, 99}}</string>
<key>RubberWindowFrame</key>
<string>13 75 1256 702 0 0 1280 778 </string>
</dict>
@ -910,6 +910,8 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>6BF5F5491176FAD9000502A6</string>
<string>6BF5F54A1176FAD9000502A6</string>
<string>6BF5F29911747CFA000502A6</string>
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
</array>

View File

@ -106,7 +106,9 @@ int main(int /*argc*/, char** /*argv*/)
float camx = 0, camy = 0, camz = 0, camr = 1000;
float origrx = 0, origry = 0;
int origx = 0, origy = 0;
float scrollZoom = 0;
bool rotate = false;
bool movedDuringRotate = false;
float rays[3], raye[3];
bool mouseOverMenu = false;
bool showMenu = true;
@ -160,10 +162,13 @@ int main(int /*argc*/, char** /*argv*/)
{
// Handle input events.
int mscroll = 0;
bool processHitTest = false;
bool processHitTestShift = false;
SDL_Event event;
while(SDL_PollEvent(&event))
while (SDL_PollEvent(&event))
{
switch(event.type)
switch (event.type)
{
case SDL_KEYDOWN:
// Handle any key presses here.
@ -254,66 +259,52 @@ int main(int /*argc*/, char** /*argv*/)
break;
case SDL_MOUSEBUTTONDOWN:
// Handle mouse clicks here.
if (!mouseOverMenu)
if (event.button.button == SDL_BUTTON_RIGHT)
{
if (event.button.button == SDL_BUTTON_RIGHT)
if (!mouseOverMenu)
{
// Rotate view
rotate = true;
movedDuringRotate = false;
origx = mx;
origy = my;
origrx = rx;
origry = ry;
}
else if (event.button.button == SDL_BUTTON_LEFT)
{
// Hit test mesh.
if (geom && sample)
{
// Hit test mesh.
float t;
if (geom->raycastMesh(rays, raye, t))
{
if (SDL_GetModState() & KMOD_CTRL)
{
mposSet = true;
mpos[0] = rays[0] + (raye[0] - rays[0])*t;
mpos[1] = rays[1] + (raye[1] - rays[1])*t;
mpos[2] = rays[2] + (raye[2] - rays[2])*t;
}
else
{
float pos[3];
pos[0] = rays[0] + (raye[0] - rays[0])*t;
pos[1] = rays[1] + (raye[1] - rays[1])*t;
pos[2] = rays[2] + (raye[2] - rays[2])*t;
bool shift = (SDL_GetModState() & KMOD_SHIFT) ? true : false;
sample->handleClick(pos, shift);
}
}
else
{
if (SDL_GetModState() & KMOD_CTRL)
{
mposSet = false;
}
}
}
}
}
if (event.button.button == SDL_BUTTON_WHEELUP)
mscroll--;
if (event.button.button == SDL_BUTTON_WHEELDOWN)
mscroll++;
else if (event.button.button == SDL_BUTTON_WHEELUP)
{
if (mouseOverMenu)
mscroll--;
else
scrollZoom -= 1.0f;
}
else if (event.button.button == SDL_BUTTON_WHEELDOWN)
{
if (mouseOverMenu)
mscroll++;
else
scrollZoom += 1.0f;
}
break;
case SDL_MOUSEBUTTONUP:
// Handle mouse clicks here.
if(event.button.button == SDL_BUTTON_RIGHT)
if (event.button.button == SDL_BUTTON_RIGHT)
{
rotate = false;
if (!movedDuringRotate)
{
processHitTest = true;
processHitTestShift = true;
}
}
else if (event.button.button == SDL_BUTTON_LEFT)
{
processHitTest = true;
processHitTestShift = (SDL_GetModState() & KMOD_SHIFT) ? true : false;
}
break;
case SDL_MOUSEMOTION:
@ -325,6 +316,8 @@ int main(int /*argc*/, char** /*argv*/)
int dy = my - origy;
rx = origrx - dy*0.25f;
ry = origry + dx*0.25f;
if (dx*dx+dy*dy > 3*3)
movedDuringRotate = true;
}
break;
@ -349,6 +342,39 @@ int main(int /*argc*/, char** /*argv*/)
t += dt;
// Hit test mesh.
if (processHitTest && geom && sample)
{
float t;
if (geom->raycastMesh(rays, raye, t))
{
if (SDL_GetModState() & KMOD_CTRL)
{
// Marker
mposSet = true;
mpos[0] = rays[0] + (raye[0] - rays[0])*t;
mpos[1] = rays[1] + (raye[1] - rays[1])*t;
mpos[2] = rays[2] + (raye[2] - rays[2])*t;
}
else
{
float pos[3];
pos[0] = rays[0] + (raye[0] - rays[0])*t;
pos[1] = rays[1] + (raye[1] - rays[1])*t;
pos[2] = rays[2] + (raye[2] - rays[2])*t;
sample->handleClick(pos, processHitTestShift);
}
}
else
{
if (SDL_GetModState() & KMOD_CTRL)
{
// Marker
mposSet = false;
}
}
}
// Update and render
glViewport(0, 0, width, height);
@ -396,6 +422,9 @@ int main(int /*argc*/, char** /*argv*/)
float movex = (moveD - moveA) * keybSpeed * dt;
float movey = (moveS - moveW) * keybSpeed * dt;
movey += scrollZoom * 2.0f;
scrollZoom = 0;
camx += movex * (float)model[0];
camy += movex * (float)model[4];
camz += movex * (float)model[8];
@ -439,7 +468,7 @@ int main(int /*argc*/, char** /*argv*/)
// Help text.
if (showMenu)
{
const char msg[] = "W/S/A/D: Move RMB: Rotate LMB: Place Start LMB+SHIFT: Place End";
const char msg[] = "W/S/A/D: Move RMB: Rotate LMB+SHIFT: Place Start LMB: Place End";
imguiDrawText(width/2, height-20, IMGUI_ALIGN_CENTER, msg, imguiRGBA(255,255,255,128));
}