Fixed bug where clicks went through GUI. Added a couple of consts into detail mesh code.

This commit is contained in:
Mikko Mononen 2010-04-20 07:35:40 +00:00
parent 32b54f7981
commit 4c1a122a91
5 changed files with 116 additions and 32 deletions

View File

@ -101,15 +101,15 @@ static float distPtTri(const float* p, const float* a, const float* b, const flo
const float dot12 = vdot2(v1, v2);
// Compute barycentric coordinates
float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);
float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
const float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01);
const float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
// If point lies inside the triangle, return interpolated y-coord.
static const float EPS = 1e-4f;
if (u >= -EPS && v >= -EPS && (u+v) <= 1+EPS)
{
float y = a[1] + v0[1]*u + v1[1]*v;
const float y = a[1] + v0[1]*u + v1[1]*v;
return fabsf(y-p[1]);
}
return FLT_MAX;

View File

@ -143,6 +143,13 @@
6B6C4655117C9962002CDD36 /* PBXTextBookmark */ = 6B6C4655117C9962002CDD36 /* PBXTextBookmark */;
6B6C4658117C998D002CDD36 /* PBXTextBookmark */ = 6B6C4658117C998D002CDD36 /* PBXTextBookmark */;
6B6C465F117C998D002CDD36 /* PBXTextBookmark */ = 6B6C465F117C998D002CDD36 /* PBXTextBookmark */;
6B6C466F117D8D60002CDD36 /* PBXTextBookmark */ = 6B6C466F117D8D60002CDD36 /* PBXTextBookmark */;
6B6C4670117D8D60002CDD36 /* PBXTextBookmark */ = 6B6C4670117D8D60002CDD36 /* PBXTextBookmark */;
6B6C4671117D8D60002CDD36 /* PBXTextBookmark */ = 6B6C4671117D8D60002CDD36 /* PBXTextBookmark */;
6B6C4672117D8D60002CDD36 /* PBXTextBookmark */ = 6B6C4672117D8D60002CDD36 /* PBXTextBookmark */;
6B6C4673117D8D60002CDD36 /* PBXTextBookmark */ = 6B6C4673117D8D60002CDD36 /* PBXTextBookmark */;
6B6C4674117D8D60002CDD36 /* PBXTextBookmark */ = 6B6C4674117D8D60002CDD36 /* PBXTextBookmark */;
6B6C4675117D8D60002CDD36 /* PBXTextBookmark */ = 6B6C4675117D8D60002CDD36 /* PBXTextBookmark */;
6BBB4A96115B4F3400CF791D = 6BBB4A96115B4F3400CF791D /* PBXTextBookmark */;
6BBB4A9E115B4F3400CF791D = 6BBB4A9E115B4F3400CF791D /* PBXTextBookmark */;
6BBB4AA1115B4F3400CF791D = 6BBB4AA1115B4F3400CF791D /* PBXTextBookmark */;
@ -390,9 +397,9 @@
};
6B1185FC10068B040018F96F /* DetourCommon.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {909, 3264}}";
sepNavSelRange = "{5773, 0}";
sepNavVisRange = "{4630, 1251}";
sepNavIntBoundsRect = "{{0, 0}, {909, 2912}}";
sepNavSelRange = "{5273, 0}";
sepNavVisRange = "{4789, 1092}";
};
};
6B1185FD10068B150018F96F /* DetourCommon.cpp */ = {
@ -540,9 +547,9 @@
};
6B25B6180FFA62BE004F1BC4 /* main.cpp */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {909, 14032}}";
sepNavSelRange = "{10727, 0}";
sepNavVisRange = "{10443, 687}";
sepNavIntBoundsRect = "{{0, 0}, {909, 14208}}";
sepNavSelRange = "{7642, 0}";
sepNavVisRange = "{7154, 809}";
};
};
6B2AEC510FFB8946005BE9CC /* Sample_TileMesh.h */ = {
@ -609,7 +616,7 @@
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 429";
rLen = 0;
rLoc = 10727;
rLoc = 10818;
rType = 0;
vrLen = 687;
vrLoc = 10443;
@ -629,7 +636,7 @@
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 429";
rLen = 0;
rLoc = 10727;
rLoc = 10818;
rType = 0;
vrLen = 687;
vrLoc = 10443;
@ -677,7 +684,7 @@
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 429";
rLen = 0;
rLoc = 10727;
rLoc = 10818;
rType = 0;
vrLen = 687;
vrLoc = 10443;
@ -762,6 +769,76 @@
vrLen = 501;
vrLoc = 0;
};
6B6C466F117D8D60002CDD36 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */;
name = "DetourNavMesh.cpp: 1603";
rLen = 0;
rLoc = 43554;
rType = 0;
vrLen = 718;
vrLoc = 43246;
};
6B6C4670117D8D60002CDD36 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B1185FC10068B040018F96F /* DetourCommon.h */;
name = "DetourCommon.h: 189";
rLen = 0;
rLoc = 5273;
rType = 0;
vrLen = 1092;
vrLoc = 4789;
};
6B6C4671117D8D60002CDD36 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 429";
rLen = 0;
rLoc = 10818;
rType = 0;
vrLen = 601;
vrLoc = 10443;
};
6B6C4672117D8D60002CDD36 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */;
name = "DetourNavMesh.cpp: 1603";
rLen = 0;
rLoc = 43554;
rType = 0;
vrLen = 718;
vrLoc = 43246;
};
6B6C4673117D8D60002CDD36 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B1185FC10068B040018F96F /* DetourCommon.h */;
name = "DetourCommon.h: 189";
rLen = 0;
rLoc = 5273;
rType = 0;
vrLen = 1092;
vrLoc = 4789;
};
6B6C4674117D8D60002CDD36 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 311";
rLen = 0;
rLoc = 7642;
rType = 0;
vrLen = 809;
vrLoc = 7154;
};
6B6C4675117D8D60002CDD36 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 6BF5F3761175AACB000502A6 /* glimage.h */;
name = "glimage.h: 30";
rLen = 71;
rLoc = 419;
rType = 0;
vrLen = 501;
vrLoc = 0;
};
6B8036AC113BAABE005ED67B /* Sample_Debug.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {815, 896}}";
@ -3313,7 +3390,7 @@
fRef = 6B25B6180FFA62BE004F1BC4 /* main.cpp */;
name = "main.cpp: 434";
rLen = 0;
rLoc = 10873;
rLoc = 10964;
rType = 0;
vrLen = 687;
vrLoc = 10443;

