Commit Graph

12883 Commits

Author SHA1 Message Date
Campbell Barton
c61e4f2683 Don't allocate MFace's by default
This removes CD_MASK_MFACE from CD_MASK_BAREMESH, CD_MASK_DERIVEDMESH and others.

Callers that need it must explicitly add it to their data-masks.
2015-07-27 21:47:41 +10:00
Campbell Barton
67fe5726af Use loop data instead of face data
Replace checks in various places
2015-07-27 21:47:40 +10:00
Campbell Barton
15676bcc85 Error in looptri update, was checking wrong layer-type 2015-07-27 21:47:40 +10:00
Antony Riakiotakis
ba146899c8 Image painting 2D:
Deprecate wrap (BRUSH_TORUS) option, we now have paint flags for tiling
and we can reuse those. Also allows seperate tiling in X/Y
direction for 2D painting now.

Only one tiling is allowed for now.

Options can be found in new "Tiling" panel under the tools tab.

For version patching, we just turn off brush wrapping,
to allow reuse of the flag in the future.
New option is paint mode wide instead of per brush so
a brush having the old wrap option will not enable it
for the whole mode in the version patch.
2015-07-27 12:55:57 +02:00
Campbell Barton
b74fa38581 Missed last commit 2015-07-27 16:46:12 +10:00
Campbell Barton
e48c4d73d3 Replace MFace with looptri for dynamicpaint
D1429 by @lichtwerk, with edits
2015-07-27 16:01:56 +10:00
Campbell Barton
cdf2dbeb1f Cleanup: deprecate some G.fileflags comment others 2015-07-27 10:55:19 +10:00
Antony Riakiotakis
8fa1da9213 minor cleanup, reuse existing variable 2015-07-25 22:32:55 +02:00
Antony Riakiotakis
f1f4a16eab Convert CCGSubsurf VBO system to also sort hidden and visible faces.
It's not actually used during drawing though.
2015-07-25 22:02:43 +02:00
Antony Riakiotakis
53f6a31c4d GPU Buffers:
This commit begins implementation of the idea about hidden face
separation outlined in

http://code.blender.org/2015/06/optimizing-blenders-real-time-mesh-

We split hidden and visible faces to different parts of the triangle
buffer.
Mapped drawing will now skip iterating through hidden polys.
Of course the final target, when all derived mesh types use
VBO sorting, is to skip checking for hide flag per face
completely. All faces will be pre-sorted anyway and we'll
be able to draw them with one draw call.
2015-07-25 20:00:49 +02:00
Antony Riakiotakis
50a46a5973 GPU buffer materials:
Separate and reuse some shared code.

Also avoid counting for information we already know,
such as total loop triangles etc.
2015-07-25 14:42:26 +02:00
Antony Riakiotakis
9ff869e4fb Fix T45555 crash with subsurf edge drawing.
Loose edge count was double. It didn't fail on own
tests because they had a small number of loose edges,
but for bigger meshes it hit garbage indices at draw time
and crashed.

Also cleaned up the code to make it less verbose and easier to
understand how indices are counted.

Hope it's the last edge-related fix (fingers crossed)
2015-07-25 12:51:35 +02:00
Campbell Barton
e4b716a03f Cleanup: warnings, style 2015-07-25 07:44:25 +10:00
Antony Riakiotakis
dc80ff9b56 Fix T45541 crash when mixing flat and smooth shaded faces in sculpt
mode.

Issue from looptri merge.
2015-07-24 16:28:38 +02:00
Sergey Sharybin
a028575c4a Compositor: Allow using debug pass output in the compositor
Currently only works correct with single float output, RGBA and vector are not
supported so if one need to use this passes he'll need to wait a bit still.

It is coming, don't worry.
2015-07-24 15:39:09 +02:00
Antony Riakiotakis
eff1b54362 Fix subsurf edge drawing when more than one loose edge vert exists 2015-07-24 14:39:52 +02:00
Antony Riakiotakis
b55ed89b66 Fix yet another issue caused by my recent changes. 2015-07-24 14:32:11 +02:00
Antony Riakiotakis
2dce6dccbb Fix out of bounds memory access when copying loose vertices in cddm
Caused by own fix for too much allocated memory not taking all code
into account.
2015-07-24 12:24:57 +02:00
Campbell Barton
d6ebf72f9f Fix for building with OpenSubdiv 2015-07-24 17:11:50 +10:00
Antony Riakiotakis
b8481f4683 Minor cleanup - use integers for counters. 2015-07-23 23:21:19 +02:00
Campbell Barton
36630b7e85 Fix memory leaks mesh w/ mesh remapping 2015-07-24 05:04:33 +10:00
Antony Riakiotakis
d47e565598 Subsurf: Optimize edge drawing, now it uses VBOs.
Also the refactor exposed an error where we requested too much
memory from the video memory in general for all mesh types.

