Commit Graph

308 Commits

Author SHA1 Message Date
Bastien Montagne 3df5625ae7 Cleanup: remove some useless Derivedmesh struct declarations. 2018-06-20 15:17:35 +02:00
Bastien Montagne 204c167c72 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/BKE_mesh.h
	source/blender/blenkernel/intern/mesh_convert.c
	source/blender/editors/interface/interface_eyedropper_color.c
	source/blender/editors/object/object_add.c
	source/blender/editors/space_image/image_ops.c
	source/blender/makesrna/intern/rna_image.c
	source/blender/windowmanager/intern/wm_draw.c
2018-06-11 16:02:46 +02:00
Bastien Montagne 78a8d3685b Cleanup: remove moar ugly G.main usages...
BKE_image was an ugly nest, could fix all but the ones from compositor,
so moved ugly G.main there, at least we know where the Evil is that way ;)
2018-06-11 15:40:37 +02:00
Sybren A. Stüvel 23db3a5ade Renamed BKE_nomain_mesh_xxx → BKE_mesh_nomain_xxx
This maintains the `BKE_mesh_` prefix for the mesh-related BKE functions.
2018-06-06 10:30:24 +02:00
Sybren A. Stüvel 5f543915e8 Modifiers: ported curve_calc_modifiers_post() internals from DerivedMesh → Mesh
The function still returns a DerivedMesh, but internally it uses Mesh
now.
2018-06-06 10:11:31 +02:00
Sybren A. Stüvel a9ed50514c Moved function declarations from BKE_mesh.h → BKE_mesh_runtime.h 2018-06-05 16:59:18 +02:00
Sybren A. Stüvel c0dd355926 Modifiers: ported applying modifier from DerivedMesh → Mesh 2018-06-01 17:35:26 +02:00
Campbell Barton be8016908d Mesh: Replace DM for mesh -> curve conversion 2018-06-01 14:01:44 +02:00
Brecht Van Lommel cce16df10f Fix Cycles viewport render stuck with curve objects.
We should solve this better by making the depsgraph convert all curves to
meshes, for now ensure we don't to depsgraph tags during export.
2018-05-30 18:17:49 +02:00
Bastien Montagne 8f670dd855 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/BKE_material.h
	source/blender/blenkernel/BKE_mesh.h
	source/blender/blenkernel/intern/library_remap.c
	source/blender/blenkernel/intern/material.c
	source/blender/editors/object/object_relations.c
	source/blender/editors/render/render_preview.c
	source/blender/makesrna/intern/rna_object.c
2018-05-29 16:02:53 +02:00
Bastien Montagne f7af08b5fe Cleanup: Get rid of G.main in BKE_material.
Note that in some cases, this only moves the G.main case to somne other
places - in particular, RNA getters/setters are becoming annoying here...
2018-05-29 15:49:21 +02:00
Sybren A. Stüvel a2438373b3 Modifiers: ported Collision DerivedMesh → Mesh 2018-05-17 15:28:51 +02:00
Sybren A. Stüvel def1c3eb4b Particle System: ported most DerivedMesh → Mesh
There are a few places where DerivedMesh is still used, most notably
when calling the (not yet ported) cloth simulation. There is also still
the use of Object.derivedDeform and Object.derivedFinal. Those places are
marked with a TODO.

Some functions in the editors module were copied to accept Mesh. Those
already had 'mesh' in the name; the copies are suffixed with '__real_mesh'
for easy renaming later when the DM-based functionality is removed.
2018-05-16 16:31:38 +02:00
Mai Lavelle fee50f830d Add BKE_mesh_is_valid
Non modifying version of `BKE_mesh_validate`, mirrors `DM_is_valid` more
closely. Will be used in port of `mesh_calc_modifiers`
from `DerivedMesh` to `Mesh`.
2018-05-16 06:07:50 -04:00
Germano 5503e2565b Bmesh: Clear possible geometry saved at runtime when converting bmesh to mesh. 2018-05-11 15:48:14 -03:00
Dalai Felinto 828a3d89b3 Fix T55015: Crash on selection after recent BVH changes
Runtime data should always be initialized to NULL on read-time.
2018-05-09 15:53:16 +02:00
Campbell Barton 305c455ffe Cleanup: mesh_runtime naming
- BKE_mesh_get_looptri_num        -> BKE_mesh_runtime_looptri_len
- BKE_mesh_runtime_recalc_looptri -> BKE_mesh_runtime_looptri_recalc
- BKE_mesh_get_looptri_array      -> BKE_mesh_runtime_looptri_ensure
2018-05-08 19:26:36 +02:00
Campbell Barton 0012082c10 Cleanup: move mesh conversion into own function 2018-05-08 17:54:25 +02:00
Campbell Barton 03dd109a84 Cleanup: consistent BKE_mesh naming 2018-05-08 17:28:43 +02:00
Campbell Barton 00127d03f1 Cleanup: use bool for BKE_mesh_new_from_object 2018-05-08 17:17:40 +02:00
Campbell Barton 7522af49a3 Cleanup: rename variables
DerivedMesh had some odd conventions, remove from BKE_mesh.
2018-05-08 17:15:23 +02:00
Campbell Barton 0e964afaa4 Cleanup: use 'nomain' when not in library data
Rename only.
2018-05-08 17:06:30 +02:00
Campbell Barton fa69ce9e3a Cleanup: whitespace, duplicate includes 2018-05-08 16:57:07 +02:00
Sybren A. Stüvel 1c0be0e90f Ported Mesh Deform modifier
This modifier still has issues that are not related to this port:

