Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 336 vs 337 for /trunk/Source Code/Libs/src/ReCast/ReCast/Source/RecastFilter.cpp

Diff revisions: vs.
  @@ -35,40 +35,40 @@
35 35 /// @see rcHeightfield, rcConfig
36 36 void rcFilterLowHangingWalkableObstacles(rcContext* ctx, const int walkableClimb, rcHeightfield& solid)
37 37 {
38 - rcAssert(ctx);
38 + rcAssert(ctx);
39 39
40 - ctx->startTimer(RC_TIMER_FILTER_LOW_OBSTACLES);
41 -
42 - const int w = solid.width;
43 - const int h = solid.height;
44 -
45 - for (int y = 0; y < h; ++y)
46 - {
47 - for (int x = 0; x < w; ++x)
48 - {
49 - rcSpan* ps = 0;
50 - bool previousWalkable = false;
51 - unsigned char previousArea = RC_NULL_AREA;
52 -
53 - for (rcSpan* s = solid.spans[x + y*w]; s; ps = s, s = s->next)
54 - {
55 - const bool walkable = s->area != RC_NULL_AREA;
56 - // If current span is not walkable, but there is walkable
57 - // span just below it, mark the span above it walkable too.
58 - if (!walkable && previousWalkable)
59 - {
60 - if (rcAbs((int)s->smax - (int)ps->smax) <= walkableClimb)
61 - s->area = previousArea;
62 - }
63 - // Copy walkable flag so that it cannot propagate
64 - // past multiple non-walkable objects.
65 - previousWalkable = walkable;
66 - previousArea = s->area;
67 - }
68 - }
69 - }
40 + ctx->startTimer(RC_TIMER_FILTER_LOW_OBSTACLES);
41 +
42 + const int w = solid.width;
43 + const int h = solid.height;
44 +
45 + for (int y = 0; y < h; ++y)
46 + {
47 + for (int x = 0; x < w; ++x)
48 + {
49 + rcSpan* ps = 0;
50 + bool previousWalkable = false;
51 + unsigned char previousArea = RC_NULL_AREA;
52 +
53 + for (rcSpan* s = solid.spans[x + y*w]; s; ps = s, s = s->next)
54 + {
55 + const bool walkable = s->area != RC_NULL_AREA;
56 + // If current span is not walkable, but there is walkable
57 + // span just below it, mark the span above it walkable too.
58 + if (!walkable && previousWalkable)
59 + {
60 + if (rcAbs((int)s->smax - (int)ps->smax) <= walkableClimb)
61 + s->area = previousArea;
62 + }
63 + // Copy walkable flag so that it cannot propagate
64 + // past multiple non-walkable objects.
65 + previousWalkable = walkable;
66 + previousArea = s->area;
67 + }
68 + }
69 + }
70 70
71 - ctx->stopTimer(RC_TIMER_FILTER_LOW_OBSTACLES);
71 + ctx->stopTimer(RC_TIMER_FILTER_LOW_OBSTACLES);
72 72 }
73 73
74 74 /// @par
  @@ -82,94 +82,94 @@
