Use depth-scaled sphere silhouettes for native rapid-count view checks
This commit is contained in:
@@ -3,6 +3,13 @@ param([Parameter(Mandatory)][string]$ApkPath,[Parameter(Mandatory)][string]$Evid
|
||||
# This suite never pushes a save or injects completed stages. Every checkpoint is read from the APK.
|
||||
function Board($State,[int]$Stage) { return @($State.puzzleStates | Where-Object stageId -eq $Stage)[0] }
|
||||
function Counts($Board) { return (@($Board.groups | ForEach-Object {$_.ballIds.Count} | Sort-Object) -join ',') }
|
||||
function BallRadiusPixels($CurrentBoard,$Ball) {
|
||||
$camera=$CurrentBoard.camera
|
||||
$rotation=[Numerics.Quaternion]::new($camera.rotation.x,$camera.rotation.y,$camera.rotation.z,$camera.rotation.w)
|
||||
$origin=[Numerics.Vector3]::new($camera.target.x,($camera.target.y+.65),$camera.target.z)+[Numerics.Vector3]::Transform([Numerics.Vector3]::new(0,0,-$camera.distance),$rotation)
|
||||
$local=[Numerics.Vector3]::Transform([Numerics.Vector3]::new($Ball.position.x,$Ball.position.y,$Ball.position.z)-$origin,[Numerics.Quaternion]::Inverse($rotation))
|
||||
return 540*.55/([Math]::Tan(31*[Math]::PI/180)*$local.Z)
|
||||
}
|
||||
function Orbit([string]$Name,$CurrentBoard) {
|
||||
if(!$CurrentBoard){$saved=Save "$Name-view";$CurrentBoard=if($saved.puzzleStates.Count){$saved.puzzleStates[-1]}else{$saved.latestFreePlay}}
|
||||
$points=@($CurrentBoard.balls|ForEach-Object{,(BallPoint $CurrentBoard $_.id)})
|
||||
@@ -160,7 +167,11 @@ try {
|
||||
$actual=Board (Save "twenty-before-rapid-view-$view") 20
|
||||
$points=@($actual.balls|ForEach-Object{,(BallPoint $actual $_.id)})
|
||||
$visible=@($points|Where-Object{!(WorldSafe $_)}).Count-eq0
|
||||
for($a=0;$a-lt$points.Count;$a++){for($b=$a+1;$b-lt$points.Count;$b++){if([Math]::Pow($points[$a][0]-$points[$b][0],2)+[Math]::Pow($points[$a][1]-$points[$b][1],2)-lt10000){$visible=$false}}}
|
||||
$radii=@($actual.balls|ForEach-Object{BallRadiusPixels $actual $_})
|
||||
for($a=0;$a-lt$points.Count;$a++){for($b=$a+1;$b-lt$points.Count;$b++){
|
||||
$centreDistanceSquared=[Math]::Pow($points[$a][0]-$points[$b][0],2)+[Math]::Pow($points[$a][1]-$points[$b][1],2)
|
||||
if($centreDistanceSquared-lt[Math]::Pow([Math]::Max($radii[$a],$radii[$b])+8,2)){$visible=$false}
|
||||
}}
|
||||
if($visible){break};Orbit "twenty-rapid-safe-view-$view" $actual
|
||||
}
|
||||
Check 'twenty-all-ten-safe-separated-projections' $visible ($points|ConvertTo-Json -Compress)
|
||||
|
||||
@@ -34,7 +34,7 @@ function BallPoint($Board,[string]$Id) {
|
||||
$scale=($height/2)/([Math]::Tan(31*[Math]::PI/180)*$local.Z)
|
||||
return @([int][Math]::Round(($width/2)+$local.X*$scale),[int][Math]::Round(($height/2)-$local.Y*$scale))
|
||||
}
|
||||
function WorldSafe($Point) { return $Point[0]-ge530-and$Point[0]-le1900-and$Point[1]-ge280-and$Point[1]-le750 }
|
||||
function WorldSafe($Point) { return $Point[0]-ge530-and$Point[0]-le1850-and$Point[1]-ge280-and$Point[1]-le750 }
|
||||
function TapBall([string]$Name,$Board,[string]$Id) {
|
||||
$point=BallPoint $Board $Id
|
||||
if(!(WorldSafe $point)){throw "Refused unsafe native ball tap $Id at $($point-join',')"}
|
||||
|
||||
Reference in New Issue
Block a user