kopia lustrzana https://github.com/backface/turtlestitch
integrated raycasting into "relation TO object" primitive
rodzic
84757ba6c2
commit
12629d64ec
|
@ -3,6 +3,7 @@
|
|||
## in development:
|
||||
|
||||
* **New Features:**
|
||||
* raycasting: new "ray length" option in the "relation TO object" primitive
|
||||
* hyperdyadic MIN and MAX primitives reachable via "relabel"
|
||||
* hyperdyadic less / great than or equals primitives reachable via "relabel"
|
||||
* new SIGN function in arithmetic dropdown
|
||||
|
@ -20,6 +21,7 @@
|
|||
|
||||
### 2020-12-04
|
||||
* threads: refactored raycasting
|
||||
* integrated raycasting into "relation TO object" primitive
|
||||
|
||||
### 2020-12-03
|
||||
* threads: raycasting edge detection, under construction
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
<script src="src/morphic.js?version=2020-12-02"></script>
|
||||
<script src="src/symbols.js?version=2020-10-07"></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-04"></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-04"></script>
|
||||
<script src="src/gui.js?version=2020-12-01"></script>
|
||||
<script src="src/paint.js?version=2020-05-17"></script>
|
||||
<script src="src/lists.js?version=2020-12-01"></script>
|
||||
|
|
|
@ -158,7 +158,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2020-December-02';
|
||||
modules.blocks = '2020-December-04';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -473,7 +473,8 @@ SyntaxElementMorph.prototype.labelParts = {
|
|||
tags: 'read-only static',
|
||||
menu: {
|
||||
'distance' : ['distance'],
|
||||
'direction' : ['direction']
|
||||
'direction' : ['direction'],
|
||||
'ray length' : ['ray length']
|
||||
}
|
||||
},
|
||||
'%loc': {
|
||||
|
|
|
@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
|
|||
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
||||
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
||||
|
||||
modules.objects = '2020-December-03';
|
||||
modules.objects = '2020-December-04';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -979,13 +979,6 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
spec: '%rel to %dst',
|
||||
defaults: [['distance'], ['mouse-pointer']]
|
||||
},
|
||||
reportDistanceFacing: { // experimental, under construction
|
||||
only: SpriteMorph,
|
||||
type: 'reporter',
|
||||
category: 'sensing',
|
||||
spec: 'distance facing %cln',
|
||||
defaults: [['myself']]
|
||||
},
|
||||
doResetTimer: {
|
||||
type: 'command',
|
||||
category: 'sensing',
|
||||
|
@ -2547,8 +2540,6 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(block('reportThreadCount'));
|
||||
blocks.push(block('reportStackSize'));
|
||||
blocks.push(block('reportFrameCount'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('reportDistanceFacing'));
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
|
|
|
@ -4748,6 +4748,9 @@ Process.prototype.reportRelationTo = function (relation, name) {
|
|||
if (rel === 'distance') {
|
||||
return this.reportDistanceTo(name);
|
||||
}
|
||||
if (rel === 'ray length') {
|
||||
return this.reportRayLengthTo(name);
|
||||
}
|
||||
if (rel === 'direction') {
|
||||
return this.reportDirectionTo(name);
|
||||
}
|
||||
|
@ -4790,15 +4793,10 @@ Process.prototype.reportDistanceTo = function (name) {
|
|||
return 0;
|
||||
};
|
||||
|
||||
Process.prototype.reportDistanceFacing = function (name) {
|
||||
// raycasting edge detection, highly experimental - under construction
|
||||
|
||||
if (this.enableHyperOps) {
|
||||
if (name instanceof List) {
|
||||
return name.map(each => this.reportDistanceFacing(each));
|
||||
}
|
||||
}
|
||||
|
||||
Process.prototype.reportRayLengthTo = function (name) {
|
||||
// raycasting edge detection - answer the distance between the asking
|
||||
// sprite's rotation center to the target sprite's outer edge (the first
|
||||
// opaque pixel) in the asking sprite's current direction
|
||||
var thisObj = this.blockReceiver(),
|
||||
thatObj,
|
||||
stage,
|
||||
|
@ -4856,7 +4854,7 @@ Process.prototype.reportDistanceFacing = function (name) {
|
|||
point = rc;
|
||||
stage = thisObj.parentThatIsA(StageMorph);
|
||||
thatObj = this.getOtherObject(name, thisObj, stage);
|
||||
if (!thatObj) {return -1; }
|
||||
if (!(thatObj instanceof SpriteMorph)) {return -1; }
|
||||
|
||||
// determine intersections with the target's bounding box
|
||||
dir = thisObj.heading;
|
||||
|
|
Ładowanie…
Reference in New Issue