Commit Graph

31 Commits

Author SHA1 Message Date
74cc3974fe Fix T40405: Blender crashes on FBX export instantly.
Better fix than rBbef5cb3aa2e5a: consider edges between faces with opposed normals as sharp.

In fact, previous code was broken more deeply in this case (inconsistent normals across
a 'smooth fan') - some loop normals would even never be computed!

Fixing this is possible (even wrote it, actually), but this adds more complexity
to a piece of code that is already awfully complicated, *and* normals in that kind
of smooth fan do not make much sense anyway. So simpler and nicer results with
assuming sharp edges between such 'opposed' faces!

Note that there is some face (loop) ordering black magic at work here, added more comments
to try to explain how and why all this works.

As a bonus, we do not need to check for already computed loop normals anymore, since we
know each 'smooth fan' will be walked once, and only once.
2014-05-28 18:55:46 +02:00
bef5cb3aa2 Fix T40405: Blender crashes on FBX export instantly.
This crash can only happen in case faces in same 'smooth fan' have reversed normals.
To support this, we have to always keep a way to get real values in loop_to_poly,
even when loop itself is tagged as done, it might be needed in computation of one of
its neighbor's split normal later.
2014-05-28 13:54:29 +02:00
67f5af0531 Add asserts to BKE_mesh_normals_loop_split 2014-05-28 20:50:05 +10:00
f8278e5479 Correct ARRAY_SIZE macro and make doxy comments consistent 2014-05-19 18:00:20 +10:00
d7d2e71a03 Correct some errors in auto-cleanup 2014-04-27 22:02:59 +10:00
a2c107aef1 Code cleanup: use 'const' for arrays (blenkernel) 2014-04-27 00:25:15 +10:00
a7120b9730 Fix related to new split normals draw code.
Tessellated split normals CDlayer had no swap func, hence ugly little test_index_face()
could not rotate its values correctly when rotating tessellated faces...

Extra-reported in T39735.
2014-04-16 16:54:23 +02:00
28a829893c Math Lib: avoid having to pass a pre-calculated normal tot area_poly_v3
add normal_poly_v3
2014-04-16 00:29:57 +10:00
18e4224142 Split Normals I (1/5): basis for split normals (nearly nothing user-visible here):
* Add a new calcLoopNormals function to DerivedMesh struct, and implement it for CDDM and CCGDM (subsurf).
  EditDerivedBMesh (edit mode DM) only gets a dummy one in this commit.
* Add a tessellated version of CD_LOOPNORMAL layer (CD_TESSLOOPNORMAL), with relevant code to handle it
  (tessellation, rna access, etc.).
* Change auto_smooth options of Mesh (angle now in radian internaly, and toggle is now used to enable/disable
  split normals in DM creation process). Note BI render code is not touched here, hence its behavior regarding
  this option is now incoherent, will be addressed in a separate commit.

Reviewers: campbellbarton

CC: brecht

Differential Revision: https://developer.blender.org/D365
2014-04-13 12:19:00 +02:00
20a4e33837 Code cleanup: use consistent arg order for math api poly funcs 2014-03-27 08:30:14 +11:00
8703e2fe7e Code cleanup: remove unused flags 2014-03-26 07:58:14 +11:00
27e86ed832 Code cleanup: use bools 2014-03-20 22:56:28 +11:00
2097e621ed Code cleanup: use r_ prefix for return args 2014-03-16 03:26:23 +11:00
12348318d1 Fix T38328: GLSL display shows texture mapping completely messed up in some cases
Own stupid typo in rB28ca299d4dfc...
2014-01-23 08:37:07 +01:00
28ca299d4d Fix T38316: Half of a Face is Missing on Newly Created Cubes or Cylinders.
Own bug from rBc691551249f3. Now at least I understand why `test_index_face()` is needed for tessellated quads!

Added a bunch of comments to explain the issue, as it's far from an obvious one...

