-
Notifications
You must be signed in to change notification settings - Fork 17
/
ode-0.12-heightfield.patch
93 lines (81 loc) · 3.54 KB
/
ode-0.12-heightfield.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--- ode/src/heightfield.cpp 2011-02-15 16:43:31.000000000 +0100
+++ ode/src/heightfield.cpp 2020-01-23 14:26:32.000000000 +0100
@@ -239,7 +239,7 @@
// returns whether point is over terrain Cell triangle?
bool dxHeightfieldData::IsOnHeightfield2 ( const HeightFieldVertex * const CellCorner,
- const dReal * const pos, const bool isABC) const
+ const dReal * const pos, const bool isABC, dReal &epsilon) const
{
// WARNING!!!
// This function must be written in the way to make sure that every point on
@@ -257,43 +257,43 @@
{
// point A
MinX = CellCorner->vertex[0];
- if (pos[0] < MinX)
+ if (pos[0] + epsilon < MinX)
return false;
MaxX = (CellCorner->coords[0] + 1) * m_fSampleWidth;
- if (pos[0] >= MaxX)
+ if (pos[0] - epsilon >= MaxX)
return false;
MinZ = CellCorner->vertex[2];
- if (pos[2] < MinZ)
+ if (pos[2] + epsilon < MinZ)
return false;
MaxZ = (CellCorner->coords[1] + 1) * m_fSampleDepth;
- if (pos[2] >= MaxZ)
+ if (pos[2] - epsilon >= MaxZ)
return false;
- return (MaxZ - pos[2]) > (pos[0] - MinX) * m_fSampleZXAspect;
+ return (MaxZ - pos[2] + epsilon) > (pos[0] - MinX - epsilon) * m_fSampleZXAspect;
}
else
{
// point D
MaxX = CellCorner->vertex[0];
- if (pos[0] >= MaxX)
+ if (pos[0] - epsilon >= MaxX)
return false;
MinX = (CellCorner->coords[0] - 1) * m_fSampleWidth;
- if (pos[0] < MinX)
+ if (pos[0] + epsilon < MinX)
return false;
MaxZ = CellCorner->vertex[2];
- if (pos[2] >= MaxZ)
+ if (pos[2] - epsilon >= MaxZ)
return false;
MinZ = (CellCorner->coords[1] - 1) * m_fSampleDepth;
- if (pos[2] < MinZ)
+ if (pos[2] + epsilon < MinZ)
return false;
- return (MaxZ - pos[2]) <= (pos[0] - MinX) * m_fSampleZXAspect;
+ return (MaxZ - pos[2] + epsilon) <= (pos[0] - MinX - epsilon) * m_fSampleZXAspect;
}
}
@@ -1477,12 +1477,13 @@
{
dContactGeom *planeCurrContact = PlaneContact + i;
// Check if contact point found in plane is inside Triangle.
- const dVector3 &pCPos = planeCurrContact->pos;
+ dVector3 pCPos;
+ dAddScaledVectors3(pCPos, planeCurrContact->pos, planeCurrContact->normal, 1.0, planeCurrContact->depth);
for (size_t b = 0; planeTriListSize > b; b++)
{
if (m_p_data->IsOnHeightfield2 (itPlane->trianglelist[b]->vertices[0],
pCPos,
- itPlane->trianglelist[b]->isUp))
+ itPlane->trianglelist[b]->isUp, planeCurrContact->depth))
{
pContact = CONTACT(contact, numTerrainContacts*skip);
dVector3Copy(pCPos, pContact->pos);
diff -ur ode-0.12/ode/src/heightfield.h ode/ode/src/heightfield.h
--- ode/src/heightfield.h 2009-02-05 09:19:38.000000000 +0100
+++ ode/src/heightfield.h 2020-01-29 14:03:54.000000000 +0100
@@ -66,7 +66,7 @@
void ComputeHeightBounds();
bool IsOnHeightfield2 ( const HeightFieldVertex * const CellCorner,
- const dReal * const pos, const bool isABC) const;
+ const dReal * const pos, const bool isABC, dReal &epsilon) const;
dReal GetHeight(int x, int z);
dReal GetHeight(dReal x, dReal z);