- While editing the deformation mesh, the deformed mesh doesn't update.
  This update only happens after exiting edit mode, making editing
  cumbersome.
- Binding doesn't work yet. It works fine when binding in master and
  loading pre-bound in 2.8. This was also an issue before this port, and
  will be investigated separately.
2018-05-08 11:46:28 +02:00
Sybren A. Stüvel abb58eec53 looptri + bvhtree support for Mesh 2018-05-08 11:36:48 +02:00
Bastien Montagne 50e31136fd Rename BKE_bmesh_to_mesh to BKE_bmesh_to_mesh_nomain.
Let's be clear about functions generating datablocks outside of Main
database.
2018-05-08 11:04:20 +02:00
Sybren A. Stüvel cf7c3462ed BKE_mesh_new → BKE_mesh_new_nomain
Including 'nomain' in the name explicitifies that the returned mesh is
NOT stored in any library.
2018-05-08 11:00:34 +02:00
Sybren A. Stüvel 66b1cd45fb Added BKE_mesh_ensure_normals()
This calls BKE_mesh_calc_normals() only if the mesh vertex normals are
marked as dirty.
2018-05-08 10:47:00 +02:00
Sybren A. Stüvel 42dfbf79c3 Added BKE_mesh_new()
This function creates a Mesh struct with a number of vertices/edges/etc.
It allocates the minimal number of CD layers needed.

Currently not yet used, but will be soon in the upcoming
BKE_new_mesh_from_curve_displist().
2018-05-08 10:47:00 +02:00
Sybren A. Stüvel 3f2f27642e Renamed 1st parameter of BKE_bmesh_to_mesh from `me` to `be`
It's a BMesh, it shouldn't be called `me`
2018-05-02 16:39:22 +02:00
Sybren A. Stüvel 81175eb40d Modifiers: ported Bevel modifier DerivedMesh → Mesh
This introduces `BKE_mesh_to_bmesh_ex()`, which exposes all of the
`BMeshFromMeshParams` parameters to the caller. This is required to enable
the `calc_face_normal` flag, which is required for the Bevel modifier.

This also introduces `BKE_bmesh_to_mesh()`, which allocates a new `Mesh`,
converts the `BMesh` to it, and returns it. The returned mesh is owned by
the caller.
2018-05-02 12:15:00 +02:00
Sybren A. Stüvel 4211d02ab5 Modifiers: Mirror DerivedMesh → Mesh 2018-05-01 18:02:17 +02:00
Sybren A. Stüvel 7efc75c709 Modifiers: Simple Deform & Build, DerivedMesh → Mesh
This commit introduces `EditMeshData`. The fields in this struct are
extracted from `EditDerivedBMesh` into their own struct `EditMeshData`,
which can then also be used by the `Mesh` struct. This allows passing
deformed vertices efficiently to the draw routines.

The modifier code constructs a new Mesh instead of writing to ob->data;
even when ob->data is a CoW copy, it can still be used by different
objects and thus shouldn't be modified by a modifier.
2018-05-01 18:02:17 +02:00
Campbell Barton 40f27e520f Fix T54901: Crash renaming UV layer 2018-04-30 21:03:16 +02:00
Brecht Van Lommel 34ab90f546 Depsgraph: remove EvaluationContext, pass Depsgraph instead.
The depsgraph was always created within a fixed evaluation context. Passing
both risks the depsgraph and evaluation context not matching, and it
complicates the Python API where we'd have to expose both which is not so
easy to understand.

