2025-12-01

This commit is contained in:
2026-03-17 14:58:51 -06:00
parent 183e865f8b
commit 4b82b57113
6846 changed files with 954887 additions and 162606 deletions
+674
View File
@@ -0,0 +1,674 @@
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>.
@@ -0,0 +1,5 @@
# Lighting Overrider
This add-on allows you to create, manage and apply python overrides in a flexible and reliable way to specific linked properties, as they are used in the lighting process of the Blender Studio pipeline.
You can find the documentation [here](https://studio.blender.org/tools/addons/pose_shape_keys).
@@ -0,0 +1,33 @@
UI
- show alerts for items that are not found
- automatically select type based on match
FEATURES
custom properties
- allow rna overriding of custom properties (see geonodes modifiers)
remove drivers/animation data
- properly remove drivers/animation data when creating an rna override
animated overrides
- store animation data in the blend file and write
their rna path to json to allow animated/driven overrides
execution script
- auto-generate script from modules
text data-block
- auto-load on file-load if on disk
- jump to file in text editor
settings interaction
- show dirty per category
FIXES
- library flags for RNA overrides
- settings ordering (template)
- search invert (template)
- auto-mute drivers/fcurves whenever necessary !!
@@ -0,0 +1,42 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
from . import (
categories,
props,
templates,
json_io,
execution,
ui,
override_picker,
)
bl_info = {
"name": "Lighting Overrider",
"author": "Simon Thommes",
"version": (0, 1, 3),
"blender": (3, 0, 0),
"location": "3D Viewport > Sidebar > Overrides",
"description": "Tool for the Blender Studio to create, manage and store local python overrides of linked data on a shot and sequence level.",
"category": "Workflow",
}
modules = [
ui,
templates,
categories,
props,
json_io,
execution,
override_picker,
]
def register():
for m in modules:
m.register()
def unregister():
for m in modules:
m.unregister()
@@ -0,0 +1,19 @@
schema_version = "1.0.0"
id = "lighting_overrider"
version = "0.1.3"
name = "Lighting Overrider"
tagline = "Create, manage and store local python overrides of linked data on a shot and sequence level"
maintainer = "Simon Thommes <simon@blender.org>"
type = "add-on"
website = "https://studio.blender.org/tools/addons/lighting_overrider"
tags = ["Lighting"]
blender_version_min = "4.2.0"
license = [
"SPDX:GPL-3.0-or-later",
]
copyright = [
"2019-2025 Simon Thommes & Blender Studio",
]
@@ -0,0 +1,23 @@
from . import (
variable_settings,
motion_blur_settings,
shader_settings,
rig_settings,
rna_overrides,
)
modules = [
variable_settings,
motion_blur_settings,
shader_settings,
rig_settings,
rna_overrides,
]
def register():
for m in modules:
m.register()
def unregister():
for m in modules:
m.unregister()
@@ -0,0 +1,256 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
from .. import utils
from ..templates import LOR_UL_settings_list, LOR_subsetting
import bpy
def settings_as_dict(settings):
data = {}
for setting in settings.motion_blur_settings:
data[setting.name] = []
return data
def apply_settings(data):
''' Deactivates deformation motion blur for objects in selected collections.
'''
if not data:
return
list_unique, list_all = utils.split_by_suffix(data.keys(), ':all')
if 'Master Collection' in data.keys() or 'Scene Collection' in data.keys():
for ob in bpy.data.objects:
if ob.type == 'CAMERA':
continue
ob.cycles.use_motion_blur = False
return
for col in bpy.data.collections:
for name_col in list_all:
if not col.name.startswith(name_col):
continue
for ob in col.all_objects:
if ob.type == 'CAMERA':
continue
ob.cycles.use_motion_blur = False
# unique names
if not col.name in list_unique:
continue
for ob in col.all_objects:
if ob.type == 'CAMERA':
continue
ob.cycles.use_motion_blur = False
return
def load_settings(settings, data):
while len(settings.motion_blur_settings) > 0:
settings.motion_blur_settings.remove(0)
for name in data.keys():
value = data[name]
new_setting = settings.motion_blur_settings.add()
new_setting.name = name
settings.motion_blur_settings_index = min(settings.motion_blur_settings_index, len(settings.motion_blur_settings)-1)
return
class LOR_OT_motion_blur_settings_apply(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.motion_blur_settings_apply"
bl_label = "Apply Motion Blur Settings"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
apply_settings(settings_as_dict(settings))
utils.kick_evaluation()
return {'FINISHED'}
class LOR_motion_blur_setting(LOR_subsetting):
name: bpy.props.StringProperty(default='Collection Name')
pass
class LOR_OT_motion_blur_settings_initialize(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.motion_blur_settings_init"
bl_label = "Add Active Collection"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return bool(context.collection)
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
existing_names = [setting.name for setting in settings.motion_blur_settings]
active_name = context.collection.name
if not active_name in existing_names:
new_setting = settings.motion_blur_settings.add()
new_setting.name = active_name
settings.is_dirty = True
settings.motion_blur_settings_index = len(settings.motion_blur_settings)-1
return {'FINISHED'}
class LOR_OT_motion_blur_setting_add(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.motion_blur_setting_add"
bl_label = "Add Motion Blur Setting"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
new_setting = settings.motion_blur_settings.add()
settings.is_dirty = True
settings.motion_blur_settings_index = len(settings.motion_blur_settings)-1
return {'FINISHED'}
class LOR_OT_motion_blur_setting_remove(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.motion_blur_setting_remove"
bl_label = "Remove Motion Blur Setting"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return len(settings.motion_blur_settings)>0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
settings.motion_blur_settings.remove(settings.motion_blur_settings_index)
settings.is_dirty = True
if settings.motion_blur_settings_index >= len(settings.motion_blur_settings):
settings.motion_blur_settings_index = len(settings.motion_blur_settings)-1
return {'FINISHED'}
class LOR_UL_motion_blur_settings_list(LOR_UL_settings_list):
def draw_item(
self, context, layout, data, item, icon, active_data, active_propname, index):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
row = layout.row()
col = row.column()
row = col.row(align=True)
row.label(text='', icon='OUTLINER_COLLECTION')
icon = 'WORLD' if item.name.endswith(':all') else 'MESH_CIRCLE'
if item.name in ['Master Collection', 'Scene Collection']:
icon = 'SHADING_SOLID'
row.prop(item, "name", text='', icon=icon, emboss=False)
col = row.column()
if index == settings.motion_blur_settings_index:
col.operator("lighting_overrider.motion_blur_setting_remove", icon='X', text="", emboss=False)
else:
col.label(text='', icon='BLANK1')
def filter_items(self, context, data, propname):
settings = getattr(data, propname)
helper_funcs = bpy.types.UI_UL_list
flt_flags = []
flt_neworder = []
if self.filter_name:
flt_flags = helper_funcs.filter_items_by_name(self.filter_name, self.bitflag_filter_item, settings, "name",
reverse=self.use_filter_invert)
return flt_flags, flt_neworder
class LOR_PT_motion_blur_settings_panel(bpy.types.Panel):
bl_parent_id = "LOR_PT_lighting_overrider_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Motion Blur Settings"
bl_category = 'Overrides'
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
self.layout.label(text='', icon='ONIONSKIN_ON')
return
def draw_header_preset(self, context):
layout = self.layout
col = layout.column()
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col.enabled = False
col.label(text=str(len(settings.motion_blur_settings)))
return
def draw(self, context):
layout = self.layout
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col_top = layout.column()
if not meta_settings.enabled:
col_top.enabled = False
row = col_top.row()
col = row.column()
row = col.row()
row.operator("lighting_overrider.motion_blur_settings_init", icon='SHADERFX')
col = row.column()
row = col.row(align=True)
row.operator("lighting_overrider.motion_blur_setting_add", icon='ADD', text="")
row.operator("lighting_overrider.motion_blur_setting_remove", icon='REMOVE', text="")
row = col_top.row(align=True)
col = row.column()
col.template_list(
"LOR_UL_motion_blur_settings_list",
"",
settings,
"motion_blur_settings",
settings,
"motion_blur_settings_index",
rows=2,
)
col.operator('lighting_overrider.motion_blur_settings_apply', icon='PLAY')
return
classes = (
LOR_PT_motion_blur_settings_panel,
LOR_motion_blur_setting,
LOR_UL_motion_blur_settings_list,
LOR_OT_motion_blur_setting_add,
LOR_OT_motion_blur_setting_remove,
LOR_OT_motion_blur_settings_initialize,
LOR_OT_motion_blur_settings_apply,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
@@ -0,0 +1,418 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
from .. import utils
from ..templates import LOR_setting, LOR_UL_settings_list
import bpy
def settings_as_dict(settings):
data = {}
for setting in settings.rig_settings:
data_sub = {}
for subsetting in setting.subsettings:
if isinstance(getattr(subsetting, subsetting.type), str):
data_sub[subsetting.name] = [getattr(subsetting, subsetting.type), subsetting.type]
elif not subsetting.bl_rna.properties[subsetting.type].is_array:
data_sub[subsetting.name] = [getattr(subsetting, subsetting.type), subsetting.type]
else:
data_sub[subsetting.name] = [getattr(subsetting, subsetting.type)[:], subsetting.type]
data[setting.specifier] = data_sub
return data
def get_properties_bone(ob, prefix='Properties_'):
if not ob.type == 'ARMATURE':
return None
for bone in ob.pose.bones:
if not bone.name.startswith(prefix):
continue
return bone
return None
def apply_settings(data):
if not data:
return
list_unique, list_all = utils.split_by_suffix(data.keys(), ':all')
for ob in bpy.data.objects:
# find properties bone (first posebone that starts with 'Properties_')
if not ob.type == 'ARMATURE':
continue
bone_prop = get_properties_bone(ob)
if not bone_prop:
continue
# group names
for name_ob in list_all:
if not ob.name.startswith(name_ob):
continue
for name_set in data[name_ob+':all']:
if not name_set in bone_prop:
print(f'Warning: Property {name_set} on object {ob.name} not found.')
continue
data_path = f'pose.bones["{bone_prop.name}"]["{name_set}"]'
utils.mute_fcurve(ob, data_path)
bone_prop[name_set] = data[name_ob+':all'][name_set][0]
# unique names
if ob.name in list_unique:
for name_set in data[ob.name]:
if name_set in bone_prop:
data_path = f'pose.bones["{bone_prop.name}"]["{name_set}"]'
utils.mute_fcurve(ob, data_path)
bone_prop[name_set] = data[ob.name][name_set][0]
else:
print(f'Warning: Property {name_set} on object {ob.name} not found.')
return
def load_settings(settings, data):
while len(settings.rig_settings) > 0:
settings.rig_settings.remove(0)
for specifier in data.keys():
subsettings_dict = data[specifier]
new_setting = settings.rig_settings.add()
new_setting.setting_expanded = False
new_setting.specifier = specifier
for name in subsettings_dict.keys():
value = subsettings_dict[name]
new_subsetting = new_setting.subsettings.add()
new_subsetting.name = name
new_subsetting.type = value[1]
setattr(new_subsetting, value[1], value[0])
settings.rig_settings_index = min(settings.rig_settings_index, len(settings.rig_settings)-1)
return
class LOR_OT_rig_settings_apply(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rig_settings_apply"
bl_label = "Apply Rig Settings"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
apply_settings(settings_as_dict(settings))
utils.kick_evaluation()
return {'FINISHED'}
class LOR_rig_setting(LOR_setting):
specifier: bpy.props.StringProperty(default='HLP-', update=utils.mark_dirty)
class LOR_OT_rig_settings_initialize(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rig_settings_init"
bl_label = "Initialize from Selection"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return 'ARMATURE' in [ob.type for ob in context.selected_objects]
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
existing_specifiers = [setting.specifier for setting in settings.rig_settings]
for ob in context.selected_objects:
if not ob.type == 'ARMATURE':
continue
bone_prop = get_properties_bone(ob)
if not bone_prop:
continue
if not ob.name in existing_specifiers:
setting = settings.rig_settings.add()
setting.specifier = ob.name
else:
setting = settings.rig_settings[existing_specifiers.index(ob.name)]
existing_names = [subsetting.name for subsetting in setting.subsettings]
for name in list(bone_prop.keys()): #TODO make type identification more fail-safe
try:
prop_props = bone_prop.id_properties_ui(name)
except:
continue
if name in existing_names:
continue
value = bone_prop[name]
type = 'VALUE'
if prop_props.as_dict()['subtype'] == 'COLOR':
type = 'COLOR'
elif prop_props.as_dict()['subtype'] == 'FACTOR':
type = 'FACTOR'
elif isinstance(bone_prop[name], int):
type = 'INTEGER'
elif isinstance(value, str):
type = 'STRING'
else:
try:
if len(value)==3 and not isinstance(value[0], str):
type = 'VECTOR'
else:
continue
except:
continue
subsetting = setting.subsettings.add()
subsetting.name = name
subsetting.type = type
setattr(subsetting, subsetting.type, value)#TODO pull in settings like min/max
settings.is_dirty = True
settings.rig_settings_index = len(settings.rig_settings)-1
return {'FINISHED'}
class LOR_OT_rig_setting_add(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rig_setting_add"
bl_label = "Add Rig Setting"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
new_setting = settings.rig_settings.add()
settings.is_dirty = True
settings.rig_settings_index = len(settings.rig_settings)-1
return {'FINISHED'}
class LOR_OT_rig_setting_remove(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rig_setting_remove"
bl_label = "Remove Rig Setting"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return len(settings.rig_settings)>0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
settings.rig_settings.remove(settings.rig_settings_index)
settings.is_dirty = True
if settings.rig_settings_index >= len(settings.rig_settings):
settings.rig_settings_index = len(settings.rig_settings)-1
return {'FINISHED'}
class LOR_OT_rig_setting_duplicate(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rig_setting_duplicate"
bl_label = "Duplicate Rig Setting"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return len(settings.rig_settings)>0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
prev_setting = settings.rig_settings[settings.rig_settings_index]
new_setting = settings.rig_settings.add()
setattr(new_setting, 'specifier', getattr(prev_setting, 'specifier'))
for i in range(len(prev_setting.subsettings)):
new_setting.subsettings.add()
enum_items = [item.identifier for item in prev_setting.subsettings[i].bl_rna.properties['type'].enum_items_static]
for prop in ['name', 'type']+enum_items:
setattr(new_setting.subsettings[i], prop, getattr(prev_setting.subsettings[i], prop))
settings.rig_settings_index = len(settings.rig_settings)-1
return {'FINISHED'}
class LOR_OT_rig_subsetting_add(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rig_subsetting_add"
bl_label = "Add Rig Subsetting"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
rig_setting = settings.rig_settings[settings.rig_settings_index]
new_subsetting = rig_setting.subsettings.add()
settings.is_dirty = True
return {'FINISHED'}
class LOR_OT_rig_subsetting_remove(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rig_subsetting_remove"
bl_label = "Remove Rig Subsetting"
bl_options = {"REGISTER", "UNDO"}
index: bpy.props.IntProperty(default=-1)
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
rig_setting = settings.rig_settings[settings.rig_settings_index]
rig_setting.subsettings.remove(self.index)
settings.is_dirty = True
return {'FINISHED'}
class LOR_UL_rig_settings_list(LOR_UL_settings_list):
def draw_item(
self, context, layout, data, item, icon, active_data, active_propname, index):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
row = layout.row()
col_top = row.column()
row = col_top.row()
if len(item.subsettings) == 0 and not index == settings.rig_settings_index:
toggle = False
else:
toggle = item.setting_expanded
if len(item.subsettings) == 0:
row.label(text='', icon='LAYER_USED')
else:
row.prop(item, 'setting_expanded',
icon="TRIA_DOWN" if toggle else "TRIA_RIGHT",
icon_only=True, emboss=False
)
icon = 'WORLD' if item.specifier.endswith(':all') else 'MESH_CIRCLE'
row.prop(item, "specifier", text='', icon=icon, emboss=False)
col = row.column()
col.alignment = 'RIGHT'
col.enabled = False
col.label(text=str(len(item.subsettings)))
col = row.column()
if index == settings.rig_settings_index:
col.operator("lighting_overrider.rig_setting_remove", icon='X', text="", emboss=False)
else:
col.label(text='', icon='BLANK1')
if toggle:
if index == settings.rig_settings_index:
col_top = col_top.box()
row = col_top.row()
col = row.column()
for i in range(len(item.subsettings)):
subsetting = item.subsettings[i]
row_sub = col.row()
col_sub = row_sub.column()
row_sub2 = col_sub.row(align=True)
row_sub2.prop(subsetting, "name", text='')
row_sub2.prop(subsetting, subsetting.type, text='')
col_sub = row_sub.column()
row_sub2 = col_sub.row(align=True)
row_sub2.prop(subsetting, 'type', text='', icon='THREE_DOTS', icon_only=True, emboss=False)
if index == settings.rig_settings_index:
row_sub.operator("lighting_overrider.rig_subsetting_remove", icon='REMOVE', text="", emboss=False).index = i
if index == settings.rig_settings_index:
col_top.operator("lighting_overrider.rig_subsetting_add", icon='ADD', text="")
class LOR_PT_rig_settings_panel(bpy.types.Panel):
bl_parent_id = "LOR_PT_lighting_overrider_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Rig Settings"
bl_category = 'Overrides'
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
self.layout.label(text='', icon='ARMATURE_DATA')
return
def draw_header_preset(self, context):
layout = self.layout
col = layout.column()
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col.enabled = False
col.label(text=str(len(settings.rig_settings)))
return
def draw(self, context):
layout = self.layout
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col_top = layout.column()
if not meta_settings.enabled:
col_top.enabled = False
row = col_top.row()
col = row.column()
row = col.row()
row.operator("lighting_overrider.rig_settings_init", icon='SHADERFX')
col = row.column()
row = col.row(align=True)
row.operator("lighting_overrider.rig_setting_add", icon='ADD', text="")
row.operator("lighting_overrider.rig_setting_remove", icon='REMOVE', text="")
row.operator("lighting_overrider.rig_setting_duplicate", icon='DUPLICATE', text="")
row = col_top.row(align=True)
col = row.column()
col.template_list(
"LOR_UL_rig_settings_list",
"",
settings,
"rig_settings",
settings,
"rig_settings_index",
rows=2,
)
col.operator('lighting_overrider.rig_settings_apply', icon='PLAY')
return
classes = (
LOR_PT_rig_settings_panel,
LOR_rig_setting,
LOR_UL_rig_settings_list,
LOR_OT_rig_setting_add,
LOR_OT_rig_setting_remove,
LOR_OT_rig_setting_duplicate,
LOR_OT_rig_settings_initialize,
LOR_OT_rig_subsetting_add,
LOR_OT_rig_subsetting_remove,
LOR_OT_rig_settings_apply,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
@@ -0,0 +1,276 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
from .. import utils
from ..templates import LOR_subsetting, LOR_UL_settings_list
import bpy
import idprop
def settings_as_dict(settings):
data = {}
for setting in settings.rna_overrides:
if isinstance(getattr(setting, setting.type), str):
data[setting.path] = [getattr(setting, setting.type), setting.type, setting.name]
elif not setting.bl_rna.properties[setting.type].is_array:
data[setting.path] = [getattr(setting, setting.type), setting.type, setting.name]
else:
data[setting.path] = [getattr(setting, setting.type)[:], setting.type, setting.name]
return data
def apply_settings(data):
''' Applies custom overrides on specified rna data paths.
'''
if not data:
return
for path in data:
try:
utils.mute_animation_on_rna_path(path)
if data[path][1] == 'STRING':
exec(path+f" = '{data[path][0]}'")
elif type(eval(path)) == idprop.types.IDPropertyArray:
exec(path+f'[:] = {data[path][0]}') # workaround for Blender not retaining UI data of property (see https://projects.blender.org/blender/blender/pulls/109203)
else:
exec(path+f' = {data[path][0]}')
except:
print(f'Warning: Failed to assign property {data[path][2]} at {path}')
def load_settings(settings, data):
while len(settings.rna_overrides) > 0:
settings.rna_overrides.remove(0)
for path in data.keys():
value = data[path]
new_setting = settings.rna_overrides.add()
new_setting.name = value[2]
new_setting.path = path
new_setting.type = value[1]
setattr(new_setting, value[1], value[0])
settings.rna_overrides_index = min(settings.rna_overrides_index, len(settings.rna_overrides)-1)
class LOR_OT_rna_overrides_apply(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rna_overrides_apply"
bl_label = "Apply RNA Overrides"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
apply_settings(settings_as_dict(settings))
utils.kick_evaluation()
return {'FINISHED'}
class LOR_rna_override(LOR_subsetting):
name: bpy.props.StringProperty(default='RNA Override')
path: bpy.props.StringProperty(default='bpy.data.')
def add_rna_override(context, add_info = None):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
new_setting = None
if add_info:
for rna_override in settings.rna_overrides:
if rna_override.path == add_info[1]:
new_setting = rna_override
add_info[0] = new_setting.name
if not new_setting:
new_setting = settings.rna_overrides.add()
settings.is_dirty = True
if add_info:
new_setting.name = add_info[0]
new_setting.path = add_info[1]
new_setting.type = add_info[3]
setattr(new_setting, new_setting.type, add_info[2])
settings.rna_overrides_index = len(settings.rna_overrides)-1
class LOR_OT_rna_override_add(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rna_override_add"
bl_label = "Add Variable Setting"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
add_rna_override(context)
return {'FINISHED'}
class LOR_OT_rna_override_remove(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.rna_override_remove"
bl_label = "Remove Variable Setting"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return len(settings.rna_overrides)>0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
settings.rna_overrides.remove(settings.rna_overrides_index)
settings.is_dirty = True
if settings.rna_overrides_index >= len(settings.rna_overrides):
settings.rna_overrides_index = len(settings.rna_overrides)-1
return {'FINISHED'}
class LOR_OT_rna_override_cleanup(bpy.types.Operator):
""" Removes outdated RNA overrides from the list
"""
bl_idname = "lighting_overrider.rna_override_cleanup"
bl_label = "Cleanup RNA Overrides"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return len(settings.rna_overrides)>0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
remove_list = []
for i, setting in enumerate(settings.rna_overrides):
try:
eval(setting.path)
except:
remove_list += [i]
continue
if remove_list:
settings.is_dirty = True
for j, i in enumerate(remove_list):
settings.rna_overrides.remove(i-j)
return {'FINISHED'}
class LOR_UL_rna_overrides_list(LOR_UL_settings_list):
def draw_item(
self, context, layout, data, item, icon, active_data, active_propname, index):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
row = layout.row()
col_top = row.column()
row = col_top.row(align=True)
row.prop(item, "name", text='', icon='DOT', emboss=False)
col = row.column()
if index == settings.rna_overrides_index:
col.operator("lighting_overrider.rna_override_remove", icon='X', text="", emboss=False)
else:
col.label(text='', icon='BLANK1')
row = col_top.row(align=True)
split = row.split(factor=.7, align=True)
split.prop(item, "path", text='')
split.prop(item, item.type, text='')
row.prop(item, 'type', text='', icon='THREE_DOTS', icon_only=True, emboss=False)
if index >= len(settings.rna_overrides)-1:
col_top.operator("lighting_overrider.rna_override_add", icon='ADD', text="", emboss=False)
def filter_items(self, context, data, propname):
settings = getattr(data, propname)
helper_funcs = bpy.types.UI_UL_list
flt_flags = []
flt_neworder = []
if self.filter_name:
flt_flags = helper_funcs.filter_items_by_name(self.filter_name, self.bitflag_filter_item, settings, "name",
reverse=self.use_filter_invert)
return flt_flags, flt_neworder
class LOR_PT_rna_overrides_panel(bpy.types.Panel):
bl_parent_id = "LOR_PT_lighting_overrider_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "RNA Overrides"
bl_category = 'Overrides'
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
self.layout.label(text='', icon='RNA')
return
def draw_header_preset(self, context):
layout = self.layout
col = layout.column()
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col.enabled = False
col.label(text=str(len(settings.rna_overrides)))
return
def draw(self, context):
layout = self.layout
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col_top = layout.column()
if not meta_settings.enabled:
col_top.enabled = False
row = col_top.row(align=True)
row.operator("lighting_overrider.rna_override_add", icon='ADD', text="")
row.operator("lighting_overrider.rna_override_remove", icon='REMOVE', text="")
row.operator("lighting_overrider.rna_override_cleanup", icon='BRUSH_DATA', text="Clean Up")
row = col_top.row(align=True)
col = row.column()
col.template_list(
"LOR_UL_rna_overrides_list",
"",
settings,
"rna_overrides",
settings,
"rna_overrides_index",
rows=2,
)
col.operator('lighting_overrider.rna_overrides_apply', icon='PLAY')
return
classes = (
LOR_PT_rna_overrides_panel,
LOR_rna_override,
LOR_UL_rna_overrides_list,
LOR_OT_rna_override_add,
LOR_OT_rna_override_remove,
LOR_OT_rna_overrides_apply,
LOR_OT_rna_override_cleanup,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
@@ -0,0 +1,400 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
from .. import utils
from ..templates import LOR_setting, LOR_UL_settings_list
import bpy
def settings_as_dict(settings):
data = {}
for setting in settings.shader_settings:
data_sub = {}
for subsetting in setting.subsettings:
if isinstance(getattr(subsetting, subsetting.type), str):
data_sub[subsetting.name] = [getattr(subsetting, subsetting.type), subsetting.type]
elif not subsetting.bl_rna.properties[subsetting.type].is_array:
data_sub[subsetting.name] = [getattr(subsetting, subsetting.type), subsetting.type]
else:
data_sub[subsetting.name] = [getattr(subsetting, subsetting.type)[:], subsetting.type]
data[setting.specifier] = data_sub
return data
def apply_settings(data):
if not data:
return
list_unique, list_all = utils.split_by_suffix(data.keys(), ':all')
for ob in bpy.data.objects:
# group names
for name_ob in list_all:
if not ob.name.startswith(name_ob):
continue
for name_set in data[name_ob+':all']:
if not name_set in ob:
print(f'Warning: Property {name_set} on object {ob.name} not found.')
continue
ob[name_set] = data[name_ob+':all'][name_set][0]
# unique names
if ob.name in list_unique:
for name_set in data[ob.name]:
if name_set in ob:
ob[name_set] = data[ob.name][name_set][0]
else:
print(f'Warning: Property {name_set} on object {ob.name} not found.')
return
def load_settings(settings, data):
while len(settings.shader_settings) > 0:
settings.shader_settings.remove(0)
for specifier in data.keys():
subsettings_dict = data[specifier]
new_setting = settings.shader_settings.add()
new_setting.setting_expanded = False
new_setting.specifier = specifier
for name in subsettings_dict.keys():
value = subsettings_dict[name]
new_subsetting = new_setting.subsettings.add()
new_subsetting.name = name
new_subsetting.type = value[1]
setattr(new_subsetting, value[1], value[0])
settings.shader_settings_index = min(settings.shader_settings_index, len(settings.shader_settings)-1)
return
class LOR_OT_shader_settings_apply(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.shader_settings_apply"
bl_label = "Apply Shader Settings"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
apply_settings(settings_as_dict(settings))
utils.kick_evaluation()
return {'FINISHED'}
class LOR_shader_setting(LOR_setting):
specifier: bpy.props.StringProperty(default='HLP-', update=utils.mark_dirty)
class LOR_OT_shader_settings_initialize(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.shader_settings_init"
bl_label = "Initialize from Selection"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return len(context.selected_objects) > 0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
existing_specifiers = [setting.specifier for setting in settings.shader_settings]
objects = context.selected_objects
for ob in context.selected_objects:
if not ob.type == 'ARMATURE':
continue
for child in ob.children:
if not (child.name.startswith('HLP-') and 'settings' in child.name):
continue
if child in objects:
continue
objects += [child]
for ob in objects:
if ob.type == 'ARMATURE':
continue
if not ob.name in existing_specifiers:
setting = settings.shader_settings.add()
setting.specifier = ob.name
existing_specifiers += [ob.name]
else:
setting = settings.shader_settings[existing_specifiers.index(ob.name)]
existing_names = [subsetting.name for subsetting in setting.subsettings]
for name in list(ob.keys()):
try:
prop_props = ob.id_properties_ui(name)
except:
continue
if name in existing_names:
continue
subsetting = setting.subsettings.add()
subsetting.name = name
value = ob[name]
if 'subtype' in prop_props.as_dict().keys():
if prop_props.as_dict()['subtype'] == 'COLOR':
subsetting.type = 'COLOR'
if prop_props.as_dict()['subtype'] == 'FACTOR':
subsetting.type = 'FACTOR'
elif '__len__' in dir(value):
if isinstance(value, str):
subsetting.type = 'STRING'
elif len(value)==3:
subsetting.type = 'VECTOR'
else:
continue
setattr(subsetting, subsetting.type, value)
settings.is_dirty = True
settings.shader_settings_index = len(settings.shader_settings)-1
return {'FINISHED'}
class LOR_OT_shader_setting_add(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.shader_setting_add"
bl_label = "Add Shader Setting"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
new_setting = settings.shader_settings.add()
settings.is_dirty = True
settings.shader_settings_index = len(settings.shader_settings)-1
return {'FINISHED'}
class LOR_OT_shader_setting_remove(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.shader_setting_remove"
bl_label = "Remove Shader Setting"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return len(settings.shader_settings)>0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
settings.shader_settings.remove(settings.shader_settings_index)
settings.is_dirty = True
if settings.shader_settings_index >= len(settings.shader_settings):
settings.shader_settings_index = len(settings.shader_settings)-1
return {'FINISHED'}
class LOR_OT_shader_setting_duplicate(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.shader_setting_duplicate"
bl_label = "Duplicate Shader Setting"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return len(settings.shader_settings)>0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
prev_setting = settings.shader_settings[settings.shader_settings_index]
new_setting = settings.shader_settings.add()
setattr(new_setting, 'specifier', getattr(prev_setting, 'specifier'))
for i in range(len(prev_setting.subsettings)):
new_setting.subsettings.add()
enum_items = [item.identifier for item in prev_setting.subsettings[i].bl_rna.properties['type'].enum_items_static]
for prop in ['name', 'type']+enum_items:
setattr(new_setting.subsettings[i], prop, getattr(prev_setting.subsettings[i], prop))
settings.shader_settings_index = len(settings.shader_settings)-1
return {'FINISHED'}
class LOR_OT_shader_subsetting_add(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.shader_subsetting_add"
bl_label = "Add Shader Subsetting"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
shader_setting = settings.shader_settings[settings.shader_settings_index]
new_subsetting = shader_setting.subsettings.add()
settings.is_dirty = True
return {'FINISHED'}
class LOR_OT_shader_subsetting_remove(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.shader_subsetting_remove"
bl_label = "Remove Shader Subsetting"
bl_options = {"REGISTER", "UNDO"}
index: bpy.props.IntProperty(default=-1)
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
shader_setting = settings.shader_settings[settings.shader_settings_index]
shader_setting.subsettings.remove(self.index)
settings.is_dirty = True
return {'FINISHED'}
class LOR_UL_shader_settings_list(LOR_UL_settings_list):
def draw_item(
self, context, layout, data, item, icon, active_data, active_propname, index):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
row = layout.row()
col_top = row.column()
row = col_top.row()
if len(item.subsettings) == 0 and not index == settings.shader_settings_index:
toggle = False
else:
toggle = item.setting_expanded
if len(item.subsettings) == 0:
row.label(text='', icon='LAYER_USED')
else:
row.prop(item, 'setting_expanded',
icon="TRIA_DOWN" if toggle else "TRIA_RIGHT",
icon_only=True, emboss=False
)
icon = 'WORLD' if item.specifier.endswith(':all') else 'MESH_CIRCLE'
row.prop(item, "specifier", text='', icon=icon, emboss=False)
col = row.column()
col.alignment = 'RIGHT'
col.enabled = False
col.label(text=str(len(item.subsettings)))
col = row.column()
if index == settings.shader_settings_index:
col.operator("lighting_overrider.shader_setting_remove", icon='X', text="", emboss=False)
else:
col.label(text='', icon='BLANK1')
if toggle:
if index == settings.shader_settings_index:
col_top = col_top.box()
row = col_top.row()
col = row.column()
for i in range(len(item.subsettings)):
subsetting = item.subsettings[i]
row_sub = col.row()
col_sub = row_sub.column()
row_sub2 = col_sub.row(align=True)
row_sub2.prop(subsetting, "name", text='')
row_sub2.prop(subsetting, subsetting.type, text='')
col_sub = row_sub.column()
row_sub2 = col_sub.row(align=True)
row_sub2.prop(subsetting, 'type', text='', icon='THREE_DOTS', icon_only=True, emboss=False)
if index == settings.shader_settings_index:
row_sub.operator("lighting_overrider.shader_subsetting_remove", icon='REMOVE', text="", emboss=False).index = i
if index == settings.shader_settings_index:
col_top.operator("lighting_overrider.shader_subsetting_add", icon='ADD', text="")
class LOR_PT_shader_settings_panel(bpy.types.Panel):
bl_parent_id = "LOR_PT_lighting_overrider_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Shader Settings"
bl_category = 'Overrides'
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text='', icon='NODE_MATERIAL')
return
def draw_header_preset(self, context):
layout = self.layout
col = layout.column()
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col.enabled = False
col.label(text=str(len(settings.shader_settings)))
return
def draw(self, context):
layout = self.layout
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col_top = layout.column()
if not meta_settings.enabled:
col_top.enabled = False
row = col_top.row()
col = row.column()
row = col.row()
row.operator("lighting_overrider.shader_settings_init", icon='SHADERFX')
col = row.column()
row = col.row(align=True)
row.operator("lighting_overrider.shader_setting_add", icon='ADD', text="")
row.operator("lighting_overrider.shader_setting_remove", icon='REMOVE', text="")
row.operator("lighting_overrider.shader_setting_duplicate", icon='DUPLICATE', text="")
row = col_top.row(align=True)
col = row.column()
col.template_list(
"LOR_UL_shader_settings_list",
"",
settings,
"shader_settings",
settings,
"shader_settings_index",
rows=2,
)
col.operator('lighting_overrider.shader_settings_apply', icon='PLAY')
return
classes = (
LOR_PT_shader_settings_panel,
LOR_shader_setting,
LOR_UL_shader_settings_list,
LOR_OT_shader_setting_add,
LOR_OT_shader_setting_remove,
LOR_OT_shader_setting_duplicate,
LOR_OT_shader_settings_initialize,
LOR_OT_shader_subsetting_add,
LOR_OT_shader_subsetting_remove,
LOR_OT_shader_settings_apply,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
@@ -0,0 +1,260 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
from .. import utils
from ..templates import LOR_subsetting, LOR_UL_settings_list
import bpy
def settings_as_dict(settings):
data = {}
for setting in settings.variable_settings:
if isinstance(getattr(setting, setting.type), str):
data[setting.name] = [getattr(setting, setting.type), setting.type]
elif not setting.bl_rna.properties[setting.type].is_array:
data[setting.name] = [getattr(setting, setting.type), setting.type]
else:
data[setting.name] = [getattr(setting, setting.type)[:], setting.type]
return data
def apply_settings(data):
''' Applies settings to according nodes in the variables nodegroup.
'''
if not data:
return
for ng in bpy.data.node_groups:
if not ng.name == 'VAR-settings':
continue
for name in data:
node = ng.nodes.get(name)
if node:
node.outputs[0].default_value = data[name][0]
else:
print(f'Warning: Node {set} in variable settings nodegroup not found.')
return
def load_settings(settings, data):
while len(settings.variable_settings) > 0:
settings.variable_settings.remove(0)
for name in data.keys():
value = data[name]
new_setting = settings.variable_settings.add()
new_setting.name = name
new_setting.type = value[1]
setattr(new_setting, value[1], value[0])
settings.variable_settings_index = min(settings.variable_settings_index, len(settings.variable_settings)-1)
return
class LOR_OT_variable_settings_apply(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.variable_settings_apply"
bl_label = "Apply Variable Settings"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
apply_settings(settings_as_dict(settings))
utils.kick_evaluation()
return {'FINISHED'}
class LOR_variable_setting(LOR_subsetting):
pass
class LOR_OT_variable_settings_initialize(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.variable_settings_init"
bl_label = "Initialize from Selection"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return bool(bpy.data.node_groups.get('VAR-settings'))
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
existing_names = [setting.name for setting in settings.variable_settings]
ng = bpy.data.node_groups.get('VAR-settings')
if not ng:
return {'CANCELLED'}
for node in ng.nodes:
if node.name in ['Group Input', 'Group Output', 'Math', 'Map Range']+existing_names:
continue
new_setting = settings.variable_settings.add()
new_setting.name = node.name
value = node.outputs[0].default_value
if '__len__' in dir(value):
new_setting.type = 'COLOR'
setattr(new_setting, new_setting.type, value[:])
else:
new_setting.type = 'VALUE'
setattr(new_setting, new_setting.type, value)
settings.is_dirty = True
settings.variable_settings_index = len(settings.variable_settings)-1
return {'FINISHED'}
class LOR_OT_variable_setting_add(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.variable_setting_add"
bl_label = "Add Variable Setting"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
new_setting = settings.variable_settings.add()
settings.is_dirty = True
settings.variable_settings_index = len(settings.variable_settings)-1
return {'FINISHED'}
class LOR_OT_variable_setting_remove(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.variable_setting_remove"
bl_label = "Remove Variable Setting"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return len(settings.variable_settings)>0
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
settings.variable_settings.remove(settings.variable_settings_index)
settings.is_dirty = True
if settings.variable_settings_index >= len(settings.variable_settings):
settings.variable_settings_index = len(settings.variable_settings)-1
return {'FINISHED'}
class LOR_UL_variable_settings_list(LOR_UL_settings_list):
def draw_item(
self, context, layout, data, item, icon, active_data, active_propname, index):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
row = layout.row()
col = row.column()
row = col.row(align=True)
row.prop(item, "name", text='', icon='DOT', emboss=False)
row.prop(item, item.type, text='')
row.prop(item, 'type', text='', icon='THREE_DOTS', icon_only=True, emboss=False)
col = row.column()
if index == settings.variable_settings_index:
col.operator("lighting_overrider.variable_setting_remove", icon='X', text="", emboss=False)
else:
col.label(text='', icon='BLANK1')
def filter_items(self, context, data, propname):
settings = getattr(data, propname)
helper_funcs = bpy.types.UI_UL_list
flt_flags = []
flt_neworder = []
if self.filter_name:
flt_flags = helper_funcs.filter_items_by_name(self.filter_name, self.bitflag_filter_item, settings, "name",
reverse=self.use_filter_invert)
return flt_flags, flt_neworder
class LOR_PT_variable_settings_panel(bpy.types.Panel):
bl_parent_id = "LOR_PT_lighting_overrider_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Variable Settings"
bl_category = 'Overrides'
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.label(text='', icon='LIGHT_SUN')
return
def draw_header_preset(self, context):
layout = self.layout
col = layout.column()
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col.enabled = False
col.label(text=str(len(settings.variable_settings)))
return
def draw(self, context):
layout = self.layout
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
col_top = layout.column()
if not meta_settings.enabled:
col_top.enabled = False
row = col_top.row()
col = row.column()
row = col.row()
row.operator("lighting_overrider.variable_settings_init", icon='SHADERFX')
col = row.column()
row = col.row(align=True)
row.operator("lighting_overrider.variable_setting_add", icon='ADD', text="")
row.operator("lighting_overrider.variable_setting_remove", icon='REMOVE', text="")
row = col_top.row(align=True)
col = row.column()
col.template_list(
"LOR_UL_variable_settings_list",
"",
settings,
"variable_settings",
settings,
"variable_settings_index",
rows=2,
)
col.operator('lighting_overrider.variable_settings_apply', icon='PLAY')
return
classes = (
LOR_PT_variable_settings_panel,
LOR_variable_setting,
LOR_UL_variable_settings_list,
LOR_OT_variable_setting_add,
LOR_OT_variable_setting_remove,
LOR_OT_variable_settings_initialize,
LOR_OT_variable_settings_apply,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
@@ -0,0 +1,220 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
from . import categories
from . import utils
from .import json_io
import bpy
import inspect
from bpy.app.handlers import persistent
from . import lighting_overrider_execution
from .lighting_overrider_execution import force_reload_external, settings_from_datablock
@persistent
def write_execution_script_on_save(dummy):
meta_settings = getattr(bpy.context.scene, 'LOR_Settings')
if not meta_settings.enabled:
return
bpy.ops.lighting_overrider.generate_execution_script()
return
def load_settings(context, name, path=None):
''' Return text datablock of the settings specified with a name. If a filepath is specified (re)load from disk.
'''
meta_settings = getattr(bpy.context.scene, 'LOR_Settings')
if not meta_settings:
return None
settings = utils.get_settings(meta_settings)
if path:
path += f'/{name}.settings.json'
settings_db = bpy.data.texts.get(f'{name}.settings.json')
if settings_db:
force_reload_external(context, settings_db)
return settings_from_datablock(settings_db)
if path:
if not os.path.isfile(path):
open(path, 'a').close()
bpy.ops.text.open(filepath=bpy.path.relpath(path))
settings_db = bpy.data.texts.get(f'{name}.settings.json')
else:
settings_db = bpy.data.texts.new(f'{name}.settings.json')
return settings_from_datablock(settings_db)
def apply_settings(data):
for cat in categories.modules:
cat_name = cat.__name__.split(".")[-1]
cat.apply_settings(data[cat_name])
return
def generate_execution_script() -> str:
script = inspect.getsource(lighting_overrider_execution)
return script
class LOR_OT_generate_execution_script(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.generate_execution_script"
bl_label = "Generate Execution Script"
bl_description = "Generate script for automatic execution of the overrides based on the JSON settings"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
if not meta_settings.execution_script:
meta_settings.execution_script = utils.find_execution_script()
if not meta_settings.execution_script:
text = bpy.data.texts.new('LOR_execution_script.py')
meta_settings.execution_script = text
else:
text = meta_settings.execution_script
text.from_string(generate_execution_script())
text.use_module = True
return {'FINISHED'}
def run_execution_script(context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
if not meta_settings.execution_script:
return False
script = meta_settings.execution_script
exec(script.as_string(), globals())
return True
class LOR_OT_run_execution_script(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.run_execution_script"
bl_label = "Run Execution Script"
bl_description = "Run script for automatic execution of the overrides based on the JSON settings"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return bool(meta_settings.execution_script)
def execute(self, context):
if not run_execution_script(context):
return {'CANCELLED'}
return {'FINISHED'}
class LOR_OT_reload_libraries(bpy.types.Operator):
""" Reloads all libraries to show the fresh file without overrides
"""
bl_idname = "lighting_overrider.reload_libraries"
bl_label = "Reload Libraries"
bl_description = "Reload all libraries"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
utils.reload_libraries()
return {'FINISHED'}
class LOR_OT_reload_run_execution_script(bpy.types.Operator):
""" Reloads all libraries and runs the override script to show how the file will look after load
"""
bl_idname = "lighting_overrider.reload_run_execution_script"
bl_label = "Reload Libraries and Run Execution Script"
bl_description = "Reload all libraries and run script for automatic execution of the overrides based on the JSON settings"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
return bool(meta_settings.execution_script)
def execute(self, context):
utils.reload_libraries()
if not run_execution_script(context):
return {'CANCELLED'}
return {'FINISHED'}
class LOR_OT_apply_JSON(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.apply_json"
bl_label = "Apply JSON"
bl_description = "Apply settings from specified JSON text datablock"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return bool(settings.text_datablock)
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
text = settings.text_datablock
data = json_io.read_data_from_json(text)
apply_settings(data)
utils.kick_evaluation()
return {'FINISHED'}
class LOR_OT_write_apply_JSON(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.write_apply_json"
bl_label = "Write and Apply JSON"
bl_description = "Write and apply settings in specified JSON text datablock"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return bool(settings.text_datablock)
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
text = settings.text_datablock
data = json_io.pack_settings_data(settings)
json_io.write_data_to_json( text, data)
settings.is_dirty = False
apply_settings(data)
utils.kick_evaluation()
return {'FINISHED'}
classes = (
LOR_OT_apply_JSON,
LOR_OT_write_apply_JSON,
LOR_OT_generate_execution_script,
LOR_OT_reload_libraries,
LOR_OT_run_execution_script,
LOR_OT_reload_run_execution_script,
)
def register():
for c in classes:
bpy.utils.register_class(c)
bpy.app.handlers.save_pre.append(write_execution_script_on_save)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
@@ -0,0 +1,172 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
import bpy
import json
from . import categories
from . import utils
class LOR_OT_find_settings(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.find_settings"
bl_label = "Find JSON"
bl_description = "Find settings datablock for the current sequence or shot as it is referenced in the scene properties"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
sequence_settings_db, shot_settings_db = utils.find_settings(bpy.context)
if meta_settings.settings_toggle == 'SEQUENCE':
meta_settings.sequence_settings.text_datablock = sequence_settings_db
elif meta_settings.settings_toggle == 'SHOT':
meta_settings.shot_settings.text_datablock = shot_settings_db
return {'FINISHED'}
class LOR_OT_read_settings(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.read_settings"
bl_label = "Read JSON"
bl_description = "Read settings from specified text datablock"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return bool(settings.text_datablock)
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
text = settings.text_datablock
if not text.is_in_memory:
override = context.copy()
area_type = override['area'].type
override['area'].type = 'TEXT_EDITOR'
override['region'] = override['area'].regions[0]
override['edit_text'] = text
with context.temp_override(**override):
bpy.ops.text.reload()
override['area'].type = area_type
data = read_data_from_json(text)
unpack_settings_data(settings, data)
settings.is_dirty = False
return {'FINISHED'}
class LOR_OT_write_settings(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.write_settings"
bl_label = "Write JSON"
bl_description = "Write settings to specified text datablock"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
return bool(settings.text_datablock)
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
text = settings.text_datablock
data = pack_settings_data(settings)
write_data_to_json( text, data)
if not text.is_in_memory:
override = context.copy()
area_type = override['area'].type
override['area'].type = 'TEXT_EDITOR'
override['region'] = override['area'].regions[0]
override['edit_text'] = text
with context.temp_override(**override):
bpy.ops.text.save()
override['area'].type = area_type
settings.is_dirty = False
return {'FINISHED'}
def pack_settings_data(settings) -> dict:
data = {}
for cat in categories.modules:
cat_name = cat.__name__.split(".")[-1]
data[cat_name] = cat.settings_as_dict(settings)
return data
def unpack_settings_data(settings, data):
for cat in categories.modules:
cat_name = cat.__name__.split(".")[-1]
if not cat_name in data.keys():
continue
cat.load_settings(settings, data[cat_name])
return
def cleanup_json(string):
counter = 0
open_brackets = 0
remove = []
for i, char in enumerate(string):
#if char == '{':
# counter += 1
# continue
#if counter < 3:
# continue
if char == '[':
open_brackets += 1
elif char == ']':
open_brackets -= 1
if open_brackets:
if char == '\n':
remove += [i]
elif char == ' ' and string[i+1] == ' ':
remove += [i]
counter = 0
for i in remove:
i -= counter
string = string[:i] + string[i+1:]
counter += 1
return string
def write_data_to_json(text: bpy.types.Text, data: dict, partial=None):
text.clear()
text.write(cleanup_json(json.dumps(data, separators=(',', ':'), indent=4)))
return
def read_data_from_json(text: bpy.types.Text):
return json.loads(text.as_string()) if text.as_string() else json.loads('{}')
classes = (
LOR_OT_find_settings,
LOR_OT_read_settings,
LOR_OT_write_settings,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
@@ -0,0 +1,357 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
import bpy
import os
import json
import idprop
from pathlib import Path
def parse_rna_path_to_elements(rna_path, delimiter='.'):
''' Returns the element strings of an RNA path split by '.' delimiter, disregarding any delimiter in a string within the path.
'''
if not delimiter in rna_path:
return [rna_path]
parse = rna_path
# replace escape chars with whitespaces
parse_elements = parse.split(r'\\')
parse = ' '.join(parse_elements)
parse_elements = parse.split('\\')
parse = parse_elements[0]
for el in parse_elements[1:]:
parse += ' '
parse += el[1:]
# replace strings within path with whitespaces
parse_elements = parse.split('"')
parse = parse_elements[0]
for el1, el2 in zip(parse_elements[1::2], parse_elements[2::2]):
parse += '"'+' '*len(el1)+'"'
parse += el2
parse_elements = parse.split(delimiter)
elements = []
for el in parse_elements:
elements += [rna_path[:len(el)]]
rna_path = rna_path[len(el)+len(delimiter):]
return elements
def parse_rna_path_for_custom_property(rna_path):
''' Returns the rna path of the datablock and the name of the custom property for an rna path that describes a custom property.
'''
if not '][' in rna_path:
return False
parse_elements = parse_rna_path_to_elements(rna_path, delimiter='][')
return parse_elements[0]+']', '"'.join(parse_elements[1].split('"')[1:-1])
def mute_fcurve(db, path):
if not db.animation_data:
return
if not db.animation_data.action:
return
fcurve = db.animation_data.action.fcurves.find(path)
c = 0
while fcurve or c<=4:
if fcurve:
fcurve.mute = True
c += 1
fcurve = db.animation_data.action.fcurves.find(path, index=c)
return
def mute_driver(db, path):
if not db.animation_data:
return
if not db.animation_data.drivers:
return
driver = db.animation_data.drivers.find(path)
c = 0
while driver or c<=4:
if driver:
driver.mute = True
c += 1
driver = db.animation_data.drivers.find(path, index=c)
return
def mute_animation_on_rna_path(rna_path):
path_elements = parse_rna_path_to_elements(rna_path)
db_path = '.'.join(path_elements[:3])
if 'session_uid' in dir(eval(db_path)):
data_block = eval(db_path)
path = '.'.join(path_elements[3:])
else: # handle custom props
db_path, c_prop = parse_rna_path_for_custom_property(rna_path)
data_block = eval(db_path)
path = f'["{c_prop}"]'
if data_block.id_type in ['ACTION', 'BRUSH', 'COLLECTION', 'IMAGE', 'LIBRARY', 'PALETTE', 'PAINTCURVE', 'SCREEN', 'TEXT', 'WINDOWMANAGER', 'WORKSPACE']:
return
mute_fcurve(data_block, path)
mute_driver(data_block, path)
return
def split_by_suffix(list, sfx):
with_suffix = [name[:-len(sfx)] for name in list if name.endswith(sfx)]
without_suffix = [name for name in list if not name.endswith(sfx)]
return without_suffix, with_suffix
def get_properties_bone(ob, prefix='Properties_'):
if not ob.type == 'ARMATURE':
return None
for bone in ob.pose.bones:
if not bone.name.startswith(prefix):
continue
return bone
return None
def apply_variable_settings(data):
''' Applies settings to according nodes in the variables nodegroup.
'''
if not data:
return
for ng in bpy.data.node_groups:
if not ng.name == 'VAR-settings':
continue
for name in data:
node = ng.nodes.get(name)
if node:
node.outputs[0].default_value = data[name][0]
else:
print(f'Warning: Node {set} in variable settings nodegroup not found.')
return
def apply_motion_blur_settings(data):
''' Deactivates deformation motion blur for objects in selected collections.
'''
if not data:
return
list_unique, list_all = split_by_suffix(data.keys(), ':all')
if 'Master Collection' in data.keys() or 'Scene Collection' in data.keys():
for ob in bpy.data.objects:
if ob.type == 'CAMERA':
continue
ob.cycles.use_motion_blur = False
return
for col in bpy.data.collections:
for name_col in list_all:
if not col.name.startswith(name_col):
continue
for ob in col.all_objects:
if ob.type == 'CAMERA':
continue
ob.cycles.use_motion_blur = False
# unique names
if not col.name in list_unique:
continue
for ob in col.all_objects:
if ob.type == 'CAMERA':
continue
ob.cycles.use_motion_blur = False
return
def apply_shader_settings(data):
''' Assign shader setting properties to helper objects according to specified names.
'''
if not data:
return
list_unique, list_all = split_by_suffix(data.keys(), ':all')
for ob in bpy.data.objects:
# group names
for name_ob in list_all:
if not ob.name.startswith(name_ob):
continue
for name_set in data[name_ob+':all']:
if not name_set in ob:
print(f'Warning: Property {name_set} on object {ob.name} not found.')
continue
ob[name_set] = data[name_ob+':all'][name_set][0]
# unique names
if ob.name in list_unique:
for name_set in data[ob.name]:
if name_set in ob:
ob[name_set] = data[ob.name][name_set][0]
else:
print(f'Warning: Property {name_set} on object {ob.name} not found.')
return
def apply_rig_settings(data):
''' Assign rig setting properties to property bones according to specified names. Mutes fcurves from evaluation on those overriden properties.
'''
if not data:
return
list_unique, list_all = split_by_suffix(data.keys(), ':all')
for ob in bpy.data.objects:
# find properties bone (first posebone that starts with 'Properties_')
if not ob.type == 'ARMATURE':
continue
bone_prop = get_properties_bone(ob)
if not bone_prop:
continue
# group names
for name_ob in list_all:
if not ob.name.startswith(name_ob):
continue
for name_set in data[name_ob+':all']:
if not name_set in bone_prop:
print(f'Warning: Property {name_set} on object {ob.name} not found.')
continue
data_path = f'pose.bones["{bone_prop.name}"]["{name_set}"]'
mute_fcurve(ob, data_path)
bone_prop[name_set] = data[name_ob+':all'][name_set][0]
# unique names
if ob.name in list_unique:
for name_set in data[ob.name]:
if name_set in bone_prop:
data_path = f'pose.bones["{bone_prop.name}"]["{name_set}"]'
mute_fcurve(ob, data_path)
bone_prop[name_set] = data[ob.name][name_set][0]
else:
print(f'Warning: Property {name_set} on object {ob.name} not found.')
return
def apply_rna_overrides(data):
''' Applies custom overrides on specified rna data paths.
'''
if not data:
return
for path in data:
try:
mute_animation_on_rna_path(path)
if data[path][1] == 'STRING':
exec(path+f" = '{data[path][0]}'")
elif type(eval(path)) == idprop.types.IDPropertyArray:
exec(path+f'[:] = {data[path][0]}') # workaround for Blender not retaining UI data of property (see https://projects.blender.org/blender/blender/pulls/109203)
else:
exec(path+f' = {data[path][0]}')
except:
print(f'Warning: Failed to assign property {data[path][2]} at {path}')
return
def apply_settings(data):
''' Applies settings by categories using the specified category name and apply function.
'''
categories = {
'variable_settings': apply_variable_settings,
'motion_blur_settings': apply_motion_blur_settings,
'shader_settings': apply_shader_settings,
'rig_settings': apply_rig_settings,
'rna_overrides': apply_rna_overrides,
}
for cat in categories:
cat_data = data.get(cat)
if cat_data:
categories[cat](cat_data)
return
def settings_from_datablock(datablock):
''' Return the settings dict from the text data-block.
'''
settings = {}
if not datablock:
return None
if not datablock.as_string():
return settings
settings = json.loads(datablock.as_string())
return settings
def force_reload_external(context, text):
''' Reloads text datablock from disk.
'''
if not text:
return
if text.is_in_memory:
return
if not (text.is_dirty or text.is_modified):
return
path = text.filepath
path = bpy.path.abspath(path)
if not os.path.isfile(path):
return
new_string = open(path, 'r').read()
if not text.as_string() == new_string:
text.from_string(new_string)
return
def load_settings(context, name, path=None):
''' Return text datablock of the settings specified with a name. If a filepath is specified (re)load from disk.
'''
if path:
path += f'/{name}.settings.json'
settings_db = bpy.data.texts.get(f'{name}.settings.json')
if settings_db:
force_reload_external(context, settings_db)
return settings_from_datablock(settings_db)
if path:
if not os.path.isfile(path):
open(path, 'a').close()
bpy.ops.text.open(filepath=bpy.path.relpath(path))
settings_db = bpy.data.texts.get(f'{name}.settings.json')
else:
settings_db = bpy.data.texts.new(f'{name}.settings.json')
return settings_from_datablock(settings_db)
if __name__=="__main__" or __name__=="lighting_overrider.execution":
# Execution
context = bpy.context
sequence_settings = None
shot_settings = None
try:
sequence_db = context.scene['LOR_sequence_settings']
force_reload_external(context, sequence_db)
except:
sequence_db = None
try:
shot_db = context.scene['LOR_shot_settings']
force_reload_external(context, shot_db)
except:
shot_db = None
sequence_settings = settings_from_datablock(sequence_db)
shot_settings = settings_from_datablock(shot_db)
filepath = Path(bpy.context.blend_data.filepath)
sequence_name, shot_name = filepath.parts[-3:-1]
sequence_settings_path = filepath.parents[1].as_posix()
if not sequence_settings:
sequence_settings = load_settings(context, sequence_name, sequence_settings_path)
if not shot_settings:
shot_settings = load_settings(context, shot_name)
apply_settings(sequence_settings)
apply_settings(shot_settings)
# kick re-evaluation
for ob in bpy.data.objects:
ob.update_tag()
@@ -0,0 +1,295 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
import bpy
import re
import idprop
from . import utils
from .categories import rna_overrides
def struct_from_rna_path(rna_path):
''' Returns struct object for specified rna path.
'''
if not '.' in rna_path:
return None
elements = rna_path.rsplit('.', 1)
if '][' in elements[1]:
struct_path = f"{elements[0]}.{elements[1]}"
else:
struct_path = f"{elements[0]}.bl_rna.properties['{elements[1]}']"
try:
return eval(struct_path)
except:
return None
def stylize_name(path):
''' Splits words by '_', capitalizes them and separates them with ' '.
'''
custom_prop = utils.parse_rna_path_for_custom_property(path)
if custom_prop:
return f"{eval(custom_prop[0]+'.name')}: {custom_prop[1]}"
path_elements = utils.parse_rna_path_to_elements(path)
parent = '.'.join(path_elements[:-1])
main = path_elements[-1]
try:
if main in ['default_value']:
return eval(parent).name
else:
return f"{eval(parent).name}: {' '.join([word.capitalize() for word in main.split('_')])}"
except:
return ' '.join([word.capitalize() for word in main.split('_')])
class LOR_OT_override_picker(bpy.types.Operator):
"""Adds an operator on button mouse hover"""
bl_idname = "lighting_overrider.override_picker"
bl_label = "Add RNA Override"
bl_options = {'UNDO'}
rna_path: bpy.props.StringProperty(name="Data path to override", default="")
override_float: bpy.props.FloatProperty(name="Override", default=0)
batch_override: bpy.props.BoolProperty(name="Batch Override", default=False, options={'SKIP_SAVE'})
init_val = None
property = None
override = None
name_string = 'RNA Override'
type = 'VALUE'
_array_path_re = re.compile(r'^(.*)\[[0-9]+\]$')
@classmethod
def poll(cls, context):
#print(f'poll: {bpy.ops.ui.copy_data_path_button.poll()}')
return True
def draw(self, context):
layout = self.layout
property = self.property
if property is None:
return
col = layout.column()
col.scale_y = 1.8
col.scale_x = 1.5
if self.type == 'COLOR':
col.template_color_picker(context.scene, 'override', value_slider=True)
col = layout.column()
col.prop(context.scene, 'override')
self.override = context.scene['override']
if self.batch_override:
row = layout.row()
row.alert = True
row.label(text=f'Batch Overriding {len(context.selected_objects)} Objects', icon='DOCUMENTS')
def invoke(self, context, event):
if not bpy.ops.ui.copy_data_path_button.poll():
return {'PASS_THROUGH'}
clip = context.window_manager.clipboard
bpy.ops.ui.copy_data_path_button(full_path=True)
rna_path = context.window_manager.clipboard
context.window_manager.clipboard = clip
if rna_path.endswith('name'):
print("Warning: Don't override datablock names.")
return {'CANCELLED'}
if not rna_path.startswith('bpy.data.objects'):
self.batch_override = False
# Strip off array indices (f.e. 'a.b.location[0]' -> 'a.b.location')
m = self._array_path_re.match(rna_path)
if m:
rna_path = m.group(1)
self.rna_path = rna_path
self.property = struct_from_rna_path(rna_path)
if self.property is None:
print("Warning: No struct was found for given RNA path.")
return {'CANCELLED'}
self.name_string = stylize_name(self.rna_path)
if 'type' in dir(self.property):
# Gather UI data
keys = ['description', 'default', 'min', 'max', 'soft_min', 'soft_max', 'step', 'precision', 'subtype']
vars = {}
for key in keys:
try:
vars[key] = eval(f'self.property.{key}')
except:
print(f'{key} not in property')
if self.property.type == 'FLOAT':
vars['unit'] = self.property.unit
if not self.property.is_array:
bpy.types.Scene.override = bpy.props.FloatProperty(name = self.name_string, **vars)
else:
vars['size'] = self.property.array_length
vars['default'] = self.property.default_array[:]
if vars['subtype'] == 'COLOR':
self.type = 'COLOR'
else:
self.type = 'VECTOR'
bpy.types.Scene.override = bpy.props.FloatVectorProperty(name = self.name_string, **vars)
elif self.property.type == 'STRING':
bpy.types.Scene.override = bpy.props.StringProperty(name = self.name_string, **vars)
self.type = 'STRING'
elif self.property.type == 'BOOLEAN':
bpy.types.Scene.override = bpy.props.BoolProperty(name = self.name_string, **vars)
self.type = 'BOOL'
elif self.property.type == 'INT':
bpy.types.Scene.override = bpy.props.IntProperty(name = self.name_string, **vars)
self.type = 'INTEGER'
elif self.property.type == 'ENUM':
self.type = 'STRING'
items = [(item.identifier, item.name, item.description, item.icon, i) for i, item in enumerate(self.property.enum_items)]
vars.pop('subtype', None)
bpy.types.Scene.override = bpy.props.EnumProperty(items = items, name = self.name_string, **vars)
else:
vars = {}
custom_prop = utils.parse_rna_path_for_custom_property(self.rna_path)
if custom_prop:
data_block = eval(custom_prop[0])
property_name = custom_prop[1]
vars = data_block.id_properties_ui(property_name).as_dict()
if type(self.property) is float:
bpy.types.Scene.override = bpy.props.FloatProperty(name = self.name_string, **vars)
elif type(self.property) is idprop.types.IDPropertyArray:
bpy.types.Scene.override = bpy.props.FloatVectorProperty(name = self.name_string, size=len(self.property), **vars)
if vars['subtype'] in ['COLOR', 'COLOR_GAMMA']:
self.type = 'COLOR'
else:
self.type = 'VECTOR'
elif type(self.property) is str:
bpy.types.Scene.override = bpy.props.StringProperty(name = self.name_string, **vars)
self.type = 'STRING'
elif type(self.property) is int:
bpy.types.Scene.override = bpy.props.IntProperty(name = self.name_string, **vars)
self.type = 'INTEGER'
elif type(self.property) == bool:
bpy.types.Scene.override = bpy.props.BoolProperty(name = self.name_string, **vars)
self.type = 'BOOL'
# check for custom property
context.scene.override = eval(rna_path)
self.override = context.scene.override
self.init_val = eval(rna_path)
wm = context.window_manager
state = wm.invoke_props_dialog(self)
if state in {'FINISHED', 'CANCELLED'}:
del context.scene['override']
return state
else:
return state
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
path_elements = utils.parse_rna_path_to_elements(self.rna_path)
if context.scene.override==self.init_val:
del context.scene['override']
return {'CANCELLED'}
utils.mute_animation_on_rna_path(self.rna_path)
if type(eval(self.rna_path)) == idprop.types.IDPropertyArray:
exec(self.rna_path+f'[:] = context.scene.override') # workaround for Blender not retaining UI data of property (see https://projects.blender.org/blender/blender/pulls/109203)
else:
exec(self.rna_path+f' = context.scene.override')
add_info=[self.name_string, self.rna_path, context.scene.override, self.type]
rna_overrides.add_rna_override(context, add_info)
# TODO deduplicate with utils
if path_elements[2].startswith('objects'):
db_path = '.'.join(path_elements[:3])
if 'session_uid' in dir(eval(db_path)):
data_block = eval(db_path)
subpath = f'.{".".join(path_elements[3:])}'
else: # handle custom props
db_path, c_prop = utils.parse_rna_path_for_custom_property(self.rna_path)
data_block = eval(db_path)
subpath = f'["{c_prop}"]'
data_block.update_tag()
if not self.batch_override:
del context.scene['override']
return {'FINISHED'}
for ob in context.selected_objects:
if ob.library:
rna_path = f'bpy.data.objects["{ob.name}", "{ob.library.filepath}"]{subpath}'
else:
rna_path = f'bpy.data.objects["{ob.name}"]{subpath}'
utils.mute_animation_on_rna_path(rna_path)
try:
eval(rna_path)
except:
continue
if type(eval(rna_path)) == idprop.types.IDPropertyArray:
exec(rna_path+f'[:] = context.scene.override') # workaround for Blender not retaining UI data of property (see https://projects.blender.org/blender/blender/pulls/109203)
else:
exec(rna_path+f' = context.scene.override')
name_string = stylize_name(rna_path)
add_info = [name_string, rna_path, context.scene.override, self.type]
rna_overrides.add_rna_override(context, add_info)
utils.kick_evaluation(list(context.selected_objects))
del context.scene['override']
utils.kick_evaluation()
return {'FINISHED'}
def cancel(self, context):
del context.scene['override']
return
classes = [
LOR_OT_override_picker,
]
def register():
for c in classes:
bpy.utils.register_class(c)
wm = bpy.context.window_manager
if wm.keyconfigs.addon is not None:
km = wm.keyconfigs.addon.keymaps.new(name="User Interface")
kmi = km.keymap_items.new("lighting_overrider.override_picker","O", "PRESS",shift=False, ctrl=False)
kmi.properties.batch_override = False
kmi = km.keymap_items.new("lighting_overrider.override_picker","O", "PRESS",shift=False, ctrl=False, alt=True)
kmi.properties.batch_override = True
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
if __name__ == "__main__":
register()
@@ -0,0 +1,56 @@
import bpy
from .categories import rig_settings, shader_settings, rna_overrides
from .categories import variable_settings as var_settings
class LOR_SettingsGroup(bpy.types.PropertyGroup):
name: bpy.props.StringProperty()
text_datablock: bpy.props.PointerProperty(
type = bpy.types.Text,
name = "Settings JSON",
description = "Text datablock that contains the full settings information"
)
is_dirty: bpy.props.BoolProperty(default=False)
variable_settings: bpy.props.CollectionProperty(type=var_settings.LOR_variable_setting)
variable_settings_index: bpy.props.IntProperty()
motion_blur_settings: bpy.props.CollectionProperty(type=var_settings.LOR_variable_setting)
motion_blur_settings_index: bpy.props.IntProperty()
shader_settings: bpy.props.CollectionProperty(type=shader_settings.LOR_shader_setting)
shader_settings_index: bpy.props.IntProperty()
rig_settings: bpy.props.CollectionProperty(type=rig_settings.LOR_rig_setting)
rig_settings_index: bpy.props.IntProperty()
rna_overrides: bpy.props.CollectionProperty(type=rna_overrides.LOR_rna_override)
rna_overrides_index: bpy.props.IntProperty()
class LOR_MetaSettings(bpy.types.PropertyGroup):
enabled: bpy.props.BoolProperty(default=False)
shot_settings: bpy.props.PointerProperty(type=LOR_SettingsGroup)
sequence_settings: bpy.props.PointerProperty(type=LOR_SettingsGroup)
settings_toggle: bpy.props.EnumProperty(default='SHOT',
items= [('SEQUENCE', 'Sequence Settings', 'Manage override settings for the current sequence', '', 0),
('SHOT', 'Shot Settings', 'Manage override settings for the current shot', '', 1),]
)
execution_script: bpy.props.PointerProperty(
type = bpy.types.Text,
name = "Execution Script",
description = "Text datablock with script that automatically applies the saved settings on file-load"
)
execution_script_source: bpy.props.StringProperty(default='//../../../lib/scripts/load_settings.blend')#TODO expose in addon settings
classes = [
LOR_SettingsGroup,
LOR_MetaSettings,
]
def register():
for c in classes:
bpy.utils.register_class(c)
bpy.types.Scene.LOR_Settings = bpy.props.PointerProperty(type=LOR_MetaSettings)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
del bpy.types.Scene.LOR_Settings
@@ -0,0 +1,75 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
import bpy
from . import utils
class LOR_filter_string(bpy.types.PropertyGroup):
string: bpy.props.StringProperty(default='')
class LOR_subsetting(bpy.types.PropertyGroup):
name: bpy.props.StringProperty(default='setting', update=utils.mark_dirty)
VALUE: bpy.props.FloatProperty('', update=utils.mark_dirty)
FACTOR: bpy.props.FloatProperty(subtype='FACTOR', soft_min=0, soft_max=1, update=utils.mark_dirty)
INTEGER: bpy.props.IntProperty('', update=utils.mark_dirty)
BOOL: bpy.props.BoolProperty('', update=utils.mark_dirty)
VECTOR: bpy.props.FloatVectorProperty('', update=utils.mark_dirty)
COLOR: bpy.props.FloatVectorProperty(size=4, subtype='COLOR', default=(.5,.5,.5,1), soft_min=0, soft_max=1, update=utils.mark_dirty)
STRING: bpy.props.StringProperty('', update=utils.mark_dirty)
type: bpy.props.EnumProperty(items=[('VALUE', 'Value', '', '', 0),
('FACTOR', 'Factor', '', '', 1),
('INTEGER', 'Integer', '', '', 2),
('BOOL', 'Boolean', '', '', 3),
('VECTOR', 'Vector', '', '', 4),
('COLOR', 'Color', '', '', 5),
('STRING', 'String', '', '', 6),]
, update=utils.mark_dirty)
class LOR_setting(bpy.types.PropertyGroup):
specifier: bpy.props.StringProperty('', update=utils.mark_dirty)
subsettings: bpy.props.CollectionProperty(type=LOR_subsetting)
setting_expanded: bpy.props.BoolProperty(default=True)
class LOR_UL_settings_list(bpy.types.UIList):
filter_strings: bpy.props.CollectionProperty(type=LOR_filter_string)
def filter_items(self, context, data, propname):
settings = getattr(data, propname)
helper_funcs = bpy.types.UI_UL_list
flt_flags = []
flt_neworder = []
while not len(self.filter_strings) == len(settings):
if len(self.filter_strings) < len(settings):
self.filter_strings.add()
else:
self.filter_strings.remove(0)
if self.filter_name:
for i, set in enumerate(settings):
self.filter_strings[i].string = ' '.join([subset.name for subset in set.subsettings]).lower()
self.filter_strings[i].string = ' '.join([set.specifier, self.filter_strings[i].string])
flt_flags = helper_funcs.filter_items_by_name(self.filter_name.lower(), self.bitflag_filter_item, self.filter_strings, "string",
reverse=self.use_filter_invert)
return flt_flags, flt_neworder
classes = (
LOR_subsetting,
LOR_setting,
LOR_filter_string,
LOR_UL_settings_list,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
+206
View File
@@ -0,0 +1,206 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path
import bpy
from bpy.app.handlers import persistent
from . import utils
@persistent
def init_on_load(dummy):
if not bpy.data.is_saved:
return
context = bpy.context
meta_settings = getattr(context.scene, 'LOR_Settings')
if not meta_settings:
return
settings = utils.get_settings(meta_settings)
filepath = Path(bpy.context.blend_data.filepath)
sequence_name, shot_name, file_name = filepath.parts[-3:]
meta_settings.sequence_settings.name = sequence_name
meta_settings.shot_settings.name = shot_name
if file_name.endswith('.lighting.blend'):
meta_settings.enabled = True
if not meta_settings.enabled:
return
if not meta_settings.execution_script:
execution_script = bpy.data.texts.get('lighting_overrider_execution.py')
if not execution_script:
pass
meta_settings.execution_script = execution_script
if not bpy.context.blend_data.filepath:
return
sequence_settings_db, shot_settings_db = utils.find_settings(bpy.context)
if not meta_settings.sequence_settings.text_datablock:
meta_settings.sequence_settings.text_datablock = sequence_settings_db
if not meta_settings.shot_settings.text_datablock:
meta_settings.shot_settings.text_datablock = shot_settings_db
#utils.reload_settings(context) #TODO: Fix loading settings on file load
return
@persistent
def store_ref_on_save(dummy):
meta_settings = getattr(bpy.context.scene, 'LOR_Settings')
bpy.context.scene['LOR_sequence_settings'] = meta_settings.sequence_settings.text_datablock
bpy.context.scene['LOR_shot_settings'] = meta_settings.shot_settings.text_datablock
return
class LOR_OT_toggle_enabled(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.toggle_enabled"
bl_label = "Toggle Lighting Overrider Addon"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
meta_settings.enabled = not meta_settings.enabled
return {'FINISHED'}
class LOR_OT_text_db_add(bpy.types.Operator):
"""
"""
bl_idname = "lighting_overrider.text_db_add"
bl_label = "Add Text Datablock"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
name = f'{settings.name}.settings.json' if settings.name else f'{meta_settings.settings_toggle.lower()}_settings.json'
text_db = bpy.data.texts.new(name)
settings.text_datablock = text_db
return {'FINISHED'}
class LOR_PT_lighting_overrider_panel(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Lighting Overrider"
bl_category = 'Overrides'
def draw_header(self, context):
self.layout.label(text='', icon='LIBRARY_DATA_OVERRIDE')
return
def draw(self, context):
layout = self.layout
meta_settings = context.scene.LOR_Settings
settings = utils.get_settings(meta_settings)
enabled = meta_settings.enabled
text = 'Lighting Overrider Active' if enabled else 'Lighting Overrider Inactive'
icon = 'CHECKBOX_HLT' if enabled else 'CHECKBOX_DEHLT'
layout.operator('lighting_overrider.toggle_enabled', text=text, icon=icon, depress=enabled)
col_main = layout.column()
if not meta_settings.enabled:
col_main.enabled = False
col = col_main.column()
box = col.box()
row = box.row(align=True)
row.prop(meta_settings, 'execution_script')
if not meta_settings.execution_script:
row.operator('lighting_overrider.generate_execution_script', icon='FILE_CACHE', text='')
#row.operator('lighting_overrider.reload_libraries', icon='FILE_REFRESH', text='')#TODO reload libraries accurately (bug?)
row.operator('lighting_overrider.run_execution_script', icon='PLAY', text='')
#row = box.row()
#row.operator('lighting_overrider.reload_run_execution_script', icon='CHECKMARK')
if not meta_settings.execution_script:
col_warn = box.column()
col_warn.alert = True
row = col_warn.row()
row.label(text=f'No execution script referenced!', icon='ERROR')
row = col_warn.row()
row.label(text=f'Without the execution script overrides will not be applied on file-load!', icon='BLANK1')
col.separator(factor=2.0)
row = col.row()
row.prop(meta_settings, 'settings_toggle', expand=True)
col.alignment = 'CENTER'
col.label(text=f"{meta_settings.settings_toggle.capitalize()} Name: {settings.name if settings.name else 'UNKNOWN'}")
col = col_main.column()
col.label(text=settings.bl_rna.properties['text_datablock'].name)
row = col.row(align=True)
try:
linked_settings = context.scene[f'LOR_{meta_settings.settings_toggle.lower()}_settings']
except:
linked_settings = None
if settings.text_datablock not in [linked_settings, None]:
row.alert = True
row.prop(settings, 'text_datablock', text='', expand=True)
if not settings.text_datablock or row.alert:
row.operator('lighting_overrider.find_settings', text='', icon='VIEWZOOM')
if not settings.text_datablock:
row.operator('lighting_overrider.text_db_add', text='', icon='FILE_NEW')
else:
# mark whether JSON file is internal or external
row.label(text='', icon = 'FILE_ARCHIVE' if settings.text_datablock.is_in_memory else 'FILE')
row = col.row(align=True)
flag1 = False
flag2 = False
if settings.text_datablock:
if settings.text_datablock.is_dirty:
flag1 = True
if settings.text_datablock.is_modified:
flag2 = True
flag = (flag1 or flag2) and not settings.text_datablock.is_in_memory
row.alert = flag or settings.is_dirty
icon = 'FILE_TICK'if flag else 'IMPORT'
text = 'Write and Save JSON' if flag else 'Write JSON'
row.operator('lighting_overrider.write_settings', icon=icon, text=text)
icon = 'FILE_REFRESH'if flag else 'EXPORT'
text = 'Reload and Read JSON' if flag else 'Read JSON'
row.operator('lighting_overrider.read_settings', icon=icon, text=text)
row = col.row(align=True)
row.alert = settings.is_dirty
operator = 'lighting_overrider.write_apply_json' if settings.is_dirty else 'lighting_overrider.apply_json'
icon = 'TEMP' if settings.is_dirty else 'PLAY'
row.operator(operator, icon=icon)
return
classes = [
LOR_OT_text_db_add,
LOR_OT_toggle_enabled,
LOR_PT_lighting_overrider_panel,
]
def register():
for c in classes:
bpy.utils.register_class(c)
bpy.app.handlers.load_post.append(init_on_load)
bpy.app.handlers.save_pre.append(store_ref_on_save)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
bpy.app.handlers.load_post.remove(init_on_load)
bpy.app.handlers.save_pre.remove(store_ref_on_save)
#if __name__ == "__main__":
# register()
+198
View File
@@ -0,0 +1,198 @@
# SPDX-FileCopyrightText: 2025 Blender Studio Tools Authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
import os
import bpy
from pathlib import Path
def executions_script_source_exists(context):
meta_settings = context.scene.LOR_Settings
path = meta_settings.execution_script_source
path = bpy.path.abspath(path)
return os.path.isfile(path)
def find_execution_script():
execution_script = bpy.data.texts.get('LOR_execution_script.py')
return execution_script
def find_settings(context):
meta_settings = getattr(context.scene, 'LOR_Settings')
if not meta_settings:
return None, None
sequence_name = meta_settings.sequence_settings.name
shot_name = meta_settings.shot_settings.name
try:
sequence_settings_db = context.scene['LOR_sequence_settings']
except:
sequence_settings_db = None
try:
shot_settings_db = context.scene['LOR_shot_settings']
except:
shot_settings_db = None
if not sequence_settings_db:
sequence_settings_db = bpy.data.texts.get(f'{sequence_name}.settings.json')
if not shot_settings_db:
shot_settings_db = bpy.data.texts.get(f'{shot_name}.settings.json')
if not sequence_settings_db:
filepath = Path(bpy.context.blend_data.filepath)
path = filepath.parents[1].as_posix()+f'/{sequence_name}.settings.json'
if not os.path.isfile(path):
open(path, 'a').close()
bpy.ops.text.open(filepath=bpy.path.relpath(path))
if not shot_settings_db:
shot_settings_db = bpy.data.texts.new(f'{shot_name}.settings.json')
return sequence_settings_db, shot_settings_db
def get_settings(meta_settings):
''' Returns the currently active settings group.
'''
if meta_settings.settings_toggle == 'SHOT':
settings = meta_settings.shot_settings
elif meta_settings.settings_toggle == 'SEQUENCE':
settings = meta_settings.sequence_settings
return settings
def mark_dirty(self, context):
meta_settings = context.scene.LOR_Settings
settings = get_settings(meta_settings)
if settings.is_dirty:
return
settings.is_dirty = True
return
def reload_libraries():
for lib in bpy.data.libraries:
lib.reload()
return
def reload_settings(context):#TODO find a way to run this on load_post handler
meta_settings = context.scene.LOR_Settings
for settings in [meta_settings.sequence_settings, meta_settings.shot_settings]:
if not settings.text_datablock:
continue
if settings.text_datablock.is_in_memory:
continue
override = context.copy()
if not override['area']:
return
area_type = override['area'].type
override['area'].type = 'TEXT_EDITOR'
override['edit_text'] = settings.text_datablock
bpy.ops.text.reload(override)
override['area'].type = area_type
return
def get_instances_across_all_libraries(name, path) -> list:#TODO
return
def kick_evaluation(objects=None):
if not objects:
objects = bpy.data.objects
for ob in objects:
ob.update_tag()
return
def split_by_suffix(list, sfx):
with_suffix = [name[:-len(sfx)] for name in list if name.endswith(sfx)]
without_suffix = [name for name in list if not name.endswith(sfx)]
return without_suffix, with_suffix
def parse_rna_path_to_elements(rna_path, delimiter='.'):
''' Returns the element strings of an RNA path split by '.' delimiter, disregarding any delimiter in a string within the path.
'''
if not delimiter in rna_path:
return [rna_path]
parse = rna_path
# replace escape chars with whitespaces
parse_elements = parse.split(r'\\')
parse = ' '.join(parse_elements)
parse_elements = parse.split('\\')
parse = parse_elements[0]
for el in parse_elements[1:]:
parse += ' '
parse += el[1:]
# replace strings within path with whitespaces
parse_elements = parse.split('"')
parse = parse_elements[0]
for el1, el2 in zip(parse_elements[1::2], parse_elements[2::2]):
parse += '"'+' '*len(el1)+'"'
parse += el2
parse_elements = parse.split(delimiter)
elements = []
for el in parse_elements:
elements += [rna_path[:len(el)]]
rna_path = rna_path[len(el)+len(delimiter):]
return elements
def parse_rna_path_for_custom_property(rna_path):
''' Returns the rna path of the datablock and the name of the custom property for an rna path that describes a custom property.
'''
if not '][' in rna_path:
return False
parse_elements = parse_rna_path_to_elements(rna_path, delimiter='][')
return parse_elements[0]+']', '"'.join(parse_elements[1].split('"')[1:-1])
def mute_fcurve(db, path):
if not db.animation_data:
return
if not db.animation_data.action:
return
fcurve = db.animation_data.action.fcurves.find(path)
c = 0
while fcurve or c<=4:
if fcurve:
fcurve.mute = True
c += 1
fcurve = db.animation_data.action.fcurves.find(path, index=c)
return
def mute_driver(db, path):
if not db.animation_data:
return
if not db.animation_data.drivers:
return
driver = db.animation_data.drivers.find(path)
c = 0
while driver or c<=4:
if driver:
driver.mute = True
c += 1
driver = db.animation_data.drivers.find(path, index=c)
return
def mute_animation_on_rna_path(rna_path):
path_elements = parse_rna_path_to_elements(rna_path)
db_path = '.'.join(path_elements[:3])
if 'session_uid' in dir(eval(db_path)):
data_block = eval(db_path)
path = '.'.join(path_elements[3:])
else: # handle custom props
db_path, c_prop = parse_rna_path_for_custom_property(rna_path)
data_block = eval(db_path)
path = f'["{c_prop}"]'
if data_block.id_type in ['ACTION', 'BRUSH', 'COLLECTION', 'IMAGE', 'LIBRARY', 'PALETTE', 'PAINTCURVE', 'SCREEN', 'TEXT', 'WINDOWMANAGER', 'WORKSPACE']:
return
mute_fcurve(data_block, path)
mute_driver(data_block, path)
return