[v0.0.1] init
This commit is contained in:
commit
5e83e9b098
14 changed files with 1617 additions and 0 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
__pycache__/
|
||||||
|
*.egg-info/
|
||||||
|
/dist/
|
||||||
|
/build/
|
||||||
|
/.venv*/
|
14
CHANGELOG.md
Normal file
14
CHANGELOG.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# CHANGELOG
|
||||||
|
## \[v0.0.1] init
|
||||||
|
- WFC
|
||||||
|
- plot WFC hitbox (x-z plot and x/z-y plot) with matplotlib toolbar
|
||||||
|
- options:
|
||||||
|
- track Mario
|
||||||
|
- show Mario as red point
|
||||||
|
- airborne or grounded
|
||||||
|
- on Yoshi
|
||||||
|
- invert X/Z
|
||||||
|
- angle dial for x/z-y plot
|
||||||
|
- Runtime
|
||||||
|
- advance by QF
|
||||||
|
- show Hitbox
|
10
COPYING
Normal file
10
COPYING
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
This software is provided under:
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
Being under the terms of the GNU General Public License version 3 only,
|
||||||
|
according with:
|
||||||
|
|
||||||
|
LICENSES/GPL-3.0
|
||||||
|
|
||||||
|
All contributions to this software are subject to this COPYING file.
|
683
LICENSES/GPL-3.0
Normal file
683
LICENSES/GPL-3.0
Normal file
|
@ -0,0 +1,683 @@
|
||||||
|
Valid-License-Identifier: GPL-3.0-only
|
||||||
|
SPDX-URL: https://spdx.org/licenses/GPL-3.0-only.html
|
||||||
|
Usage-Guide:
|
||||||
|
To use this license in source code, put the following SPDX
|
||||||
|
tag/value pairs into a comment according to the placement
|
||||||
|
guidelines in the licensing rules documentation:
|
||||||
|
SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
License-Text:
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
include src/supSMSTAS/codes/*.bin
|
51
README.md
Normal file
51
README.md
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# supSMSTAS
|
||||||
|
A tool to **sup**port **S**uper **M**ario **S**unshine **T**ool **A**ssisted **S**peedrun/Superplay.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
```
|
||||||
|
pip install supSMSTAS==0.0.1
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
```
|
||||||
|
python -m supSMSTAS
|
||||||
|
```
|
||||||
|
|
||||||
|
## Required Gecko code
|
||||||
|
You need to add and activate the following Gecko code in Dolphin:
|
||||||
|
```
|
||||||
|
C20ECDE0 00000004
|
||||||
|
3C60817F 80631000
|
||||||
|
7C631B79 38600258
|
||||||
|
41820008 38600096
|
||||||
|
60000000 00000000
|
||||||
|
C20ED284 00000005
|
||||||
|
4E800021 3D60817F
|
||||||
|
816B1010 55608380
|
||||||
|
2800817E 4082000C
|
||||||
|
7D6803A6 4E800021
|
||||||
|
60000000 00000000
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to disable those codes that
|
||||||
|
alter QF sync (advance by QF) or render triangle/hitbox
|
||||||
|
if you are using any of them.
|
||||||
|
|
||||||
|
If the checkboxes in the Runtime tab don't work,
|
||||||
|
try to disable all Gecko codes in Dolphin (except the *required Gecko code*).
|
||||||
|
|
||||||
|
## Execute the source code directly
|
||||||
|
To install dependencies, the easiest way is to run the following command
|
||||||
|
in the root directory of the package:
|
||||||
|
```
|
||||||
|
pip install .
|
||||||
|
```
|
||||||
|
|
||||||
|
Due to some module/script problems,
|
||||||
|
in order to start the program,
|
||||||
|
instead of using `python path/to/supSMSTAS/__main__.py` (as script),
|
||||||
|
make sure to use `python -m path.to.supSMSTAS` (as module) outside the `src/supSMSTAS/` directory.
|
||||||
|
For example, if you are in `src/` directory, you can run the following command:
|
||||||
|
```
|
||||||
|
python -m supSMSTAS
|
||||||
|
```
|
3
pyproject.toml
Normal file
3
pyproject.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=42"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
34
setup.cfg
Normal file
34
setup.cfg
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[metadata]
|
||||||
|
name = supSMSTAS
|
||||||
|
version = 0.0.1
|
||||||
|
author = sup39
|
||||||
|
author_email = sms@sup39.dev
|
||||||
|
description = A tool to support Super Mario Sunshine Tool Assisted Speedrun/Superplay
|
||||||
|
long_description = file: README.md
|
||||||
|
long_description_content_type = text/markdown
|
||||||
|
license_files = COPYING LICENSES/*
|
||||||
|
url = https://github.com/sup39/supSMSTAS
|
||||||
|
project_urls =
|
||||||
|
Bug Tracker = https://github.com/sup39/supSMSTAS/issues
|
||||||
|
classifiers =
|
||||||
|
Programming Language :: Python :: 3
|
||||||
|
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
||||||
|
Operating System :: OS Independent
|
||||||
|
|
||||||
|
[options]
|
||||||
|
package_dir =
|
||||||
|
= src
|
||||||
|
packages = find_namespace:
|
||||||
|
include_package_data = True
|
||||||
|
python_requires = >=3.8
|
||||||
|
install_requires =
|
||||||
|
sup-dolphin-memory-lib ~= 0.1.0
|
||||||
|
matplotlib ~= 3.5
|
||||||
|
PyQt5 ~= 5.15
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
where = src
|
||||||
|
|
||||||
|
[options.entry_points]
|
||||||
|
console_scripts =
|
||||||
|
supSMSTAS = supSMSTAS.__main__:main
|
382
src/supSMSTAS/UI.py
Normal file
382
src/supSMSTAS/UI.py
Normal file
|
@ -0,0 +1,382 @@
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
# Copyright (c) 2022 sup39
|
||||||
|
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
## numpy
|
||||||
|
import numpy as np
|
||||||
|
from numpy import array
|
||||||
|
## matplotlib
|
||||||
|
import matplotlib as mpl
|
||||||
|
mpl.use('Qt5Agg')
|
||||||
|
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT
|
||||||
|
from matplotlib.figure import Figure
|
||||||
|
import matplotlib.patches as patches
|
||||||
|
## PyQt5
|
||||||
|
from PyQt5.QtCore import *
|
||||||
|
from PyQt5.QtWidgets import *
|
||||||
|
## logging
|
||||||
|
import logging
|
||||||
|
## local
|
||||||
|
from .WFC import *
|
||||||
|
|
||||||
|
# add TRACE
|
||||||
|
logging.TRACE = 5
|
||||||
|
logging.addLevelName(logging.TRACE, 'TRACE')
|
||||||
|
def trace(self, message, *args, **kws):
|
||||||
|
if self.isEnabledFor(logging.TRACE):
|
||||||
|
self._log(logging.TRACE, message, args, **kws)
|
||||||
|
logging.Logger.trace = trace
|
||||||
|
# logger
|
||||||
|
logger = logging.getLogger('supSMSTAS')
|
||||||
|
|
||||||
|
# widgets utils
|
||||||
|
def layoutAddItem(ll, w):
|
||||||
|
if w is None: ll.addStretch()
|
||||||
|
elif isinstance(w, QLayout): ll.addLayout(w)
|
||||||
|
else: ll.addWidget(w)
|
||||||
|
def HBox(*children, **kwargs):
|
||||||
|
ll = QHBoxLayout(**kwargs)
|
||||||
|
for w in children: layoutAddItem(ll, w)
|
||||||
|
return ll
|
||||||
|
def VBox(*children, **kwargs):
|
||||||
|
ll = QVBoxLayout(**kwargs)
|
||||||
|
for w in children: layoutAddItem(ll, w)
|
||||||
|
return ll
|
||||||
|
|
||||||
|
class MPLCanvas(FigureCanvasQTAgg):
|
||||||
|
def __init__(self, parent=None, width=5, height=5, dpi=100):
|
||||||
|
fig = self.fig = Figure(figsize=(width, height), dpi=dpi)
|
||||||
|
self.axs = [
|
||||||
|
fig.add_subplot(121),
|
||||||
|
fig.add_subplot(122),
|
||||||
|
]
|
||||||
|
super().__init__(fig)
|
||||||
|
|
||||||
|
# Dolphin for SMS
|
||||||
|
from dolphin.memorylib import Dolphin
|
||||||
|
class SMSDolphin(Dolphin):
|
||||||
|
symbols = { # TODO
|
||||||
|
b'GMSJ01\x00\x00': {
|
||||||
|
'gpMarioOriginal': 0x8040A378,
|
||||||
|
'gpMap': 0x8040A570,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def get_symb_addr(self, name): # override
|
||||||
|
verID = self.memory.buf[:8].tobytes()
|
||||||
|
return SMSDolphin.symbols[verID][name]
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.hooked = False
|
||||||
|
def hook(self):
|
||||||
|
self.hooked = False
|
||||||
|
if Dolphin.hook(self) is None:
|
||||||
|
return 'SMS is not running'
|
||||||
|
# found pid -> check game
|
||||||
|
verID = self.memory.buf[:8].tobytes()
|
||||||
|
if verID[:3] != b'GMS':
|
||||||
|
return 'Current game is not SMS'
|
||||||
|
if verID not in SMSDolphin.symbols:
|
||||||
|
return 'Only NTSJ-1.0 is supported in this version'
|
||||||
|
self.hooked = True
|
||||||
|
|
||||||
|
def checkList2list(self, ptr):
|
||||||
|
ans = []
|
||||||
|
while ptr:
|
||||||
|
ptr, data = self.read_struct(ptr+4, '>II')
|
||||||
|
ans.append(Surface(
|
||||||
|
*self.read_struct(data, '>HHBB'),
|
||||||
|
array(self.read_struct(data+0x10, '>9f'), 'f').reshape(3, 3),
|
||||||
|
n=array(self.read_struct(data+0x34, '>3f'), 'f'),
|
||||||
|
c=self.read_float(data+0x40),
|
||||||
|
))
|
||||||
|
return ans
|
||||||
|
|
||||||
|
# widgets
|
||||||
|
class WFCWidget(QWidget):
|
||||||
|
def __init__(self, dolphin, parent=None):
|
||||||
|
super().__init__(parent=parent)
|
||||||
|
self.d = dolphin
|
||||||
|
self._init_state()
|
||||||
|
self._init_layout()
|
||||||
|
def activate(self, val):
|
||||||
|
# stop timer if deactivate
|
||||||
|
self.setFPS(self.fps) if val else self.timer.stop()
|
||||||
|
def _init_state(self):
|
||||||
|
self.trackMario = Qt.Checked
|
||||||
|
self.showMario = Qt.Checked
|
||||||
|
self.airborne = Qt.Checked
|
||||||
|
self.yoshi = 0
|
||||||
|
self.fps = 4
|
||||||
|
self.updating = False
|
||||||
|
self.invertX = 0
|
||||||
|
self.invertZ = 0
|
||||||
|
self.xzAngle = 0
|
||||||
|
def _init_layout(self):
|
||||||
|
# timer
|
||||||
|
timer = self.timer = QTimer()
|
||||||
|
timer.timeout.connect(self.updatePlot)
|
||||||
|
# mcv
|
||||||
|
self.mcv = mcv = MPLCanvas(self, width=11, height=5, dpi=100)
|
||||||
|
self.updatePlot()
|
||||||
|
# toolbar
|
||||||
|
toolbar = NavigationToolbar2QT(mcv, self)
|
||||||
|
# buttons
|
||||||
|
llbtn = QHBoxLayout()
|
||||||
|
btn = QPushButton()
|
||||||
|
btn.setText('Update plot')
|
||||||
|
btn.clicked.connect(self.updatePlot)
|
||||||
|
llbtn.addWidget(btn)
|
||||||
|
# update
|
||||||
|
lbFPS = QLabel()
|
||||||
|
lbFPS.setText('fps')
|
||||||
|
sbFPS = QSpinBox()
|
||||||
|
sbFPS.setRange(0, 60)
|
||||||
|
sbFPS.setValue(self.fps)
|
||||||
|
#cbFPS.setText('fps')
|
||||||
|
sbFPS.valueChanged.connect(lambda: self.setFPS(sbFPS.value()))
|
||||||
|
self.setFPS(self.fps)
|
||||||
|
## add widget
|
||||||
|
llbtn.addWidget(lbFPS)
|
||||||
|
llbtn.addWidget(sbFPS)
|
||||||
|
for text, attr in [
|
||||||
|
('Track Mario', 'trackMario'),
|
||||||
|
('Show Mario', 'showMario'),
|
||||||
|
('Airborne', 'airborne'),
|
||||||
|
('Yoshi', 'yoshi'),
|
||||||
|
('invert X', 'invertX'),
|
||||||
|
('invert Z', 'invertZ'),
|
||||||
|
]:
|
||||||
|
cb = QCheckBox()
|
||||||
|
cb.setText(text)
|
||||||
|
cb.setCheckState(getattr(self, attr))
|
||||||
|
cb.clicked.connect((lambda attr, cb: lambda: setattr(self, attr, cb.checkState()))(attr, cb))
|
||||||
|
llbtn.addWidget(cb)
|
||||||
|
llbtn.addStretch()
|
||||||
|
# angle
|
||||||
|
lbXZAngle = QLabel()
|
||||||
|
lbXZAngle.setText('Angle')
|
||||||
|
dlXZAngle = QDial()
|
||||||
|
dlXZAngle.setWrapping(True)
|
||||||
|
#dlXZAngle.setNotchesVisible(True) # TODO
|
||||||
|
dlXZAngle.valueChanged.connect(lambda: self.setXZAngle(dlXZAngle.value()))
|
||||||
|
## angle button
|
||||||
|
llXZAngleBtns = QVBoxLayout()
|
||||||
|
for text, val in [
|
||||||
|
('X+', 75),
|
||||||
|
('X-', 25),
|
||||||
|
('Z+', 50),
|
||||||
|
('Z-', 0),
|
||||||
|
]:
|
||||||
|
btn = QPushButton()
|
||||||
|
btn.setText(text)
|
||||||
|
btn.clicked.connect((lambda val: lambda: dlXZAngle.setValue(val))(val))
|
||||||
|
llXZAngleBtns.addWidget(btn)
|
||||||
|
# footer
|
||||||
|
llFooter = HBox(
|
||||||
|
# buttons
|
||||||
|
VBox(
|
||||||
|
llbtn,
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
## angle
|
||||||
|
lbXZAngle,
|
||||||
|
dlXZAngle,
|
||||||
|
llXZAngleBtns,
|
||||||
|
)
|
||||||
|
# layout
|
||||||
|
self.setLayout(VBox(
|
||||||
|
toolbar,
|
||||||
|
mcv,
|
||||||
|
llFooter,
|
||||||
|
))
|
||||||
|
def toggleTimer(self, toggle):
|
||||||
|
if toggle:
|
||||||
|
self.timer.start()
|
||||||
|
else:
|
||||||
|
self.timer.stop()
|
||||||
|
def setFPS(self, fps):
|
||||||
|
self.fps = fps
|
||||||
|
if fps == 0:
|
||||||
|
self.timer.stop()
|
||||||
|
else:
|
||||||
|
self.timer.setInterval(int(1000/fps))
|
||||||
|
self.timer.start()
|
||||||
|
def setXZAngle(self, val):
|
||||||
|
self.xzAngle = val
|
||||||
|
#self.updatePlot()
|
||||||
|
def updatePlot(self):
|
||||||
|
if self.updating or not self.d.hooked: return
|
||||||
|
self.updating = True
|
||||||
|
try: self._updatePlot()
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
self.updating = False
|
||||||
|
def _updatePlot(self):
|
||||||
|
d = self.d
|
||||||
|
pos = d.read_struct(('gpMarioOriginal', 0x10), '>3f')
|
||||||
|
if pos is None: return
|
||||||
|
pos = array(pos)
|
||||||
|
x, y, z = pos
|
||||||
|
# get collision data (static collision)
|
||||||
|
colInfo = d.read_struct(('gpMap', 0x10, 0), '>ffI4x4xI')
|
||||||
|
if colInfo is None: return
|
||||||
|
xLimit, zLimit, xBlockCount, ptrStCLR = colInfo
|
||||||
|
## TBGCheckListRoot[zBlockCount][xBlockCount]
|
||||||
|
colOff = int((z+zLimit)//1024*xBlockCount + (x+xLimit)//1024)*36
|
||||||
|
## root->ground(12*2).next(4)
|
||||||
|
|
||||||
|
# mario
|
||||||
|
yoshi = self.yoshi
|
||||||
|
airborne = self.airborne
|
||||||
|
rW = 80 if yoshi else 50
|
||||||
|
|
||||||
|
t0 = time.time()
|
||||||
|
stGnds, stRoofs, stWalls = [
|
||||||
|
#data1 = [ # TODO dynamic data
|
||||||
|
d.checkList2list(d.read_uint32(ptrStCLR+colOff+4+12*j))
|
||||||
|
for j in range(3)
|
||||||
|
]
|
||||||
|
hitboxs = [
|
||||||
|
# ceiling
|
||||||
|
([
|
||||||
|
#(c, array((0, -1, 0)))
|
||||||
|
(makeRoof(tri, 82 if airborne else 2), array([0, -1, 0]))
|
||||||
|
for tri in stRoofs
|
||||||
|
#for c in makeCol(tri, airborne=airborne, yoshi=yoshi)
|
||||||
|
# if tri.maxY >= yMin
|
||||||
|
##], 1.0, 78.0 if airborne else 158.0, '#f88e', '#800'),
|
||||||
|
## FIXME: draw arrow
|
||||||
|
], 1.0, 0, '#f88e', '#800'),
|
||||||
|
([
|
||||||
|
#(c, array((0, 1, 0)))
|
||||||
|
(makeGround(tri, 0 if airborne else 0), array([0, 1, 0])) # TODO hG=100
|
||||||
|
for tri in stGnds # TODO grounded hitbox
|
||||||
|
#for c in makeCol(tri, airborne=airborne, yoshi=yoshi)
|
||||||
|
# if tri.maxY >= yMin
|
||||||
|
## FIXME: draw arrow
|
||||||
|
], 1.0, 0, '#88fe', '#008'), # TODO
|
||||||
|
*(
|
||||||
|
([
|
||||||
|
#(c, tri.n)
|
||||||
|
(makeWall(tri, w, dy), tri.n)
|
||||||
|
for tri in stWalls
|
||||||
|
#for c in [makeCol(tri, airborne=airborne, yoshi=yoshi)[ii]]
|
||||||
|
# if tri.maxY >= yMin
|
||||||
|
# arrow size scale (0.5 if radius is 25)
|
||||||
|
], 1.0 if airborne or ii == 1 else 0.5, rW, ['#8fcc', '#8f8c'][ii], ['#084', '#080'][ii])
|
||||||
|
#], 1.0 if airborne or ii == 1 else 0.5, rW, '#8f8e', '#080')
|
||||||
|
for ii, (w, dy) in zip((1, 0), [(rW, 30), (rW, 150)] if airborne else [(rW, 60), (rW/2, 30)])
|
||||||
|
),
|
||||||
|
]
|
||||||
|
# xzAngle
|
||||||
|
theta = self.xzAngle/50*np.pi
|
||||||
|
pnXZ = (-np.sin(theta), 0, -np.cos(theta))
|
||||||
|
axesXZ = [2 if abs(pnXZ[0])>abs(pnXZ[2]) else 0, 1]
|
||||||
|
invertX = self.invertX==Qt.Checked
|
||||||
|
invertZ = self.invertZ==Qt.Checked
|
||||||
|
# ax
|
||||||
|
xzAngle = self.xzAngle
|
||||||
|
for ax, (pn, axes) in zip(self.mcv.axs, [
|
||||||
|
((0, 1, 0), [0, 2]),
|
||||||
|
(pnXZ, axesXZ),
|
||||||
|
]):
|
||||||
|
ax.patches.clear()
|
||||||
|
make_geo_plot(ax, hitboxs, pos, pn, axes)
|
||||||
|
if self.showMario:
|
||||||
|
ax.add_patch(patches.Circle(pos[axes], 25, fc='red'))
|
||||||
|
if self.trackMario:
|
||||||
|
offs = [(-1000, 1000), (-1000, 1000), (-1000, 1000)] # TODO
|
||||||
|
for f, i in zip((ax.set_xlim, ax.set_ylim), axes):
|
||||||
|
p = pos[i]
|
||||||
|
d0, d1 = offs[i]
|
||||||
|
if invertX & (i==0) | invertZ & (i==2): # invert
|
||||||
|
d0, d1 = d1, d0
|
||||||
|
f(p+d0, p+d1)
|
||||||
|
ax.grid(True)
|
||||||
|
# apply
|
||||||
|
self.mcv.fig.tight_layout()
|
||||||
|
self.mcv.draw()
|
||||||
|
logger.trace('%.2f'%((time.time()-t0)*1000))
|
||||||
|
|
||||||
|
class RuntimeWidget(QWidget):
|
||||||
|
def __init__(self, dolphin, parent=None):
|
||||||
|
super().__init__(parent=parent)
|
||||||
|
self.d = dolphin
|
||||||
|
self._init_state()
|
||||||
|
self._init_layout()
|
||||||
|
def _init_state(self):
|
||||||
|
pass
|
||||||
|
def _init_layout(self):
|
||||||
|
# QF
|
||||||
|
cbQF = QCheckBox()
|
||||||
|
cbQF.setText('Advance by QF')
|
||||||
|
cbQF.clicked.connect(lambda: self.toggleQFSync(cbQF.checkState()))
|
||||||
|
# hitbox
|
||||||
|
cbHitbox = QCheckBox()
|
||||||
|
cbHitbox.setText('Show hitbox')
|
||||||
|
cbHitbox.clicked.connect(lambda: self.toggleHitbox(cbHitbox.checkState()))
|
||||||
|
# layout
|
||||||
|
self.setLayout(VBox(
|
||||||
|
cbQF,
|
||||||
|
cbHitbox,
|
||||||
|
None,
|
||||||
|
))
|
||||||
|
def toggleQFSync(self, val):
|
||||||
|
self.d.write_uint8(0x817F1000, 1 if val else 0)
|
||||||
|
def toggleHitbox(self, val):
|
||||||
|
ptrAddr = 0x817F1010
|
||||||
|
funcAddr = 0x817E05B8 # TODO
|
||||||
|
baseAddr = 0x817E0000
|
||||||
|
if val: # TODO other scripts
|
||||||
|
baseDir = os.path.dirname(__file__)
|
||||||
|
with open(os.path.join(baseDir, 'codes/showHitbox.bin'), 'rb') as fr:
|
||||||
|
buf = fr.read()
|
||||||
|
self.d.memory.buf[baseAddr-0x80000000:baseAddr-0x80000000+len(buf)] = buf
|
||||||
|
self.d.write_uint32(ptrAddr, funcAddr)
|
||||||
|
else:
|
||||||
|
self.d.write_uint32(ptrAddr, 0)
|
||||||
|
|
||||||
|
class MainWindow(QMainWindow):
|
||||||
|
def __init__(self, dolphin=None, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.setWindowTitle("supSMSTAS")
|
||||||
|
self.dolphin = SMSDolphin() if dolphin is None else dolphin
|
||||||
|
self._init_layout()
|
||||||
|
self.hook()
|
||||||
|
def _init_layout(self):
|
||||||
|
# hook button bar: btHook, lbHook, (spacer)
|
||||||
|
btHook = QPushButton()
|
||||||
|
btHook.setText('Hook')
|
||||||
|
btHook.clicked.connect(self.hook)
|
||||||
|
self.lbHook = lbHook = QLabel()
|
||||||
|
lbHook.setText('')
|
||||||
|
llHook = HBox(
|
||||||
|
btHook,
|
||||||
|
lbHook,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
## tab
|
||||||
|
qtab = self.qtab = QTabWidget(self)
|
||||||
|
self.subwWFC = WFCWidget(dolphin=self.dolphin)
|
||||||
|
self.tidxWFC = qtab.addTab(self.subwWFC, 'WFC')
|
||||||
|
self.subwRuntime = RuntimeWidget(dolphin=self.dolphin)
|
||||||
|
self.tidxRuntime = qtab.addTab(self.subwRuntime, 'Runtime')
|
||||||
|
qtab.currentChanged.connect(lambda: self.onTabChanged(qtab.currentIndex()))
|
||||||
|
# dummy widget to put widgets in the center
|
||||||
|
w = QWidget()
|
||||||
|
w.setLayout(VBox(
|
||||||
|
llHook,
|
||||||
|
qtab,
|
||||||
|
None,
|
||||||
|
))
|
||||||
|
self.setCentralWidget(w)
|
||||||
|
def hook(self):
|
||||||
|
err = self.dolphin.hook()
|
||||||
|
self.lbHook.setText('Hooked' if err is None else err)
|
||||||
|
self.qtab.setEnabled(self.dolphin.hooked)
|
||||||
|
def onTabChanged(self, index):
|
||||||
|
self.subwWFC.activate(index==self.tidxWFC)
|
175
src/supSMSTAS/WFC.py
Normal file
175
src/supSMSTAS/WFC.py
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
# Copyright (c) 2022 sup39
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
from numpy import array
|
||||||
|
from .shape import Polyhedron
|
||||||
|
import matplotlib.patches as patches
|
||||||
|
|
||||||
|
class Surface:
|
||||||
|
def __init__(self, surtype, surpara, trntype, unk7, verts, vidxs=None, n=None, c=None):
|
||||||
|
self.surtype, self.surpara, self.trntype, self.unk7 = \
|
||||||
|
surtype, surpara, trntype, unk7
|
||||||
|
self.vidxs = vidxs
|
||||||
|
self.verts = verts
|
||||||
|
self.minY = verts[:,1].min()
|
||||||
|
self.maxY = verts[:,1].max()
|
||||||
|
self.n = normalize(np.cross(verts[1]-verts[0], verts[2]-verts[1])) if n is None else n
|
||||||
|
self.c = -np.dot(verts[0], self.n) if c is None else c
|
||||||
|
def __repr__(self):
|
||||||
|
return 'minY=%.0f maxY=%.0f n=(%5.2f, %5.2f, %5.2f)'%(
|
||||||
|
self.minY, self.maxY, *self.n,
|
||||||
|
)
|
||||||
|
|
||||||
|
makeTriPrism = lambda tri0, tri1: Polyhedron([
|
||||||
|
*tri0,
|
||||||
|
*tri1,
|
||||||
|
], [
|
||||||
|
(0, 1), (1, 2), (2, 0),
|
||||||
|
(0, 3), (1, 4), (2, 5),
|
||||||
|
(3, 4), (4, 5), (5, 3),
|
||||||
|
])
|
||||||
|
|
||||||
|
def makeGround(tri, hG=0):
|
||||||
|
vertsLow = tri.verts-(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)),
|
||||||
|
]
|
||||||
|
edges = [
|
||||||
|
# top face
|
||||||
|
(3, 4), (4, 5), (5, 3),
|
||||||
|
# vertical edge
|
||||||
|
(0, 3), (1, 4), (2, 5),
|
||||||
|
]
|
||||||
|
r = v[:, 1]-ySlice
|
||||||
|
b = r>0
|
||||||
|
bc = b.sum()
|
||||||
|
if bc in [0, 3]:
|
||||||
|
# bottom face
|
||||||
|
edges += [(0, 1), (1, 2), (2, 0)]
|
||||||
|
else:
|
||||||
|
k0 = np.where(b if bc==1 else ~b)[0][0]
|
||||||
|
k1 = (k0+1)%3
|
||||||
|
k2 = (k0+2)%3
|
||||||
|
v0, r0 = v[k0], r[k0]
|
||||||
|
v1, r1 = v[k1], r[k1]
|
||||||
|
v2, r2 = v[k2], r[k2]
|
||||||
|
verts += [
|
||||||
|
(r1*v0-r0*v1)/(-r0+r1),
|
||||||
|
(r2*v0-r0*v2)/(-r0+r2),
|
||||||
|
]
|
||||||
|
edges += [
|
||||||
|
(k0, 6), (6, k1),
|
||||||
|
(k0, 7), (7, k2),
|
||||||
|
(k1, k2), (6, 7),
|
||||||
|
]
|
||||||
|
poly = Polyhedron(verts, edges)
|
||||||
|
return poly
|
||||||
|
def makeRoof(tri, hR=82):
|
||||||
|
poly = makeTriPrism(tri.verts-(0,hR,0), tri.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]))
|
||||||
|
poly = makeTriPrism(verts-off, verts+off)
|
||||||
|
return poly
|
||||||
|
|
||||||
|
def make_geo_plot(ax, hitboxs, p0, pn, axes):
|
||||||
|
# paras
|
||||||
|
arrowWidthBase = 60
|
||||||
|
arrowWidthMul = 0.2
|
||||||
|
arrowLenMax = 80
|
||||||
|
arrowLenTher = 200
|
||||||
|
arrowLenMul1 = 0.7
|
||||||
|
arrowLenMul2 = 0.35
|
||||||
|
arrowHeadLenMul = 0.3
|
||||||
|
arrowLenMul2off = 0.025
|
||||||
|
arrowCountMax = 20
|
||||||
|
|
||||||
|
# plot
|
||||||
|
for polys, awmul, alen, facecolor, arcolor in hitboxs:
|
||||||
|
# draw wall hitboxs (draw in reverse order)
|
||||||
|
for poly, n in polys[::-1]:
|
||||||
|
# clip at y=yy and take (x, z) coordinate
|
||||||
|
verts = poly.slicePlane(p0, pn)[:,axes]
|
||||||
|
if len(verts) == 0: continue
|
||||||
|
# plot hitbox area
|
||||||
|
ax.add_patch(patches.Polygon(verts, fc=facecolor, ec='black', lw=1))
|
||||||
|
# plot arrow
|
||||||
|
n = n*(1, 0, 1) # no y arrow
|
||||||
|
n = n[axes]
|
||||||
|
nnorm = np.linalg.norm(n)
|
||||||
|
if nnorm == 0: continue # TODO
|
||||||
|
n = n/nnorm
|
||||||
|
l = array([n[1], -n[0]])
|
||||||
|
## basis matrix
|
||||||
|
B = np.vstack([n, l])
|
||||||
|
## center
|
||||||
|
C = verts.mean(axis=0)
|
||||||
|
vertsO = verts-C
|
||||||
|
## n-l coordinates
|
||||||
|
nn = np.dot(vertsO, n)
|
||||||
|
ll = np.dot(vertsO, l)
|
||||||
|
## determine arrow width and count
|
||||||
|
iminl = ll.argmin()
|
||||||
|
imaxl = ll.argmax()
|
||||||
|
minl = ll[iminl]
|
||||||
|
maxl = ll[imaxl]
|
||||||
|
dl = maxl-minl
|
||||||
|
arrowWidth = arrowWidthBase*awmul
|
||||||
|
nArrow = np.floor(dl/arrowWidth).astype('i')
|
||||||
|
if nArrow >= 1:
|
||||||
|
if nArrow>arrowCountMax: nArrow = arrowCountMax
|
||||||
|
else:
|
||||||
|
arrowWidth = dl
|
||||||
|
nArrow = 1
|
||||||
|
arrowWidth *= arrowWidthMul
|
||||||
|
## determine arrow position
|
||||||
|
vlen = len(verts)
|
||||||
|
nbss = []
|
||||||
|
ls = np.linspace(minl, maxl, nArrow+2)[1:-1]
|
||||||
|
for step in [1, -1]:
|
||||||
|
i0 = iminl
|
||||||
|
i1 = (i0+step)%vlen
|
||||||
|
nbs = []
|
||||||
|
for lb in ls:
|
||||||
|
while ll[i1] < lb: i0, i1 = i1, (i1+step)%vlen
|
||||||
|
r0 = lb-ll[i0]
|
||||||
|
r1 = ll[i1]-lb
|
||||||
|
nbs.append((nn[i0]+nn[i1])/2 if r0+r1==0 else (nn[i0]*r1+nn[i1]*r0)/(r0+r1))
|
||||||
|
nbss.append(nbs)
|
||||||
|
nbss = array(nbss)
|
||||||
|
ncts = nbss.mean(axis=0)
|
||||||
|
nrgs = np.abs(np.diff(nbss, axis=0)[0])
|
||||||
|
# add arrow
|
||||||
|
for p, nrg in zip(
|
||||||
|
C+np.matmul(np.column_stack([ncts, ls]), B),
|
||||||
|
nrgs,
|
||||||
|
):
|
||||||
|
if nrg > arrowLenTher:
|
||||||
|
nrg = min(arrowLenMax, nrg*arrowLenMul2)
|
||||||
|
dn = n * nrg
|
||||||
|
offs = [-arrowLenMul2off, 1+arrowLenMul2off]
|
||||||
|
else:
|
||||||
|
nrg = min(arrowLenMax, nrg*arrowLenMul1)
|
||||||
|
dn = n * nrg
|
||||||
|
offs = [0.5]
|
||||||
|
arrowHeadLen = nrg*arrowHeadLenMul
|
||||||
|
for off in offs:
|
||||||
|
ax.arrow(
|
||||||
|
*(p-dn*off), *dn,
|
||||||
|
width=arrowWidth, #min(arrowWidth, nrg*0.15),
|
||||||
|
head_length=arrowHeadLen,
|
||||||
|
length_includes_head=True,
|
||||||
|
color=arcolor,
|
||||||
|
)
|
||||||
|
|
||||||
|
ax.set_xlabel('xyz'[axes[0]])
|
||||||
|
ax.set_ylabel('xyz'[axes[1]])
|
||||||
|
|
||||||
|
return axes
|
0
src/supSMSTAS/__init__.py
Normal file
0
src/supSMSTAS/__init__.py
Normal file
30
src/supSMSTAS/__main__.py
Normal file
30
src/supSMSTAS/__main__.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
# Copyright (c) 2022 sup39
|
||||||
|
|
||||||
|
def main():
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
from .UI import MainWindow
|
||||||
|
from PyQt5.QtWidgets import QApplication
|
||||||
|
|
||||||
|
# set log level
|
||||||
|
logging.basicConfig()
|
||||||
|
def try_parse_int(x):
|
||||||
|
try: return int(x)
|
||||||
|
except: return None
|
||||||
|
logLevelRaw = os.environ.get('LOG_LEVEL', 'WARNING')
|
||||||
|
logLevel = try_parse_int(logLevelRaw)
|
||||||
|
if logLevel is None: logLevel = try_parse_int(getattr(logging, logLevelRaw, None))
|
||||||
|
## logger
|
||||||
|
logger = logging.getLogger('supSMSTAS')
|
||||||
|
logger.setLevel(logging.WARNING if logLevel is None else logLevel)
|
||||||
|
|
||||||
|
# execute
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
w = MainWindow()
|
||||||
|
w.show()
|
||||||
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
BIN
src/supSMSTAS/codes/showHitbox.bin
Normal file
BIN
src/supSMSTAS/codes/showHitbox.bin
Normal file
Binary file not shown.
229
src/supSMSTAS/shape.py
Normal file
229
src/supSMSTAS/shape.py
Normal file
|
@ -0,0 +1,229 @@
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
'''
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 sup39[サポミク]
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
'''
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
array = np.array
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from matplotlib.path import Path
|
||||||
|
from matplotlib import patches
|
||||||
|
def normalize(x):
|
||||||
|
l = np.linalg.norm(x)
|
||||||
|
return x if l==0 else x/l
|
||||||
|
|
||||||
|
# 多角形
|
||||||
|
class Polygon():
|
||||||
|
def __init__(self, verts):
|
||||||
|
'''
|
||||||
|
* self.verts:
|
||||||
|
頂点の配列
|
||||||
|
Array of vertices
|
||||||
|
'''
|
||||||
|
self.verts = np.array(verts)
|
||||||
|
def clipLine(self, p, n, c):
|
||||||
|
'''
|
||||||
|
半平面 (x-p)・n >= c との共通部分を取る
|
||||||
|
Take intersection with half plane (x-p)・n >= c
|
||||||
|
* p:
|
||||||
|
直線上の一点
|
||||||
|
Any point on the line
|
||||||
|
* n:
|
||||||
|
直線の法線ベクトル
|
||||||
|
Normal vector of the line
|
||||||
|
* c:
|
||||||
|
定数
|
||||||
|
Constant
|
||||||
|
'''
|
||||||
|
p, n, c = map(array, (p, n, c))
|
||||||
|
r = np.dot(self.verts-p, n)-c
|
||||||
|
verts = []
|
||||||
|
for i in range(len(r)):
|
||||||
|
v0, r0 = self.verts[i-1], r[i-1]
|
||||||
|
v1, r1 = self.verts[i], r[i]
|
||||||
|
if r1 >= 0:
|
||||||
|
if r0 < 0: # (- +)
|
||||||
|
verts.append((r1*v0-r0*v1)/(-r0+r1))
|
||||||
|
verts.append(v1)
|
||||||
|
elif r0 >= 0: # (+ -)
|
||||||
|
verts.append((-r1*v0+r0*v1)/(r0-r1))
|
||||||
|
self.verts = np.array(verts) if len(verts) else self.verts[:0]
|
||||||
|
@property # getter
|
||||||
|
def path(self):
|
||||||
|
if self.verts.shape[0] == 0: return None
|
||||||
|
verts = self.verts
|
||||||
|
assert verts.shape[-1] == 2, 'verts should be 2D'
|
||||||
|
return Path([*verts, (0, 0)], [
|
||||||
|
Path.MOVETO,
|
||||||
|
*(Path.LINETO for _ in range(1, verts.shape[0])),
|
||||||
|
Path.CLOSEPOLY,
|
||||||
|
])
|
||||||
|
def plot(self, margin=0.05, facecolor='#2ee5b8', lw=1):
|
||||||
|
'''
|
||||||
|
この多角形を描画し、figとaxを返す
|
||||||
|
Plot this polygon and return ``fig'' and ``ax''
|
||||||
|
* margin:
|
||||||
|
Set margin of the plot
|
||||||
|
* facecolor:
|
||||||
|
面の色
|
||||||
|
Face color
|
||||||
|
* lw:
|
||||||
|
線の太さ
|
||||||
|
Line width
|
||||||
|
'''
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
if self.verts.shape[0] == 0: return ax
|
||||||
|
# path
|
||||||
|
path = self.path
|
||||||
|
patch = patches.PathPatch(path, facecolor=facecolor, lw=lw)
|
||||||
|
ax.add_patch(patch)
|
||||||
|
verts = self.verts
|
||||||
|
xMax, yMax = verts.max(axis=0)
|
||||||
|
xMin, yMin = verts.min(axis=0)
|
||||||
|
xMg, yMg = verts.ptp(axis=0)*margin
|
||||||
|
ax.set_xlim(xMin-xMg, xMax+xMg)
|
||||||
|
ax.set_ylim(yMin-yMg, yMax+yMg)
|
||||||
|
return fig, ax
|
||||||
|
def __repr__(self):
|
||||||
|
return 'Polygon with %d vertices:\n%s'%(
|
||||||
|
len(self.verts),
|
||||||
|
array(self.verts, 'f'),
|
||||||
|
)
|
||||||
|
|
||||||
|
# 多面体
|
||||||
|
class Polyhedron:
|
||||||
|
def __init__(self, verts, edges):
|
||||||
|
'''
|
||||||
|
* self.verts:
|
||||||
|
頂点の配列
|
||||||
|
Array of vertices
|
||||||
|
* self.edges:
|
||||||
|
辺(2頂点の番号)の配列
|
||||||
|
Array of edges (indices of 2 vertices)
|
||||||
|
'''
|
||||||
|
self.verts = np.array(verts)
|
||||||
|
self.edges = np.array(edges)
|
||||||
|
def clipPlane(self, p, n, c=0):
|
||||||
|
'''
|
||||||
|
半空間 (x-p)・n >= c との共通部分を取る
|
||||||
|
Take intersection with half space (x-p)・n >= c
|
||||||
|
* p:
|
||||||
|
平面上の一点
|
||||||
|
Any point on the plane
|
||||||
|
* n:
|
||||||
|
直線の法線ベクトル
|
||||||
|
Normal vector of the plane
|
||||||
|
* c:
|
||||||
|
定数
|
||||||
|
Constant
|
||||||
|
'''
|
||||||
|
p = array(p)
|
||||||
|
n = array(n)
|
||||||
|
r = np.dot(self.verts-p, n)-c
|
||||||
|
rb = [s>=0 for s in r]
|
||||||
|
# map vertex indices old to new
|
||||||
|
io2n = {
|
||||||
|
iO: iN
|
||||||
|
for iN, iO in enumerate(iO for iO, sb in enumerate(rb) if sb)
|
||||||
|
}
|
||||||
|
# handle old vert
|
||||||
|
verts = [v for v, sb in zip(self.verts, rb) if sb]
|
||||||
|
edges = []
|
||||||
|
for i0, i1 in self.edges:
|
||||||
|
if rb[i0] and rb[i1]:
|
||||||
|
# remain
|
||||||
|
edges.append((io2n[i0], io2n[i1]))
|
||||||
|
elif rb[i0] or rb[i1]:
|
||||||
|
# new vert
|
||||||
|
v0, r0 = self.verts[i0], abs(r[i0])
|
||||||
|
v1, r1 = self.verts[i1], abs(r[i1])
|
||||||
|
vN = (r1*v0+r0*v1)/(r0+r1)
|
||||||
|
edges.append((io2n[i0 if rb[i0] else i1], len(verts)))
|
||||||
|
verts.append(vN)
|
||||||
|
# else drop edge
|
||||||
|
# add new face
|
||||||
|
nOld = len(io2n)
|
||||||
|
vNews = verts[nOld:]
|
||||||
|
if len(vNews):
|
||||||
|
assert len(vNews) >= 3
|
||||||
|
p0, p1 = vNews[:2]
|
||||||
|
# choose p1-p0 as e1
|
||||||
|
e1 = normalize(p1-p0)
|
||||||
|
# choose e2 that ⊥ n, e1
|
||||||
|
e2 = normalize(np.cross(n, e1))
|
||||||
|
# set (p0+p1)/2 as new origin, and use {e1, e2} as new basis
|
||||||
|
cNews = np.dot(vNews-(p0+p1)/2, array([e1, e2]).transpose())
|
||||||
|
# indices of new verts CCW
|
||||||
|
jNews = nOld+np.arctan2(cNews[:,0], cNews[:,1]).argsort()
|
||||||
|
# add to edge
|
||||||
|
for i in range(len(vNews)):
|
||||||
|
edges.append((jNews[i-1], jNews[i]))
|
||||||
|
# final
|
||||||
|
self.verts = array(verts)
|
||||||
|
self.edges = array(edges)
|
||||||
|
def slicePlane(self, p, n):
|
||||||
|
'''
|
||||||
|
平面 (x-p)・n=0 との共通部分(多角形)の頂点を返す
|
||||||
|
Return vertices of intersection(polygon) with plane (x-p)・n=0
|
||||||
|
* p:
|
||||||
|
平面上の一点
|
||||||
|
Any point on the plane
|
||||||
|
* n:
|
||||||
|
平面の法線ベクトル
|
||||||
|
Normal vector of the plane
|
||||||
|
'''
|
||||||
|
p = array(p)
|
||||||
|
n = array(n)
|
||||||
|
r = np.dot(self.verts-p, n)
|
||||||
|
# handle old verts
|
||||||
|
#for i0, i1 in self.edges:
|
||||||
|
# # two vertices on other side of the plane
|
||||||
|
# if np.sign(r[i0]) != np.sign(r[i1]):
|
||||||
|
# v0, r0 = self.verts[i0], abs(r[i0])
|
||||||
|
# v1, r1 = self.verts[i1], abs(r[i1])
|
||||||
|
# vN = (r1*v0+r0*v1)/(r0+r1)
|
||||||
|
# vNews.append(vN)
|
||||||
|
signr = np.sign(r[self.edges])
|
||||||
|
edgesNew = self.edges[signr[:,0]!=signr[:,1]]
|
||||||
|
vv = self.verts[edgesNew]
|
||||||
|
rr = np.abs(r[edgesNew])
|
||||||
|
vNews = ((vv[:,0]*rr[:,1,None])+(vv[:,1]*rr[:,0,None]))/rr.sum(axis=1)[:,None]
|
||||||
|
# new verts
|
||||||
|
if len(vNews):
|
||||||
|
assert len(vNews) >= 2
|
||||||
|
p0, p1 = vNews[:2]
|
||||||
|
e1 = normalize(p1-p0)
|
||||||
|
e2 = normalize(np.cross(n, e1))
|
||||||
|
cNews = np.dot(vNews-(p0+p1)/2, array([e1, e2]).transpose())
|
||||||
|
jNews = np.arctan2(cNews[:,0], cNews[:,1]).argsort()
|
||||||
|
return vNews[jNews]
|
||||||
|
else:
|
||||||
|
return vNews
|
||||||
|
def __repr__(self):
|
||||||
|
return 'Polyhedron with %d vertices and %d edges:\n%s'%(
|
||||||
|
len(self.verts), len(self.edges),
|
||||||
|
array(self.verts[self.edges], 'f')
|
||||||
|
)
|
Loading…
Reference in a new issue