Skip to content

Commit

Permalink
Merge branch 'release/0.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
caewok committed Jul 20, 2021
2 parents 2e4e8a9 + cb1f506 commit 3f3e01d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.2.4
Minor update with additional checks on presence of elevation increment flag. Additional logging.

# 0.2.3
Fix #3. When a grid is present, snap the projected destination point to the center of the grid. This keeps the distances consistent for different cardinalities. Rounding still occurs with grid measurements such that adjacent squares may have the same measured 3-D distance despite appearing to be closer/further from the origin point.

Expand Down
14 changes: 11 additions & 3 deletions scripts/segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { MODULE_ID, log } from "./module.js";
* - ending elevation of the segment
*/
export function elevationRulerAddProperties(wrapped, ...args) {
log(`elevationRulerAddProperties: this`, this);

if(this.segment_num < 0) {
console.error(`${MODULE_ID}|libRulerAddProperties: this.segment_num is less than zero`, this);
return;
Expand All @@ -30,12 +32,16 @@ UX goals:
would go from 5 to 55.
*/

const elevation_increments = duplicate(this.ruler.getFlag(MODULE_ID, "elevation_increments"));
let elevation_increments = duplicate(this.ruler.getFlag(MODULE_ID, "elevation_increments"));
if(!elevation_increments || elevation_increments.length < 1) {
elevation_increments = [0];
}

log(`${elevation_increments.length} elevation increments for ruler flag.`)

const destination_elevation_increment = this.ruler.getFlag(MODULE_ID, "destination_elevation_increment");
const destination_elevation_increment = this.ruler.getFlag(MODULE_ID, "destination_elevation_increment") || 0;
elevation_increments.push(destination_elevation_increment);
log(`${this.ruler.getFlag(MODULE_ID, "elevation_increments").length} elevation increments for ruler flag.`);
log(`${this.ruler.getFlag(MODULE_ID, "elevation_increments").length} destination elevation increments for ruler flag.`);


elevation_increments.shift(); //first increment is 0 for the origin waypoint
Expand All @@ -46,6 +52,7 @@ UX goals:
// starting elevation equals the token elevation
// if no token, use elevation at the point.
starting_elevation = ElevationAtPoint(this.ray.A, this.ruler._getMovementToken(), 0) // 0 starting elevation otherwise
log(`Starting elevation using origin ${this.ray.A.x}, ${this.ray.A.y}`, this.ruler._getMovementToken());

} else {
// starting elevation is the prior segment end elevation
Expand All @@ -57,6 +64,7 @@ UX goals:
const incremental_elevation = toGridDistance(elevation_increments[this.segment_num]);
const current_point_elevation = ElevationAtPoint(this.ray.B, undefined, starting_elevation); // no starting token; assume we are at the elevation from the last segment
const ending_elevation = current_point_elevation + incremental_elevation;
log(`Current elevation using point ${this.ray.B.x}, ${this.ray.B.y}`);

log(`elevationRulerAddProperties segment ${this.segment_num}: ${starting_elevation}[start]; ${incremental_elevation}[incremental]; ${current_point_elevation}[current point]`);

Expand Down

0 comments on commit 3f3e01d

Please sign in to comment.