82 82 ///
83 83 /// @see rcHeightfield, rcConfig
84 84 void rcFilterLedgeSpans(rcContext* ctx, const int walkableHeight, const int walkableClimb,
85 - rcHeightfield& solid)
85 + rcHeightfield& solid)
86 86 {
87 - rcAssert(ctx);
88 -
89 - ctx->startTimer(RC_TIMER_FILTER_BORDER);
90 -
91 - const int w = solid.width;
92 - const int h = solid.height;
93 - const int MAX_HEIGHT = 0xffff;
94 -
95 - // Mark border spans.
96 - for (int y = 0; y < h; ++y)
97 - {
98 - for (int x = 0; x < w; ++x)
99 - {
100 - for (rcSpan* s = solid.spans[x + y*w]; s; s = s->next)
101 - {
102 - // Skip non walkable spans.
103 - if (s->area == RC_NULL_AREA)
104 - continue;
105 -
106 - const int bot = (int)(s->smax);
107 - const int top = s->next ? (int)(s->next->smin) : MAX_HEIGHT;
108 -
109 - // Find neighbours minimum height.
110 - int minh = MAX_HEIGHT;
111 -
112 - // Min and max height of accessible neighbours.
113 - int asmin = s->smax;
114 - int asmax = s->smax;
115 -
116 - for (int dir = 0; dir < 4; ++dir)
117 - {
118 - int dx = x + rcGetDirOffsetX(dir);
119 - int dy = y + rcGetDirOffsetY(dir);
120 - // Skip neighbours which are out of bounds.
121 - if (dx < 0 || dy < 0 || dx >= w || dy >= h)
122 - {
123 - minh = rcMin(minh, -walkableClimb - bot);
124 - continue;
125 - }
126 -
127 - // From minus infinity to the first span.
128 - rcSpan* ns = solid.spans[dx + dy*w];
129 - int nbot = -walkableClimb;
130 - int ntop = ns ? (int)ns->smin : MAX_HEIGHT;
131 - // Skip neightbour if the gap between the spans is too small.
132 - if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)
133 - minh = rcMin(minh, nbot - bot);
134 -
135 - // Rest of the spans.
136 - for (ns = solid.spans[dx + dy*w]; ns; ns = ns->next)
137 - {
138 - nbot = (int)ns->smax;
139 - ntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT;
140 - // Skip neightbour if the gap between the spans is too small.
141 - if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)
142 - {
143 - minh = rcMin(minh, nbot - bot);
144 -
145 - // Find min/max accessible neighbour height.
146 - if (rcAbs(nbot - bot) <= walkableClimb)
147 - {
148 - if (nbot < asmin) asmin = nbot;
149 - if (nbot > asmax) asmax = nbot;
150 - }
151 -
152 - }
153 - }
154 - }
155 -
156 - // The current span is close to a ledge if the drop to any
157 - // neighbour span is less than the walkableClimb.
158 - if (minh < -walkableClimb)
159 - s->area = RC_NULL_AREA;
160 -
161 - // If the difference between all neighbours is too large,
162 - // we are at steep slope, mark the span as ledge.
163 - if ((asmax - asmin) > walkableClimb)
164 - {
165 - s->area = RC_NULL_AREA;
166 - }
167 - }
168 - }
169 - }
170 -
171 - ctx->stopTimer(RC_TIMER_FILTER_BORDER);
172 - }
87 + rcAssert(ctx);
88 +
89 + ctx->startTimer(RC_TIMER_FILTER_BORDER);
90 +
91 + const int w = solid.width;
92 + const int h = solid.height;
93 + const int MAX_HEIGHT = 0xffff;
94 +
95 + // Mark border spans.
96 + for (int y = 0; y < h; ++y)
97 + {
98 + for (int x = 0; x < w; ++x)
99 + {
100 + for (rcSpan* s = solid.spans[x + y*w]; s; s = s->next)
101 + {
102 + // Skip non walkable spans.
103 + if (s->area == RC_NULL_AREA)
104 + continue;
105 +
106 + const int bot = (int)(s->smax);
107 + const int top = s->next ? (int)(s->next->smin) : MAX_HEIGHT;
108 +
109 + // Find neighbours minimum height.
110 + int minh = MAX_HEIGHT;
111 +
112 + // Min and max height of accessible neighbours.
113 + int asmin = s->smax;
114 + int asmax = s->smax;
115 +
116 + for (int dir = 0; dir < 4; ++dir)
117 + {
118 + int dx = x + rcGetDirOffsetX(dir);
119 + int dy = y + rcGetDirOffsetY(dir);
120 + // Skip neighbours which are out of bounds.
121 + if (dx < 0 || dy < 0 || dx >= w || dy >= h)
122 + {
123 + minh = rcMin(minh, -walkableClimb - bot);
124 + continue;
125 + }
126 +
127 + // From minus infinity to the first span.
128 + rcSpan* ns = solid.spans[dx + dy*w];
129 + int nbot = -walkableClimb;
130 + int ntop = ns ? (int)ns->smin : MAX_HEIGHT;
131 + // Skip neightbour if the gap between the spans is too small.
132 + if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)
133 + minh = rcMin(minh, nbot - bot);
134 +
135 + // Rest of the spans.
136 + for (ns = solid.spans[dx + dy*w]; ns; ns = ns->next)
137 + {
138 + nbot = (int)ns->smax;
139 + ntop = ns->next ? (int)ns->next->smin : MAX_HEIGHT;
140 + // Skip neightbour if the gap between the spans is too small.
141 + if (rcMin(top,ntop) - rcMax(bot,nbot) > walkableHeight)
142 + {
143 + minh = rcMin(minh, nbot - bot);
144 +
145 + // Find min/max accessible neighbour height.
146 + if (rcAbs(nbot - bot) <= walkableClimb)
147 + {
148 + if (nbot < asmin) asmin = nbot;
149 + if (nbot > asmax) asmax = nbot;
150 + }
151 +
152 + }
153 + }
154 + }
155 +
156 + // The current span is close to a ledge if the drop to any
157 + // neighbour span is less than the walkableClimb.
158 + if (minh < -walkableClimb)
159 + s->area = RC_NULL_AREA;
160 +
161 + // If the difference between all neighbours is too large,
162 + // we are at steep slope, mark the span as ledge.
163 + if ((asmax - asmin) > walkableClimb)
164 + {
165 + s->area = RC_NULL_AREA;
166 + }
167 + }
168 + }
169 + }
170 +
171 + ctx->stopTimer(RC_TIMER_FILTER_BORDER);
172 + }
173 173
174 174 /// @par
175 175 ///
  @@ -179,29 +179,29 @@
