kopia lustrzana https://github.com/backface/turtlestitch
cleaned up raycasting
rodzic
9fcaf64300
commit
84757ba6c2
|
@ -18,6 +18,9 @@
|
||||||
* Spanish, thanks, Joan!
|
* Spanish, thanks, Joan!
|
||||||
* Catalan, thanks, Joan!
|
* Catalan, thanks, Joan!
|
||||||
|
|
||||||
|
### 2020-12-04
|
||||||
|
* threads: refactored raycasting
|
||||||
|
|
||||||
### 2020-12-03
|
### 2020-12-03
|
||||||
* threads: raycasting edge detection, under construction
|
* threads: raycasting edge detection, under construction
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<script src="src/symbols.js?version=2020-10-07"></script>
|
<script src="src/symbols.js?version=2020-10-07"></script>
|
||||||
<script src="src/widgets.js?version=2020-10-06"></script>
|
<script src="src/widgets.js?version=2020-10-06"></script>
|
||||||
<script src="src/blocks.js?version=2020-12-02"></script>
|
<script src="src/blocks.js?version=2020-12-02"></script>
|
||||||
<script src="src/threads.js?version=2020-12-03"></script>
|
<script src="src/threads.js?version=2020-12-04"></script>
|
||||||
<script src="src/objects.js?version=2020-12-03"></script>
|
<script src="src/objects.js?version=2020-12-03"></script>
|
||||||
<script src="src/gui.js?version=2020-12-01"></script>
|
<script src="src/gui.js?version=2020-12-01"></script>
|
||||||
<script src="src/paint.js?version=2020-05-17"></script>
|
<script src="src/paint.js?version=2020-05-17"></script>
|
||||||
|
|
|
@ -59,10 +59,9 @@ degrees, detect, nop, radians, ReporterSlotMorph, CSlotMorph, RingMorph, Sound,
|
||||||
IDE_Morph, ArgLabelMorph, localize, XML_Element, hex_sha512, TableDialogMorph,
|
IDE_Morph, ArgLabelMorph, localize, XML_Element, hex_sha512, TableDialogMorph,
|
||||||
StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, Map,
|
StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, Map,
|
||||||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, BLACK,
|
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, BLACK,
|
||||||
TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume,
|
TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume*/
|
||||||
normalizeCanvas*/
|
|
||||||
|
|
||||||
modules.threads = '2020-December-03';
|
modules.threads = '2020-December-04';
|
||||||
|
|
||||||
var ThreadManager;
|
var ThreadManager;
|
||||||
var Process;
|
var Process;
|
||||||
|
@ -4812,7 +4811,7 @@ Process.prototype.reportDistanceFacing = function (name) {
|
||||||
hSect, vSect,
|
hSect, vSect,
|
||||||
point, hit,
|
point, hit,
|
||||||
temp,
|
temp,
|
||||||
canvas, width, imageData;
|
width, imageData;
|
||||||
|
|
||||||
hSect = (yLevel) => {
|
hSect = (yLevel) => {
|
||||||
var theta = radians(dir);
|
var theta = radians(dir);
|
||||||
|
@ -4907,33 +4906,13 @@ Process.prototype.reportDistanceFacing = function (name) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// convert intersections to local bitmap coordinates of the target
|
// convert intersections to local bitmap coordinates of the target
|
||||||
/*
|
|
||||||
intersections = intersections.map(point =>
|
intersections = intersections.map(point =>
|
||||||
point.subtract(targetBounds.origin).floor()
|
point.subtract(targetBounds.origin).floorDivideBy(stage.scale)
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
intersections = intersections.map(point =>
|
|
||||||
point.subtract(targetBounds.origin).floorDivideBy(stage.scale) // +++
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// get image data
|
// get image data
|
||||||
/*
|
width = Math.floor(targetBounds.width() / stage.scale);
|
||||||
canvas = thatObj.getImage();
|
imageData = thatObj.getImageData();
|
||||||
if (canvas.isRetinaEnabled) { // for the "turtle" costume
|
|
||||||
canvas = normalizeCanvas(canvas, true); // copy it
|
|
||||||
}
|
|
||||||
width = canvas.width;
|
|
||||||
imageData = canvas.getContext('2d').getImageData(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
width,
|
|
||||||
canvas.height
|
|
||||||
).data;
|
|
||||||
*/
|
|
||||||
|
|
||||||
width = Math.floor(targetBounds.width() / stage.scale); // +++
|
|
||||||
imageData = thatObj.getImageData(); // +++
|
|
||||||
|
|
||||||
// scan the ray along the coordinates of a Bresenham line
|
// scan the ray along the coordinates of a Bresenham line
|
||||||
// for the first opaque pixel
|
// for the first opaque pixel
|
||||||
|
@ -4957,7 +4936,7 @@ Process.prototype.reportDistanceFacing = function (name) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (testFunc(x0, y0)) {
|
if (testFunc(x0, y0)) {
|
||||||
return new Point(x0 * stage.scale, y0 * stage.scale); // +++
|
return new Point(x0 * stage.scale, y0 * stage.scale);
|
||||||
}
|
}
|
||||||
if (x0 === x1 && y0 === y1) {
|
if (x0 === x1 && y0 === y1) {
|
||||||
return -1; // not found
|
return -1; // not found
|
||||||
|
|
Ładowanie…
Reference in New Issue