Previously, there was a `StringRef.copy` method which would copy the string into
the given buffer. However, it was not defined for the case when the buffer was
too small. It moved the responsibility of making sure the buffer is large enough
to the caller.
Unfortunately, in practice that easily hides bugs in builds without asserts
which don't come up in testing much. Now, the method is replaced with
`StringRef.copy_utf8_truncated` which has much more well defined semantics and
also makes sure that the string remains valid utf-8.
This also renames `unsafe_copy` to `copy_unsafe` to make the naming more similar
to `copy_utf8_truncated`.
Pull Request: https://projects.blender.org/blender/blender/pulls/133677
If the parent editbone is hidden, it will (rightfully) not be taken into
account in `createTransArmatureVerts`.
In `recalcData_edit_armature` though, there was the assumption in a
particular code path that "this bone has a parent tip that has been
moved" even though it wasnt (because it was hidden -- see above).
To resolve, guard this code path with a `EBONE_VISIBLE` check.
Pull Request: https://projects.blender.org/blender/blender/pulls/133707
This commit moves the Convert World Material checkbox under Materials to
a World Dome Light option "under" Lights. Based on feedback this is more
intuitive for artists. Previously artists would try unchecking "Lights"
and be confused why a DomeLight would still be in their scene.
This is only a UI layout change, API remains unchanged.
Authored by Apple
Co-authored-by: Dhruv Govil <dgovil2@apple.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/131829
Move 3D viewport bounds calculation out of the operator callbacks
into utility functions, needed for !129594.
Some minor renaming:
- `ok` -> `changed`.
- `ok_dist` -> `do_zoom`.
When performing a transform operation that drags or tweaks, do not show
the Cancel or Confirm keymap item on the Status Bar if they use the
same mouse button that initiated the operation. For example if you are
RCS and are tweaking an object, don't show Cancel on status bar since
that requires right click. If LCS then don't show Confirm (requires
left click) when tweaking, dragging gizmo parts, etc.
Pull Request: https://projects.blender.org/blender/blender/pulls/131336
ANIM_bone_is_visible_editbone was being used in situations where the
intention is to check if the bone is visible to the user.
In this case, EBONE_VISIBLE makes more sense as it also accounts
for hidden bones too.
This was caused by using the same factor as in dithered.
But dithered already has the transparency applied from
the dithered transparency. The transparency needs to be
applied to holdout in forward.
Remove the need for a temporary array of colors.
Just put the data directly into the translations vector.
This should provide a small performance improvement.
This updates the Move Channels operator in the Action Editor channel list to
also work with Slots, allowing Slots to be reordered within an Action.
Note that the Move Channels operator already had interesting behavior when
channels are selected in multiple levels of the channel hierarchy (e.g. when
both channel groups and f-curve channels are selected). For Slots, I've chosen
a simpler behavior: if any Slot is moved, all non-Slot channels (i.e. those
lower in the hierarchy) are left alone.
In the future we may want to change channel group rearrangement to work the same
way with respect to f-curve channels, but I've left that alone for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/133328
Refactored USD instancing export to support instanceable references.
With this change, it's now possible to instance object hierarchies and
geometry types other than meshes (e.g., curves, point clouds, etc.).
No longer marking mesh prims as instances in
USDGenericMeshWriter::write_mesh().
USDTransformWriter::do_write() now marks the Xform as instanceable
with a reference to the prototype's Xform when the Blender object is
an instance.
In USDAbstractWriter::mark_as_instance() the target prim is now marked
as instanceable.
Added AbstractHierarchyIterator virtual functions include_data_writers()
and include_child_writers() to allow pruning children of instanceable Xforms
in AbstractHierarchyIterator::make_writers(). These functions return true
in the base class implementation, so that the iterator behavior for Alembic
exports is unaffected. In the USDHierarchyIterator subclass, these functions
are overridden to return false if instancing is enabled and the objects are
instances.
Added virtual function AbstractHierarchyIterator::should_determine_duplication_references()
which returns true if duplication references should be resolved for children
of a given context. This function is overridden in USDHierarchyIterator to
skip processing children of instances, which is more efficient for USD export,
since children of instances are pruned during traversal for writing. For nested
instances where the original prototype is not included in the export, this also
avoids designating a duplicated object parented to an instance as "the original",
which would cause USD errors since defining a prim under an instance
proxy is not allowed.
Extended logic in `AbstractHierarchyIterator::determine_duplication_references()`
to identify prototypes.
Added new function `HierarchyContext::is_prototype()`.
Disallowing merging with parent for instances and prototypes, since
the Xforms cannot be discarded in those cases.
Extended `USDWriterAbstract::ensure_usd_material()` with special logic
to ensure materials for prototype prims are defined in the subtree of the
prototype. This helps ensure the hierarchical encapsulation requirement
for prototypes and is required by certain renderers (e.g., Houdini's Karma)
for instance materials to render.
Added a new `process_scene_graph_instances()` function to ensure
prototypes are exported as abstract prims.
Added python tests test_export_native_instancing_true and
test_export_native_instancing_false.
Pull Request: https://projects.blender.org/blender/blender/pulls/131707
The issue was that the function that computes the maximum used material index
did not take the edit mesh into account yet. This led the drawing code to
believe that only the first material is used by the mesh.
Pull Request: https://projects.blender.org/blender/blender/pulls/133711
This patch allows the multi-function procedure pixel operation to
operate on single values. While it previously assumes a 1x1 image for
processing which was later reduced to a single value using input
processors. This is more efficient, but will allow us to use
multi-function procedures for single value sub-trees even in GPU
execution.
This patch adds a none-const variant of the get_single_value method and
use that in the set_single_value method, which will reduce code
duplication. This is also needed for a future change.
The Translate node is a transform operation that should not realize the
transformations of its input. So this patch marks its input accordingly.
Additionally, we also protect against operating on single values and
pass them without changes.
Precision in knife operations is greatly impacted when projecting a 3D
coordinate to 2D in screen space.
This happened for example when performing constraint operations, where
only the mval of the constrained position was used for snapping.
To solve this problem, the constrained position is now used to
calculate the ray_orig and ray_dir used in snap operations.
Now, a ray_orig and ray_dir are calculated whenever an mval is
set and can be adjusted later when setting a constraint.
Ref !131764
In NDOF's turntable mode, direction of rotating around Z axis should be
inverted when the view is "upside-down".
Co-authored-by: Kamil Galik <kgalik@3dconnexion.com>
Ref: !129970
This PR explicitly declares integer type for `image_center_offs`, which
formalizes accidentally implemented correct behavior. Previously type
was float, all rhs types in expression were integers, so result was int
cast to float.
Comment is also added clarifying why integer must be used - float may
cause images to be interpolated, even when translation is set to 0.
There should be no functional changes.
Pull Request: https://projects.blender.org/blender/blender/pulls/133573
After drop to scene operation, notifiers are sent to redraw the tree but
it uses the old tree hierarchy. `RGN_DRAW_NO_REBUILD` flag prevented the
tree rebuilding in `outliner_build_tree`. To clear the flag, call
region_redraw function inside `scene_drop_invoke()`.
Pull Request: https://projects.blender.org/blender/blender/pulls/133253
In the theme settings for the user interface, there was a option to
change the outline color of pulldown menus (E.g. the buttons at the top
of the 3D viewport) when the button was selected.
However this color wasn't used. This commit aims to fix that
by using the selected outline color for the outline of selected
pulldown buttons.
Pull Request: https://projects.blender.org/blender/blender/pulls/133470
Since one user-defined conversion operator is allowed during implicit conversion,
and after this conversion here is a constructor which can accept result
of conversion, there was a backdoor for a vector types to up-cast their
dimensions via cast to pointer type of a component of a vector. Since it was
implicit and non-intentional it led to buffer overflows.
Pull Request: https://projects.blender.org/blender/blender/pulls/132927
This adds a debugging utility for developers that makes it easier to what's
stored in a .blend file. Some possible use cases:
* Figure out if some specific data has been written to the .blend file.
* Check the order of data in the .blend file.
* Work towards having less runtime dependent changes in .blend files (it's
easier to diff the textual output).
It is **not** a goal to provide a general human and machine readable form of
.blend files (like xml/json files). That would be way more involved.
The way to use this is to set `GENERATE_DEBUG_BLEND_FILE` to `1` at the top of
`writefile.cc`. Then, whenever Blender saves a .blend file, it will generate a
`.debug.txt` file next to it.
There is already `blend2json.py` which serves a similar purpose but is a
separate program that can be executed on the .blend file afterwards. With the
`--full-data` flag it outputs comparable data, but the output is a bit more
verbose and it needs an extra step that can be avoided by generating the
`.debug.txt` file immediately. For certain use cases,
`GENERATE_DEBUG_BLEND_FILE` can be more convenient. It's also much simpler to
add log additional data in that file that is produced during the blend-write
process.
Pull Request: https://projects.blender.org/blender/blender/pulls/133063
When assigning an Action to an ID, a slot can be automatically
assigned as well. This behaviour is now extended by making untyped
slot identifiers (like `XXSlot`) act as wildcards.
If the last-used slot identifier was 'untyped' (like `XXSlot`), and a
slot with the same name that is specific to the animated ID's type
exists, that slot will be chosen.
Similarly, if the last-used slot identifier was 'typed' (like
`OBSlot`), a slot `OBSlot` does NOT exist, but an untyped slot with
the same name exists (like `XXSlot`), that one will be chosen.
If there is any ambiguity in the matter, the more specific slot is
chosen. In other words, in this case:
- last_slot_identifier = `XXSlot`
- both `XXSlot` and `OBSlot` exist on the Action (where `OB`
represents the ID type of `animated_id`).
the `OBSlot` should be chosen. This means that `XXSlot` NOT being
auto-assigned if there is an alternative. Since untyped slots are
bound on assignment, this design keeps the Action as-is, which means
that the `XXSlot` remains untyped and thus the user is free to assign
this to another ID type if desired.
Pull Request: https://projects.blender.org/blender/blender/pulls/133653
When an action slot does not have an ID type, and it is assigned to some
ID, the slot is bound to that ID's type. This now no longer happens when
the Action is linked, because linked data should not be modified.
Pull Request: https://projects.blender.org/blender/blender/pulls/133670