[v0.0.1.2] consider the -1 area of triangles

This commit is contained in:
sup39 2022-07-20 04:29:28 +09:00
parent 16b64d7945
commit 2ae48aafda
4 changed files with 26 additions and 9 deletions

View file

@ -1,4 +1,10 @@
# CHANGELOG
## \[v0.0.1.2] consider the -1 area of triangles (2022/07/20)
- WFC
- consider the -1 area of triangles to improve the precision of WFC plot
- SMSDolphin
- add `*args` and `**kwargs` to `hook()`
- use sup-dolphin-memory-lib >= 0.1.2 to solve pid problem
## \[v0.0.1.1] improve performance by using PolyCollection (2022/07/19)
- WFC
- improve process speed of `make_geo_plot()` by using PolyCollection

View file

@ -1,6 +1,6 @@
[metadata]
name = supSMSTAS
version = 0.0.1.1
version = 0.0.1.2
author = sup39
author_email = sms@sup39.dev
description = A tool to support Super Mario Sunshine Tool Assisted Speedrun/Superplay
@ -23,7 +23,7 @@ packages = find_namespace:
include_package_data = True
python_requires = >=3.8
install_requires =
sup-dolphin-memory-lib >= 0.1.1
sup-dolphin-memory-lib >= 0.1.2
matplotlib >= 3.5
PyQt5 >= 5.15

View file

@ -69,9 +69,9 @@ class SMSDolphin(Dolphin):
def __init__(self):
super().__init__()
self.hooked = False
def hook(self):
def hook(self, *args, **kwargs):
self.hooked = False
if Dolphin.hook(self) is None:
if super().hook(*args, **kwargs) is None:
return 'SMS is not running'
# found pid -> check game
verID = self.memory.buf[:8].tobytes()

View file

@ -30,14 +30,23 @@ makeTriPrism = lambda tri0, tri1: Polyhedron([
(3, 4), (4, 5), (5, 3),
])
def extendTriangle(tri, axis):
ans = np.array(tri, 'd')
tri = tri[:, axis]
for i in [-1, 0, 1]:
l1, l2 = tri[i]-tri[i+1], tri[i]-tri[i-1]
ans[i, axis] += (l1+l2)/np.abs(np.cross(l1, l2).item())
return ans
def makeGround(tri, hG=0):
vertsLow = tri.verts-(0,108,0)
vertsE = extendTriangle(tri.verts, [0, 2])
vertsLow = vertsE-(0,108,0)
ySlice = tri.minY-30
v = array(vertsLow)
vertsLow[:,1] = np.clip(vertsLow[:,1], a_min=ySlice, a_max=None)
verts = [
*vertsLow,
*(tri.verts+(0,hG,0)),
*(vertsE+(0,hG,0)),
]
edges = [
# top face
@ -70,12 +79,14 @@ def makeGround(tri, hG=0):
poly = Polyhedron(verts, edges)
return poly
def makeRoof(tri, hR=82):
poly = makeTriPrism(tri.verts-(0,hR,0), tri.verts-(0,160,0))
verts = extendTriangle(tri.verts, [0, 2])
poly = makeTriPrism(verts-(0,hR,0), verts-(0,160,0))
return poly
def makeWall(tri, rW=50, dy=30):
verts = tri.verts - (0, dy, 0)
n = tri.n
off = (np.abs(rW/n[0]),0,0) if np.abs(n[0])>0.707 else (0,0,np.abs(rW/n[2]))
isXWall = np.abs(n[0])>0.707
verts = extendTriangle(tri.verts, [2 if isXWall else 0, 1]) - (0, dy, 0)
off = (np.abs(rW/n[0]),0,0) if isXWall else (0,0,np.abs(rW/n[2]))
poly = makeTriPrism(verts-off, verts+off)
return poly