Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit 79f570e

Browse files
committed
Merge pull request #29 from jgkamat/fix-draw
Fix segfault on draw outside of window bounds
2 parents 0db7a8a + 30e7142 commit 79f570e

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# RoboCup base editorconfig
2+
3+
# Editorconfig files are recursive, so if you want to add specifc rules for
4+
# your subdirectory, make a file like this in that directory.
5+
6+
# Lots of configuration is supported, like max line length, and charset.
7+
8+
# for more information look at http://editorconfig.org/. There are
9+
# plugins available for almost every text editor!
10+
11+
# For an easy install of the sublime editorconfig package, go to:
12+
# PackageControl -> Install Package -> EditorConfig
13+
14+
root = false
15+
16+
# Unix-style newlines with a newline ending every file
17+
[*]
18+
end_of_line = lf
19+
insert_final_newline = true
20+
trim_trailing_whitespace = true
21+
22+
# Use 4 spaces for most files
23+
indent_style = space
24+
indent_size = 4
25+
26+
27+
# Use 2 spaces for travis files
28+
[{package.json,*.yml}]
29+
indent_style = space
30+
indent_size = 2
31+
32+
# Makefiles are required to use tabs
33+
[{makefile, Makefile}]
34+
indent_style = tab
35+
indent_size = 4

src/rrt-viewer/RRTWidget.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void RRTWidget::paintEvent(QPaintEvent *p) {
194194
controlLength = 0.5*min( (waypoint - prevWaypoint).norm(), (nextWaypoint - waypoint).norm() );
195195
controlDir = ((prevWaypoint - waypoint).normalized() - (nextWaypoint - waypoint).normalized()).normalized();
196196
}
197-
197+
198198

199199
Vector2f controlDiff = controlDir * controlLength;
200200

@@ -344,7 +344,10 @@ void RRTWidget::mouseMoveEvent(QMouseEvent *event) {
344344
_goalVel = (point - _biRRT->goalState()) / VelocityDrawingMultiplier;
345345
} else if (_editingObstacles) {
346346
Vector2i gridLoc = _stateSpace->obstacleGrid().gridSquareForLocation(point);
347-
_stateSpace->obstacleGrid().obstacleAt(gridLoc) = !_erasingObstacles;
347+
if (gridLoc[1] >= 0 && gridLoc[1] < _stateSpace->obstacleGrid().discretizedHeight()
348+
&& gridLoc[0] >= 0 && gridLoc[0] < _stateSpace->obstacleGrid().discretizedWidth()) {
349+
_stateSpace->obstacleGrid().obstacleAt(gridLoc) = !_erasingObstacles;
350+
}
348351
}
349352

350353
if (_draggingItem != DraggingNone || _editingObstacles) update();

0 commit comments

Comments
 (0)