diff --git a/RecastDemo/Bin/Recast.app/Contents/MacOS/Recast b/RecastDemo/Bin/Recast.app/Contents/MacOS/Recast index ba33153..0dd4dc7 100755 Binary files a/RecastDemo/Bin/Recast.app/Contents/MacOS/Recast and b/RecastDemo/Bin/Recast.app/Contents/MacOS/Recast differ diff --git a/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.pbxuser b/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.pbxuser index dd88f45..afd7309 100644 --- a/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.pbxuser +++ b/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.pbxuser @@ -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}}"; diff --git a/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.perspectivev3 b/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.perspectivev3 index ab17880..c91dbe4 100644 --- a/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.perspectivev3 +++ b/RecastDemo/Build/Xcode/Recast.xcodeproj/memon.perspectivev3 @@ -216,7 +216,7 @@ _historyCapacity 0 bookmark - 6BF5F5241176F5F8000502A6 + 6BF5F5571176FB74000502A6 history 6BF5F3751175AACB000502A6 @@ -323,14 +323,13 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 5 - 2 + 46 1 0 PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 22}, {264, 643}} + {{0, 396}, {264, 643}} PBXTopSmartGroupGIDs @@ -365,7 +364,7 @@ PBXProjectModuleGUID 6B8632A30F78115100E2684A PBXProjectModuleLabel - Sample_SoloMeshTiled.cpp + main.cpp PBXSplitModuleInNavigatorKey Split0 @@ -373,11 +372,11 @@ PBXProjectModuleGUID 6B8632A40F78115100E2684A PBXProjectModuleLabel - Sample_SoloMeshTiled.cpp + main.cpp _historyCapacity 0 bookmark - 6BF5F5231176F5F8000502A6 + 6BF5F5561176FB74000502A6 history 6BBB4A96115B4F3400CF791D @@ -411,7 +410,6 @@ 6BF5F2E611748884000502A6 6BF5F2E711748884000502A6 6BF5F2EA11748884000502A6 - 6BF5F30E1174904B000502A6 6BF5F31C117490A1000502A6 6BF5F32E11759C3C000502A6 6BF5F32F11759C3C000502A6 @@ -444,7 +442,8 @@ 6BF5F50B1176F5F8000502A6 6BF5F50C1176F5F8000502A6 6BF5F50D1176F5F8000502A6 - 6BF5F50E1176F5F8000502A6 + 6BF5F52C1176FA0B000502A6 + 6BF5F5321176FA1E000502A6 prevStack @@ -596,6 +595,7 @@ 6BF5F5201176F5F8000502A6 6BF5F5211176F5F8000502A6 6BF5F5221176F5F8000502A6 + 6BF5F52E1176FA0B000502A6 SplitCount @@ -609,18 +609,18 @@ GeometryConfiguration Frame - {{0, 0}, {970, 390}} + {{0, 0}, {970, 530}} RubberWindowFrame 13 75 1256 702 0 0 1280 778 Module PBXNavigatorGroup Proportion - 390pt + 530pt Proportion - 266pt + 126pt Tabs @@ -688,7 +688,7 @@ GeometryConfiguration Frame - {{10, 27}, {970, 239}} + {{10, 27}, {970, 99}} RubberWindowFrame 13 75 1256 702 0 0 1280 778 @@ -910,6 +910,8 @@ 5 WindowOrderList + 6BF5F5491176FAD9000502A6 + 6BF5F54A1176FAD9000502A6 6BF5F29911747CFA000502A6 /Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj diff --git a/RecastDemo/Source/main.cpp b/RecastDemo/Source/main.cpp index 9a4217d..f377a4b 100644 --- a/RecastDemo/Source/main.cpp +++ b/RecastDemo/Source/main.cpp @@ -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)); }