This also removes the global evaluation context in main, which assumed there
to be a single active scene and view layer.

Differential Revision: https://developer.blender.org/D3152
2018-04-16 19:55:33 +02:00
Brecht Van Lommel 7b9fb32591 Python API: remove preview/render resolution settings from API functions.
For correct results these must have been set already when the depsgraph was
created and evaluated, so all dependencies have appropriate resolutions too.

For particle we no longer backup and restore the viewport particles to avoid
overwriting them during render, as copy-on-write solves this for us. Even
without COW particles seem to work ok.

This also removes the particle simplification options based on camera. This
was never used much and only available in Blender Internal.

Differential Revision: https://developer.blender.org/D3148
2018-04-13 14:38:59 +02:00
Campbell Barton 4913e47aa0 Merge branch 'master' into blender2.8 2018-03-02 14:09:27 +11:00
Bastien Montagne 1178518a68 Refactor: Merge non-functional-change part of 'edit normals' 2017 GSoC.
This merges changes in internals, runtime-only of existing custom
normals code, which make sense as of themselves, and will make diff of
soc branch easier/lighter to review.

In the details, it mostly changes two things:

* Now, smooth fans (aka MLoopNorSpaceArray) can store either loop
indices, or pointers to BMLoop themselves. This makes sense since in
BMesh, it's relatively easy to get index from a BMElement, but nearly
impracticable to go the other way around.

* First change enforces another, now we cannot rely anymore on `loops`
being NULL in MLoopNorSpace to detect single-loop fans, so we instead
store that info in a new flag.

Again, these are expected to be totally non-functional changes.
2018-03-01 16:54:21 +01:00
Bastien Montagne 4ee3d7e3ac Merge branch 'master' into blender2.8
Conflicts:
	source/blender/bmesh/intern/bmesh_mesh.c
2018-02-22 15:22:44 +01:00
Bastien Montagne 0eee776e45 Fix (unreported) meshes changing shading when creating empty clnors data.
When you were using autosmooth to generate some custom normals, and
created empty custom loop normal data, you would go back to an 'all
smooth' shading, cancelling some sharp edges generated by the mesh's
smooth threshold.

Now we will first tag such edges as sharp, such that shading remains the
same. This is not crucial in current master, but it is for clnors
editing gsoc branch!
2018-02-22 15:20:39 +01:00
Sergey Sharybin 78ceb4b51e Merge branch 'master' into blender2.8 2018-02-21 10:30:50 +01:00
Bastien Montagne 35f225b44c Cleanup: split normals: use different varnames for angle and its cosine.
Using same name for two different things is not the best idea ever...
2018-02-20 13:03:10 +01:00
Campbell Barton 2f19559258 Cleanup: naming for mesh dirty flags
- NOCHECK -> ALL
- ALL -> MAYBE_ALL

Where 'MAYBE_ALL' checks to see if the mesh has changed.
This is clearer that `BKE_MESH_BATCH_DIRTY_ALL` is dirty and
going to be updated without any guess-work.
2017-08-22 22:07:25 +10:00
Campbell Barton 3e555d3d78 Merge branch 'master' into blender2.8 2017-08-21 15:41:03 +10:00
Campbell Barton 361c7cbbc5 Fix T52434: Restore mesh center of mass calculation
The new method while improved for solid objects
doesn't work for non-manifold meshes, keep both.
2017-08-21 15:19:08 +10:00
Campbell Barton 1b462e5a51 Pass EvaluationContext instead of bContext
2.8x branch added bContext arg in many places,
pass eval-context instead since its not simple to reason about what
what nested functions do when they can access and change almost anything.

Also use const to prevent unexpected modifications.

This fixes crash loading files with shadows,
since off-screen buffers use a NULL context for rendering.
2017-08-16 12:46:04 +10:00
Bastien Montagne 41830cc432 Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).

This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.

It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).

Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!

As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.

Design task : T51804
Phab Diff: D2714
2017-08-07 20:34:36 +02:00
Bastien Montagne 9da7dfa158 Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).

This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.

It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).

Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!

As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.

Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
Luca Rood 1c4c288727 Pass EvaluationContext argument everywhere
Note that some little parts of code have been dissabled because eval_ctx
was not available there. This should be resolved once DerivedMesh is
replaced.
2017-07-21 14:47:26 +02:00
Campbell Barton f5f34a9aa6 RNA: face-map access
Currently RNA doesn't give us a good way of accessing singleton layers,
for now expose as a layer list (skin & paint-pask do this too).

Noted in T47811 that this should be changed.
2017-07-20 19:52:26 +10:00