View File

@ -216,7 +216,7 @@
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>6B6C465F117C998D002CDD36</string>
<string>6B6C4675117D8D60002CDD36</string>
<key>history</key>
<array>
<string>6BF5F55B1176FEC8000502A6</string>
@ -323,14 +323,13 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>18</integer>
<integer>11</integer>
<integer>46</integer>
<integer>1</integer>
<integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 102}, {264, 643}}</string>
<string>{{0, 427}, {264, 643}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@ -365,7 +364,7 @@
<key>PBXProjectModuleGUID</key>
<string>6B8632A30F78115100E2684A</string>
<key>PBXProjectModuleLabel</key>
<string>DetourNavMesh.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>DetourNavMesh.cpp</string>
<string>main.cpp</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>6B6C4658117C998D002CDD36</string>
<string>6B6C4674117D8D60002CDD36</string>
<key>history</key>
<array>
<string>6BBB4A96115B4F3400CF791D</string>
@ -440,11 +439,11 @@
<string>6BF5F50C1176F5F8000502A6</string>
<string>6BF5F50D1176F5F8000502A6</string>
<string>6BF5F52C1176FA0B000502A6</string>
<string>6B6C464A117C9962002CDD36</string>
<string>6B6C464B117C9962002CDD36</string>
<string>6B6C464C117C9962002CDD36</string>
<string>6B6C464D117C9962002CDD36</string>
<string>6B6C464E117C9962002CDD36</string>
<string>6B6C466F117D8D60002CDD36</string>
<string>6B6C4670117D8D60002CDD36</string>
<string>6B6C4671117D8D60002CDD36</string>
</array>
<key>prevStack</key>
<array>
@ -517,6 +516,8 @@
<string>6B6C4651117C9962002CDD36</string>
<string>6B6C4652117C9962002CDD36</string>
<string>6B6C4653117C9962002CDD36</string>
<string>6B6C4672117D8D60002CDD36</string>
<string>6B6C4673117D8D60002CDD36</string>
</array>
</dict>
<key>SplitCount</key>
@ -530,18 +531,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {970, 490}}</string>
<string>{{0, 0}, {970, 572}}</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>490pt</string>
<string>572pt</string>
</dict>
<dict>
<key>Proportion</key>
<string>166pt</string>
<string>84pt</string>
<key>Tabs</key>
<array>
<dict>
@ -609,7 +610,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {970, 139}}</string>
<string>{{10, 27}, {970, 57}}</string>
<key>RubberWindowFrame</key>
<string>13 75 1256 702 0 0 1280 778 </string>
</dict>

View File

@ -293,16 +293,22 @@ int main(int /*argc*/, char** /*argv*/)
if (event.button.button == SDL_BUTTON_RIGHT)
{
rotate = false;
if (!movedDuringRotate)
if (!mouseOverMenu)
{
processHitTest = true;
processHitTestShift = true;
if (!movedDuringRotate)
{
processHitTest = true;
processHitTestShift = true;
}
}
}
else if (event.button.button == SDL_BUTTON_LEFT)
{
processHitTest = true;
processHitTestShift = (SDL_GetModState() & KMOD_SHIFT) ? true : false;
if (!mouseOverMenu)
{
processHitTest = true;
processHitTestShift = (SDL_GetModState() & KMOD_SHIFT) ? true : false;
}
}
break;