We loose some performances, but it's still much quicker than org code.
2014-01-22 19:56:21 +01:00
00119e5ac2 Code Cleanup: reduce sign conversion 2014-01-22 02:56:52 +11:00
c691551249 Optimize tessellation code (min 20% better, up to 300% with some CD layers to tessellate).
The main idea is to store (during tessellation) or recreate (during tessdata update) a tessfaceverts-to-loops mapping, and then update all tessdata
in one pass, instead of calling `BKE_mesh_loops_to_mface_corners` repeatedly for all tfaces!

Differential Revision: https://developer.blender.org/D226

Reviewed by Campbell, thanks a lot!
2014-01-21 16:32:47 +01:00
6ba02681de Fix a bunch of UI string issues... 2014-01-15 10:40:54 +01:00
8952f58375 Add tangent space computation/access from RNA (i.e. python).
This simply mimics code used for loopnormals, to enable py scripts to generate and access (temporary)
a tangent 3D vector and bitangent sign for each loop. Together with the split normals, this allow
to recreate a complete tangent space for normal mapping (bitangent = bitangent_sign * cross(normal, tangent)).

Expects all faces to be tri or quads.

Reviewed By: Brecht, campbellbarton

Differential Revision: https://developer.blender.org/D185
2014-01-11 11:51:19 +01:00
e23f77b935 Code Cleanup: move mesh mapping functions into their own file/header 2013-12-12 16:28:52 +11:00
f64ae4cbe5 MemArena: use size_t instead of int for alloc args and internal storage.
also add BLI_memarena_calloc to be used when calloc isnt enabled for the arena.
2013-12-02 17:51:27 +11:00
5da703e915 BMesh/Mesh: replace scanfill with polyfill 2013-11-30 22:13:52 +11:00
3264461598 move bmesh array lookup data and utility functions from editmesh into bmesh,
since enough bmesh operations can also take advantage of direct index lookups on verts/edges/faces.

developers note:
- EDBM_index_arrays_init/ensure/free -> BM_mesh_elem_table_ensure/init/free
- EDBM_vert/edge/face_at_index -> BM_vert/edge/face_at_index
- EDBM_uv_element_map_create/free -> BM_uv_element_map_create/free
- ED_uv_element_get -> BM_uv_element_get
2013-10-28 02:05:33 +00:00
e783611098 Arg! Fix another bug in split normal core algorithm (some flat faces were ignored, depending on the order of evaluation)... :/ 2013-10-19 13:48:51 +00:00
110b32cf6f Fix [#37012] The new export split normal does nor produce correct results.
Was a silly error introduced in algo during optimization, vertices having sharp and smooth edges would only get the first poly's normal for each "smooth loop group".

Also done a (minor) optimization, and some comment fixes.
2013-10-09 17:48:27 +00:00
92d94ccb08 misc minor changes
- make cmake osx use of -ftemplate-depth match scons.
- use array size within sizeof(), more compact.
- replace AT with __func__ where the function is unique enough.
- BLI_box_pack_2D -> 2d to match other functions.
- rename new mesh normal calculation to mesh.calc_normals_split()
2013-09-10 19:23:39 +00:00
4a2f6447ef Core code for split normals computation. Many thanks to ideasman for is optimization guiding and code reviews!
Note the API is not yet committed, as it may need a few more checks & tweaks. ;)
2013-09-10 12:48:08 +00:00
00bd7da674 correct error in recent changes for building with openmp.
rename DM_OMP_LIMIT to BKE_MESH_OMP_LIMIT and set to 0 when in debug mode, same for BM_OMP_LIMIT.
2013-09-09 05:42:26 +00:00
66efedd096 enable strict flags for mesh_evaluate.c 2013-09-09 03:12:23 +00:00
40b6532ec8 remove use of BLI_array in BKE_mesh_mpoly_to_mface(). was over-allocating anyway so just allocate the array once. 2013-09-09 02:16:22 +00:00
2646bbdccb move mesh evaluation functions (normal, mapping, smooth group... etc, calculations) into mesh_evaluate.c.
mesh.c was over 4k lines and complex functions mixed in with general library management.
2013-09-09 02:11:44 +00:00