Now we are back to normal :)
2015-07-23 20:02:57 +02:00
Campbell Barton
cc5d48e8dd Use looptri for sampling UV's in smoke.c
D1424 by @scorpion81
2015-07-23 20:08:26 +10:00
Campbell Barton
b6cf4f777d Use looptri for smoke collisions & particle edit 2015-07-23 17:07:14 +10:00
Campbell Barton
6aabc1bde4 Cleanup; duplicate header 2015-07-23 15:40:47 +10:00
Campbell Barton
0a249f9853 Cleanup: arg names 2015-07-23 15:17:26 +10:00
Campbell Barton
abbd82a504 Use looptri for mesh remapping 2015-07-23 15:10:12 +10:00
Campbell Barton
8155d25d39 Utility function to get poly -> looptri mapping 2015-07-23 15:08:27 +10:00
Campbell Barton
60822ec183 Use looptri for BVH raycast (simple cases) 2015-07-23 14:41:09 +10:00
Campbell Barton
748899a50a Missed adding BVH callbacks in recent commit 2015-07-23 14:41:09 +10:00
Campbell Barton
0bf2b207e2 Add missing break checking for tangents 2015-07-23 11:51:03 +10:00
Campbell Barton
b604d5ade0 Add bvhtree_from_mesh_looptri utility function 2015-07-22 21:40:45 +10:00
Campbell Barton
b305041ce6 Add DM_get_looptri_array utility function 2015-07-22 21:40:41 +10:00
Campbell Barton
a6f00bb75c Use doxy sections in bvhutils 2015-07-22 21:32:14 +10:00
Campbell Barton
df41f7bf4f Use const for BVH mesh arrays 2015-07-22 21:32:14 +10:00
Sergey Sharybin
75d1723518 OpenSubdiv: Optimize speed of topology refiner construction
Now the conversion code uses mesh element mapping to speed up lookups.
Gives really nice speed improvement here, but the cost is higher memory
usage during refiner construction.

On the dragon scene here topology refiner construction time goes down
from 5 seconds to around 0.01.

