This idea is borrowed from the multires modifier, which already
checked if the object was in sculpt mode and, if so, created the
PBVH. That check is now moved higher up the chain into
mesh_build_data(), so that it occurs for CDDerivedMesh too.
This also replaces an assert in cdDM_getPBVH for tesselated mesh faces
with a call to create them if missing.
Vector.angle_signed(other)
for 2D vectors to get the clockwise angle between them.
in BLI math its called - angle_signed_v2v2()
shorthand for...
atan2f((v1[1] * v2[0]) - (v1[0] * v2[1]), dot_v2v2(v1, v2))
also corrects compile error in last commit.
Fix this by storing if the border is set - before this was only done for the window dimensions.
also move these variables into a static struct so this logic is easier to follow.
the problem was numeric precision when in ortho mode the start/end points for the view vector would be 2000 apart which caused trouble for the intersection test.
No functional changes, this is just a bit easier to read I think (and
nicer if we add more PBVH types in the future, e.g. for dynamic
topology sculpting.)
Renamed the multiresModifier_update() function to
multires_modifier_update_mdisps() and made it visible to subsurf_ccg.c
so it can be called directly. No functional change, just a bit simpler.
problem was bow-tie quads would add opposite normals together and result in zero vector which was used for projection.
Now is_quad_convex_v3() checks if quad contains 2 faces which point away from eachother when split by either direction.
Theres another fix for this bug which can be done since creating the face can use existing edges in the example given so it wont have to guess which order of verts to use.
Update handles positions after applying modifiers which seems to be expected behavior.
The only currently unsolved issue is about updating aligned handles because this needs
to determine in which order handles need to be recalculated which currently depends on
selection flags and which is quite tricky to do when running modifiers and animation data,
so currently just not update their positions for now.
Was missed check for if modifier is available for particular object type
which ended up with unpredictable results when modifier which isn't supported
yet for some object type as linked to that object type.
This is in preparation for bug fixing and cleanup related to tracking
of bmface and is_space state variables. And makes it more likely
to avoid bugs in future where some part of state is copied but not all.
Sometimes split would fail to make a face - make sure it doesn't
crash if that happens.
Chain finding code for holes would sometimes go back to same
vertex on the face, which causes problems, so fixe that.
Also, disallowed a cut that starts at a vertex or edge and
cycles back to that same point in a face - this would make
a face with a repeated vertex, which may not be handled by
the rest of the system properly.
- edgebisect bmesh operator used uninialized beauty field.
- BLI_join_dirfile could read from before the string bounds when passed an empty dir string.
- pransform could use an uninitialized projected coordinate (unlikely but possible)
- RNA_property_path_from_ID_check would compare against an uninitialized pointer when the path wasn't found.
also have bmesh walker use BM_edge_other_vert() utility function.
- moved mesh conversion functions into their own file.
bmesh py api:
- can now create a new empty bmesh without first creating mesh data.
- added function to copy bmesh data back to a mesh.
- bmesh.from_mesh() can now get a mesh which isnt in editmode.
World Context:
* Made world id block wider
* Don't show texture user when Cycles engine is used
Other:
* Change Dopesheet > DopeSheet in User Preferences Theme section for consistency.
This is called when adding a multiries modifier. BMesh MDisps have
only one loop's displacements rather than a full face's, so don't
multiply by number of corners here.
- BM_mesh_normals_update was looping over all faces to find the largest one, this is no longer needed.
- calculating a face normal was looping over every faces corners twice, now only once - using the loops directly (not an iterator).
- face vert locations were being copied an array, now use directly.
- calculating the normals would copy a float vector for the next point in the face, which was never used (only current and previous used).
- was copying vectors to compute the normal, now just assign the float pointers.
These changes originated in r35321, which transfered MDisps to a
different memory allocator; this is no long used, however, so
post-merge it was just making an identical copy.
it's user count on free. That's how other spaces handles ID block (like
image editor, space clip).
This fixes issue when loading file without loading UI when current layout
has got background images set.
Also this hopefully will fix issue #30429: Background Images Lost on Save/Close/Reload
(median point was sliding a bit from it's original position)
This happens because of how transformation for stabilization calculates:
image is scaling around it's center, so image translation should be recalculated
after scale was changed, but scale also depends on translation. That's where
tricky things happens. It's still not ideal for case of rotation, but before
fixing this issue better to figure out usecase and see if it's indeed
so needed to scale around image center (it might only be helpful to use
stabilization parameters in compositor nodes).
Applied the keymaps hack which is used for other animation editors to allow
markers to be added and renamed anywhere from within the sequencer strips
region, instead of just when the cursor is over the scrollbar.
Other operations where the hotkeys conflict though (delete, move) can still be
done only from the scrollbar, or better still, from the Timeline.
Socket selection is indicated by a simple white highlight circle.
Multiple inputs can be selected by holding SHIFTKEY (just like regular node select). Only one output socket can be selected at a time for each node, but several outputs in different nodes are allowed.
The auto-connect operator will prefer selected sockets on nodes for creating links. If either the output or input side have no selected sockets it will fall back to the previous behavior of chosing 'best' sockets first (colors, then vectors, then values). This could be improved in the future, but is out of scope here.
- Ron aspect ratio correction after applying location
There're still some annoynments with rotation stabilization with
pixel aspect != 1, will be fixed later.
- Joining tracks will update track used for rotation stabilization/
All multires grids have exactly the same ordering, so rather than
allocate a new index buffer for each PBVH node, just allocate one that
can be reused for every grid.
This requires more draw calls (one per grid rather than one per PBVH
node), but less graphics memory.
this fixes but [#30461] where the same vertex was added to some faces twice.
Previous code rebuilt all faces around the split edges, replace this with much simpler code that uses existing bmesh API for splitting.
This also gives a performance boost to the modifier (over 30x faster in the bug-report file).
* C: BM_vert_separate(...)
* py: bmesh.utils.vert_separate(vert, edges)
This splits off regions around the vertex, splitting on connected edges passed in a sequence.
also made minor changes
- rename python api functions _rip to _separate
- fixed bmesh iterator being iterable its self (some parts of python expect this)
- fix memory leak in bmesh python api.
existing "Equirectangular". This projection is useful to create light probes
from a chrome ball placed in a real scene. It expects as input a photograph of
the chrome ball, cropped so the ball just fits inside the image boundaries.
Example setup with panorama camera and mixing two (poor quality) photographs
from different viewpoints to avoid stretching and hide the photographer:
http://www.pasteall.org/pic/28036
*Add a new idname to keyingsets, keeping name as label-only (using same string for both made lookup fail when using i18n other than english, as it tried to compare an untranslated static string id against a translated RNA name). Also adding a description string (can be helpful with custom keyingsets, imho).
*Fixed a few other bugs related to that area (namely, you can’t deselect current keyingset from the shift-ctrl-alt-I popup menu, and insert/delete key ops were using a rather strange way to get chosen custom keyingset…).
*Fixed UI code so that it always uses (RNA) enum, and simplified menu-creation code.
Issue was caused by precision errors with floats.
Made internal grid drawing stuff using doubles and also added some
functions to multiply double vector by float matrix which also makes
all intermediate calculation in doubles.
This corresponds to the more usual convention.
There was no key connected to Cancel, and we already
have Return, Numpad-Return, and Right-click for confirm.
incorrectly
When the current frame occurs outside the current visible range a given motion
path, the point lookup was seeking past the ends of the path's point cache,
causing sporadic flickering of current frame indicator at 0,0,0.
Internally vector and waveform opacities are stored as float in 0..1 range
and the same range is exposed to the UI.
From file compatibility POV decided to change prop's type from percentage
to factor so it'll be nice slider with 0..1 range without confusing percentage
symbols (which should be quite easy to follow) and both forward and backwards
compatibilities are here.
The DMSetDrawOptions[Tex] callbacks return 0 (skip), 1 (draw), or 2
(either stipple or skip mcols.) In the CDDM, EDDM, and CCGDM draw
functions, as well as the callbacks in drawmesh/drawobject, replace
these numbers with values from an enum, DMDrawOptions.
- access to a meshs editmesh before the pointer was checked to be a mesh.
- uninitialized memory use in transform (not a problem practically but nice to quiet the error in valgrind).
add the function to create new UV layers, this only works when there are no polygon layers already created (to prevent confusion since scripts with polygon layers should be adding MTexPoly and MLoopUV layers)
Issue was caused by missing fdata for meshes which doesn't have tessellated
faces yet. Real fix would be to use loop's MLOOPUV layer, but currently interface
is using mtex layer names for UV lists so use poly's mtex layer to check if
layer name is indeed correct.
Should work fine until we'll separate setting textures and UV coordinates.
from Dan Eicher (dna)
--- from the tracker
Setting Screen.scene only uses the active screen through a call to CTX_wm_screen(C) instead of the actual referenced scene.
The attached py-op demonstrates this behavior, assuming at least two separate scenes in the VSE.
Knifetool accumulates a bunch of proposed cuts and when the user
confirms, it makes them all. The old code did this by using scanfill
to triangulate the cutting edges in their faces, and then merging
triangles where possible. This sometimes ended up with strange
lost faces, and also made it so that when holes were cut, the
surrounding face ended up totally triangulated. But 29908 was
an example of a lost face.
This new code directly finds chains of cutting edges that go from
one side of a face to the other and using BM_edge_split_n to make
the cuts. Holes are handled by finding two good places where
the hole can be connected to the containing face (using two
because I think some other code in bmesh assumes that there are
no edges that appear twice in a face).
The old code is still there with #if SCANFILL_CUTS, so can easily revert
if this proves to be a bad idea.
Also, a small fix to previously added BM_split_n (forgot to
copy face attributes to new face).
now theres always a single step before skipping delimiters, this means the skipping actions always advance by more then 1 char (which matches the text editor).
This function pointer's 'setDrawOptions' parameter took a slightly
different type than the other drawing callbacks. In particular, it
could set a 'drawSmooth' value to indicate that smoothing should
always be enabled, overriding the face flag. However, all callbacks
either did not set this value, or set it unconditionally to
1. Replaced this by adding a new 'flag' parameter to drawFacesMapped,
which can be set to DM_DRAW_ALWAYS_SMOOTH where appropriate.
Also removed the 'useColors' parameter and replaced it with another
flag value, DM_DRAW_USE_COLORS.
Removed the 'wpaint__setSolidDrawOptions' callback, was only being
used to set the shading to smooth.
Node updates should generally be local by design, i.e. changes should not depend on any of the other nodes in the same tree. The original purpose of the dependency sort was to allow some experimental nodes to update their socket types based on upstream connected nodes, but these have been removed long ago. If such features need to be implemented they should instead use the tree-wide update callback, which is called after all the local node updates are done.
Removing the extra allocation and recursive function calls from most updates will ensure this function stays as fast as possible and can be called during node space context updates (snode_set_context), which are done very frequently (redraw).
and 5 float image textures. For CPU render this limit will be lifted later
on with image cache support. Patch by Mike Farnsworth.
Also changed color space option in image/environment texture node, to show
options Color and Non-Color Data, instead of sRGB and Linear, this is more
descriptive, and it was not really correct to equate Non-Color Data with
Linear.
"This patch adds "Not Equal To" to the list of options for selecting faces based on the number of vertices. While the equivalent can indeed be achieved by using "Equal To" and invert selection, having this option allows for a smoother work-flow when adjusting the number of vertices to be compared."
turns out old code also had the same bug (just coincidance it was noticed after my change)
now boundry verts are tagged so edges connected to them are not seen is missing a tagged, adjacent edge.
this fixes [#30471]
when the source and destination vectors were the same pointer, the X value would get overwritten.
now the rip tool uses the best side to grab as in trunk.
It's currently not respecting the material color, probably since the
BMesh merge. There are a couple problems, both involving "dummy"
variables taking the place of actual MTFace/MCol data.
Code review: http://codereview.appspot.com/5753050/
Now create the rotate edge in advance and copy its customdata (before joining the faces).
This commit also fixes an annoyance where tryangulating faces could create duplicate edges.
Issue was caused by incorrect resetting of tesselated fave data in copy_mesh:
- CustomData_free will free data from original mesh because layers in new mesh
are pointing to the same memory just after copy. So it's needed only to
set some pointers to NULL.
- It was incorrect filling fdata with zeroes because of incorrect structure size used.
Seems that issue is caused by several threads accessing to movie clip and one
of the threads (compositor node) was editing ImBuf which isn't nice anyway.
Made Set Floor a bit more general and name it Set Plane which defines
orientation from 3 selected tracks and makes them belong to specified
plane (wall or floor).
Previously, the shading and material was set once per PBVHNode when
drawing. This is still the case, but PBVHNodes are now built to
contain only one material and shading mode.
This is done with an extra partitioning step; once the number of
primitives in the node falls below the PBVH leaf limit, it's
primitives are checked for matching materials. If more than one
material or shading mode is present in the node, it is split and
partitioned (partitioned by material rather than 3D location.)
Given a sufficiently 'annoying' input, like a dense mesh with
thousands of materials randomly scattered across it, this could
greatly increase PBVH build time (since nodes might end up containing
a single primitive), but in general this shouldn't come up.
In order to support materials for grids, the CCGDM is building another
grid array (of DMFaceMat structs). This could be used to replace
CCGDM.faceFlag for some small memory savings (TODO).
Previously this was just a character array that stored face/poly flags
and mat_nr. Since mat_nr should be a short, this would have truncated
for higher values.
Replaced with a new DMFaceFlags struct.
This option might be useful in some cases like keeping UV coordinated in kind of
"correct" state so sliding edge loop will also slide edges in UV. But for other
layers like shapekeys and vertex colors it's arguable it's actually needed.
The way it's currently done isn't actually acceptable because it doesn't take
flags like UVCALC_TRANSFORM_CORRECT into account and also makes extra unwanted
things like interpolating shapekeys which leads to propagating changes into
basis keys and also results with slide applied twice for relative keys because
offset is also applying on loading edit mesh.
Also discussed with Brecht who agreed with marking this things as TODO and
disabling for now.
This should fix issue reported in #30387: Edge Slide propogates to Basis Shape Key
[#30454] perspective_matrix not update in real time with bpy.ops.view3d.zoom
This is so you can modifify the view settings and get the view matrix after without waiting for a redraw.
mesh.calc_normals() wasnt calculating vertex normals (only face normals),
now only calculate vertex normals.
added a define incase we want to have poly normals back again.
On a user level, edge rotate now works better with multiple edges selected, it wont make zero area faces or rotate edges into existing ones.
With a single edge selected - rotate is less strict and will allow ugly resulting faces but still checks on duplicate edges.
API:
* BM_edge_rotate now takes a flag, to optionally...
** check for existing edge
** splice edge (rotate and merge)
** check for degenerate resulting faces (overlapping geometry, zero area)
** beauty - only rotate to a better fit.
... this allows it to still be used as a low level API function since all checks can be skipped.
* BM_edge_rotate() now works a bit different, it find the new edge rotation before joining the faces - exposed by BM_edge_rotate_calc().
* Added api call bmesh_radial_faceloop_find_vert() - Radial Find a Vertex Loop in Face
* optimize BM_face_other_edge_loop to do about half as many iterations for quad heavy meshes, with ngons the gain is much more since searching around the entire ngon when the edge already stores its loop is silly.
... also nicer in cases where edge has no face users it avoids a loop on all face corners.
Do not crash when joint SIDs cannot be resolved.
OpenCOLLADA cannot resolve joint SIDs connected to skin if the <skeleton> tag is missing.
Page 148 of COLLADA spec 1.4.1 states: "<skeleton> elements define where to start the sid lookup". So I think this is a bug in "FBX COLLADA exporter" which did not add the <skeleton> tag.
The problem can be fixed by manually adding the <skeleton> tag into <instance_controller>.
we cant ensure buildinfo to have utf8 encoding so access it as bytes via python - a different workaround then this patch made.
also use C style string formatting for sys_info.py
* calculate vertex normals (previously was calculating face normals only)
* clear tessfaces unless theres an argument to build them. since no tessfaces is the default state right now.
* if convert_mfaces_to_mpolys() runs, dont calculate edges, since it already does that.
* add BLI_rfindlink for reverse index lookup (used so bm.select_history[-1] doesn't have to loop the entire list twice).
* add bm.select_history.active so you can get the last selected item or None without having to check seq length.
In fact, most "UI special cases" are not well translated, currently. :/ This affects especially the "Properties" panels. This commit should address problems in Graph editors, and 3D View (but probably not yet all of them). Yet it already adds more than 100 new messages (and fixes translated drawing of more).
Also done some style edits…
* improve check to see if edge rotate can be done,
was checking if both edges verts have an edge count of 2, which is really a meaningless test since the verts can have stray edges connected and the result wont work right.
instead check if the next verts in both faces share a vertex.
* add utility function BM_face_other_vert_loop() which gets the next loop in a face.
* add convenience function BM_edge_face_pair() which returns 2 faces for edges that have exactly 2 face users. (saves ugly e->l->radial_next ... in code) and is more readable.
Also adds DampedTrackTo to the list of supported constraints in the BGE
Test file:
http://www.pasteall.org/blend/11715
Patch developed as part of a project to NF-UBC Nereus Program.
Development time 'sponsored' by the project.
www.nereusprogram.org
if blender freed the BMesh before python was finished (on exit editmode for eg), python would attempt to access the bmesh to clear python pointers in it.
- spelling - turns out we had tessellation spelt wrong all over.
- use \directive for doxy (not @directive)
- remove BLI_sparsemap.h - was from bmesh merge IIRC but entire file commented and not used.
* dont check selection and hiddent state (select + hide isnt allowed and api ensures this)
* MESH_OT_noise had incorrect check for texture (checked if slot [0] was filled but then used active texture)
In fact, the same bug affected curves' weights too. Now using the same method as for setting mesh edges' crease and bevel weights. Also factorized/simplified that part of code by defining a new utility func computing the scale factor.
Also greatly simplified UI code in same v3d_editvertex_buts() function, was really over-complicated (this fixes btw a few minor UI bugs in the transform editmode panel, like missing tips, etc.).
* double default edge allocation size (double the number of verts/faces).
* CustomData_bmesh_init_pool was using allocsize & chunksize as the same variable. Now use type specific chunk size.
* bmesh copy and editmode conversion now allocate the BMesh mempool size needed for the entire vert/edge/loop/face arrays since its known already.
* name bmesh operator func's BMO_slot_buffer_* rather then BMO_slot_* since it wasnt obvious some only dealt with buffer, some both.
* more typechecks and asserts of BMO_ functions (I lost some time calling a map with a buffer function that failed silently).
* small speedup for extrude check - test if the edge is wire _before_ doign a hash lookup.
Extruding an edge where both verts were clipped would not create a face for this edge.
This is ok when a connected face is also extruded but not when the edge is selected on its own.
* add extra argument to BMO_slot_map_to_flag() to filter by vert/edge/face
* made BMO_slot_map_* / BMO_slot_buffer_* functions stricter with type checking.
* Moved format field and added (deprecated) sfra and efra ints to ensure some forward compatibility of file output node. Earlier blender versions will simple interpret the struct as NodeFileImage, so by matching the first fields the numbers can stay somewhat valid.
1) Old CMP_NODE_OUTPUT_FILE and CMP_NODE_OUTPUT_MULTI_FILE have been merged,
only CMP_NODE_OUTPUT_FILE remains. All functions renamed accordingly.
2) do_versions code for converting single-file output nodes into multi-file
output nodes. If a Z buffer input is used, the node is made into a multilayer
exr with two inputs. (see below). Also re-identifies multi-file output nodes
with the CMP_NODE_OUTPUT_FILE type.
3) "Global" format is stored in node now. By default this overrides any
per-socket settings.
4) Multilayer EXR output implemented. When M.EXR format is selected for node
format, all socket format details are ignored. Socket names are used for layer
names.
5) Input buffer types are used as-is when possible, i.e. stored as B/W, RGB or
RGBA. In regular file output the format dictates the number of actual channels,
so the CompBuf is typechecked to the right type first. For multilayer EXR the
number of channels is more flexible, so an input buffer will store only the
channels it actually uses.
6) The editor socket type is updated from linked sockets as an indicator of the
actual data written to files. This may not be totally accurate for regular file
output though, due to restrictions of format setting.
Issue was caused by fix for slide+automerge bug resulted in accessing to freed memory
from multires projection code. Solved by moving multires projection from cleanup callback
to special_aftertrans_update.
Patch by Antony Riakiotakis with some own corrections.
- Pinch/Magnify brush isn't available from vertex paint mode anymore.
- Switch default texture to Low Quality bump method
The same method is used for new textures and it makes possible to
view bump in 3D viewport with GLSL shading.
- Anisotropic filtering is set to 2x by default.