179 179 /// @see rcHeightfield, rcConfig
180 180 void rcFilterWalkableLowHeightSpans(rcContext* ctx, int walkableHeight, rcHeightfield& solid)
181 181 {
182 - rcAssert(ctx);
183 -
184 - ctx->startTimer(RC_TIMER_FILTER_WALKABLE);
185 -
186 - const int w = solid.width;
187 - const int h = solid.height;
188 - const int MAX_HEIGHT = 0xffff;
189 -
190 - // Remove walkable flag from spans which do not have enough
191 - // space above them for the agent to stand there.
192 - for (int y = 0; y < h; ++y)
193 - {
194 - for (int x = 0; x < w; ++x)
195 - {
196 - for (rcSpan* s = solid.spans[x + y*w]; s; s = s->next)
197 - {
198 - const int bot = (int)(s->smax);
199 - const int top = s->next ? (int)(s->next->smin) : MAX_HEIGHT;
200 - if ((top - bot) <= walkableHeight)
201 - s->area = RC_NULL_AREA;
202 - }
203 - }
204 - }
205 -
206 - ctx->stopTimer(RC_TIMER_FILTER_WALKABLE);
182 + rcAssert(ctx);
183 +
184 + ctx->startTimer(RC_TIMER_FILTER_WALKABLE);
185 +
186 + const int w = solid.width;
187 + const int h = solid.height;
188 + const int MAX_HEIGHT = 0xffff;
189 +
190 + // Remove walkable flag from spans which do not have enough
191 + // space above them for the agent to stand there.
192 + for (int y = 0; y < h; ++y)
193 + {
194 + for (int x = 0; x < w; ++x)
195 + {
196 + for (rcSpan* s = solid.spans[x + y*w]; s; s = s->next)
197 + {
198 + const int bot = (int)(s->smax);
199 + const int top = s->next ? (int)(s->next->smin) : MAX_HEIGHT;
200 + if ((top - bot) <= walkableHeight)
201 + s->area = RC_NULL_AREA;
202 + }
203 + }
204 + }
205 +
206 + ctx->stopTimer(RC_TIMER_FILTER_WALKABLE);
207 207 }