It's possible to reduce the memory footprint by allocating mapping in
stages (don't allocate all of them at once, but do it on demand only
and free them after they're not needed anymore).
2015-07-22 12:51:10 +02:00
Sergey Sharybin
461340525e OpenSubdiv: Resolve crash when trying to do weight mcol 2015-07-22 12:01:38 +02:00
Bastien Montagne
945f32e66d Fix crash with recent refactor of customdata writing.
Caused by own rBff3d535bc2a6309 - since we now only write the exact amount of layers
needed to store saved customdata, we have to adjust CustomData->maxlayer too.

Otherwise, on next read, customdata code believes it has more layers allocated than
actual number.

Issue reported by Campbell over IRC, thanks.
2015-07-22 11:58:18 +02:00
Bastien Montagne
ff3d535bc2 Fix T45471: Blend file: Bad old_addr handling in mesh's customdata writing.
Issue is rather well explained in T45471: our current customdata writing code easily generates several different blocks in blend file with same 'old' address. This is bad, because those addresses are used as 'uid' during reading process (it kind of work in Blender's own reading process, by mere luck mostly, but breaks the file specs).

Solution (suggested by Campbell, thanks) implemented by this patch is to avoid duplicating everything, and instead just overwrite what we needs to skip some cdlayers on write:
* the CustomData's `totlayer` number;
* the CustomData's `layers` array of CustomDataLayer (keeping its original address using the `writestruct_at_address` helper).

New design allows us to get completely rid of the no_free flag stuff in `write_customdata()`.

Note that this implies written data is **not** directly valid from Blend PoV, since its written typemap does not match written layers (this is not an issue because typemap is rebuilt on read anyway - and it's easy to fix this if really needed).

Also, the backward compatibility saving of mface data remains an issue here, see comment in code.

Reviewers: sergey, campbellbarton

Projects: #bf_blender

Maniphest Tasks: T45471

Differential Revision: https://developer.blender.org/D1425
2015-07-21 12:02:11 +02:00
Campbell Barton
23831b2161 Cleanup: style 2015-07-21 17:29:23 +10:00
Campbell Barton
39cf1de33d Fix Clear vertex group ignoring selected option
Thanks to @chadf for spotting
2015-07-21 14:35:48 +10:00
Sergey Sharybin
3d36489672 OpenSubdiv: Commit of OpenSubdiv integration into Blender
This commit contains all the remained parts needed for initial integration of
OpenSubdiv into Blender's subdivision surface code. Includes both GPU and CPU
backends which works in the following way:

- When SubSurf modifier is the last in the modifiers stack then GPU pipeline
  of OpenSubdiv is used, making viewport performance as fast as possible.

  This also requires graphscard with GLSL 1.5 support. If this requirement is
  not met, then no GPU pipeline is used at all.

- If SubSurf is not a last modifier or if DerivesMesh is being evaluated for
  rendering then CPU limit evaluation API from OpenSubdiv is used. This only
  replaces the legacy evaluation code from CCGSubSurf_legacy, but keeps CCG
  structures exactly the same as they used to be for ages now.

This integration is fully covered with ifdef and not enabled by default
because there are several TODOs to be solved first:

- Face varying data interpolation is not really cleanly implemented for GPU
  in OpenSubdiv 3.0. It is also not implemented for limit evaluation API.

  This basically means we'll have really hard time supporting UVs.

- Limit evaluation only works with adaptivly subdivided meshes so far, which
  basically means all the points of CCG are pushed to the limit. This gives
  different result from old code.

- There are some serious optimizations possible on the topology refiner
  creation, which would speed up initial OpenSubdiv mesh creation.

- There are some hardcoded asumptions in the GPU and DerivedMesh areas which
  could be generalized.

  That's something where Antony and Campbell can help, making it so the code
  is structured in a way which is reusable by all planned viewport projects.

- There are also some workarounds in the dependency graph to make sure OpenGL
  buffers are only freed from the main thread.

Those who'll be wanting to make experiments with this code should grab dev
branch (NOT master) from

  https://github.com/Nazg-Gul/OpenSubdiv/tree/dev

There are some patches applied in there which we're working on on getting
into upstream.
2015-07-20 22:29:26 +02:00
Sergey Sharybin
2466c4f8ce OpenSubdiv: Add OpenSubdiv files which are related on the CCGSubSurf and GPU
Those files are still not in use (SCons will tyr to compile new CCGSubSurf files
but no code will be in use at all because those new files are fully wrapped by
ifdef WITH_OPENSUBDIV check).
2015-07-20 22:29:25 +02:00
Sergey Sharybin
ccc3c2dbda CCGSubSurf: Split file into several smaller ones
This is a preparation commit for having OpenSubdiv integrated into Blender
and new layout is the following:

- CCGSubSurf.c contains implementation of common functions used by both
  legacy subdivisions code and by the new code in the future.

- CCGSubSurf_inline.h contains internal functions which are to be inlined
  due to the performance reasons. Those functions are only ment to be used
  bu CCGSubSurf* files.

- CCGSubSurf_intern.h contains declarations of private functions and data
  structures used by CCGSubSurf module.

- CCGSubSurf_legacy.c contains legacy implementation of subdivision algorithm.

- CCHSubSurf_util.c contains utility functions which are not directly related
  on the subdivision code (i.e. debug functions, hash implementation etc).

There should be no functional changes so far.
2015-07-20 22:29:25 +02:00
Bastien Montagne
a4a3d5650d Minor optimization in CustomData_update_typemap(). 2015-07-20 17:28:29 +02:00
Bastien Montagne
9ee1f96a0f Fix (unreported) potential serious bug in CustomData_merge().
It was always only using the flags from the first source layer of a given type, not from
the layer actually being handled.

This was (probably) more or less harmless for the CD_FLAG_NOCOPY test,
but could be really bad when checking CD_FLAG_NOFREE, and when
copying the flags over to new copied data!
2015-07-20 16:25:01 +02:00
Campbell Barton
2e2164d5d4 Resolve compiler warning for clang 2015-07-20 22:31:19 +10:00
Antony Riakiotakis
cb6fc9d141 Use abstraction to unbind buffers, should avoid crashes in systems that
don't support VBOs.

Exposed by initialization error in GLEW, which should be fixed
seperately.
2015-07-20 12:12:28 +02:00
Campbell Barton
05ee9d2dd0 Minor edits for consistency 2015-07-20 17:07:40 +10:00
Campbell Barton
e58d788340 Cleanup: style
Also 'com' as abbreviation for center-of-mass is a bit confusing, rename to 'center'.
2015-07-20 05:30:08 +10:00