Commit Graph

120 Commits

Author SHA1 Message Date
b4e484e211 Fix for own r51737.
Refactoring of draw code showed another problem: The MCol we want to draw may change without dm rebuild (e.g. when enabling solid textured option)! Also, choosing which MCol layer to use in GPU code is stupid, different draw modes use different layers/order of precedence!

Solved this by adding a new colType parameter to GPU_color_setup, and removing any 'color choosing' code from gpu_buffers.c.
2012-10-30 11:00:06 +00:00
f139377a1a Complete fix for [#33002] Wrong vertex color.
Appart from the color glitch, there was several problems with vpaint:
* "fast_update" mode was never on, because of wrong testing code;
* drawing refresh during stroke in "fast_update" (i.e. no dm rebuild) mode was broken in VBO mode, because updated (tess data) mcol wasn't moved to colors GPUBuffer.

Solved the later point by adding a new DM_DIRTY_MCOL_UPDATE_DRAW flag to DerivedMesh dirty var, which is set each time vpaint stroke directly update me->mcol, and forces GPU_color_setup() to refresh the gpu's colors buffer.

Also got rid of the uggly GPU_color3_upload(), which basically did the same thing, but with an additional intermediate buffer !
2012-10-29 16:26:18 +00:00
2b9e70c81e Fix #32943: sculpt mode draw crash with VBO and flat shaded, hidden faces. 2012-10-23 11:07:05 +00:00
6e62491c5a Fix #32522: Object's diffuse color not showing in Sculpt Mode
Added option to display object's diffuse color multiplied by sculpting
mask. This option could be found in Options panel of toolshelf when in
sculpting mode.

Thanks to Nicholas and Brecht for reviewing the patch!
2012-10-22 17:33:53 +00:00
3a52a876b6 Fix for drawing meshes with VBOs disabled in sculpt mode
* This is another fix for r51118. Was drawing flat-shaded GPU buffers
  with VBOs even when VBOs were disabled in the preferences.
2012-10-20 00:45:44 +00:00
5ad61e9642 Fix for VBO drawing in multires sculpting
Was a mistake in a code cleanup commit, r51118.

Fixes bug [#32919] Sculting performance regression in svn_51118
projects.blender.org/tracker/?func=detail&aid=32919&group_id=9&atid=498
2012-10-19 02:38:50 +00:00
0c0fa7dde6 Improve flat-shaded VBO drawing for sculpt meshes
Separate vertex copies are now made for flat-shading, such that the
normal is correctly flat-shaded. The element index buffer is not
created in this case.
2012-10-06 16:52:52 +00:00
1df170bb96 Code cleanups for PBVH GPU buffers
* De-duplicate GPU code to check if VBO should be used.

* Add a flag to indicate if the buffer should be drawn smooth or not,
  rather than checking each time the node is drawn.
2012-10-06 16:42:11 +00:00
323ad98496 Fix: gpu_colors_enable could cause 3d display corruption because it always enables glColorMaterial. Make sure to call gpu_colors_disable even if we don't have a mask layer, to match gpu_colors_enable above 2012-10-01 07:53:54 +00:00
df298490b8 mask data is no longer automatically added when sculpting (except when there is a multi-res modifier). 2012-10-01 05:19:57 +00:00
168ffbfb67 Revert changes made to support diffuse color when sculpting
This changes are not stable enough and trying fix it could backfire in some
other regressions which isn't wanted so much close to the release.

This means objects will have gray color as diffuse which becomes darker in
masked areas for 2.64.

Proper fix is aimed for 2.65.

This commit reverts 50827 and 50898.
2012-09-30 15:04:46 +00:00
b2167e771a Fix #32663: Sculpt masks are too dark
Scaled mask multiplier to 0.25..1.0 instead of 0.0..1.0.
2012-09-26 07:55:52 +00:00
2637efa2a3 Fix #32522: Object's diffuse color not showing in Sculpt Mode
It was missing since sculpting mask implementation.

Now object's color would be multiplied by sculpt mask value.

For VBOs it's done by storing final color in VertexBufferFormat and
mimic behavior of setMaterial callback for getting current diffuse
color.

For non-VBOs diffuse color is getting from current OpenGL context.
2012-09-23 14:16:52 +00:00
32cf7fcdb1 code cleanup: spelling 2012-07-16 23:23:33 +00:00
0adf252c9b Fix #31593: Every time I switch between edit and object mode, it crashes
Crash was caused by incorrect restoring OpenGL context due to some
weird bit operations used to indicate whether stuff like color arrays
is initialized resulting in some unpredictable results on different
platforms and drivers.
2012-06-05 08:41:53 +00:00
032d83ecc4 style cleanup: defines with braces 2012-05-27 20:13:59 +00:00
dab1d8e487 style cleanup 2012-05-22 22:03:41 +00:00
931146731d Fix memory leak when deleting all vertices from mesh with certain modifiers (bevel and array among them) and VBO are enabled. 2012-05-22 17:33:58 +00:00
9dd981a440 style cleanup: block comments 2012-05-16 23:37:23 +00:00
ce17c35240 style cleanup: mainly sculpt/whitespace 2012-05-11 08:05:47 +00:00
d35d0e38ce Add mask-drawing support to GPU_Buffers.
This is the last commit of the sculpt masking merge. Documentation:
http://wiki.blender.org/index.php/User:Nicholasbishop/PaintMasks

Thanks to Brecht for reviewing!

* For VBO, add color to the VertexBufferFormat structure as three
  unsigned bytes. Since mask elements are scalar the three color
  components are identical to eachother, but the fixed-function OpenGL
  pipeline requires colors to be either three or four components.

* For the same reason, multires VBO drawing now copies into the
  VertexBufferFormat format as well.

* Regression: material colors will not show up correctly now, masks
  colors are overriding. Not sure how to fix this nicely (would be
  much easier to fix if drawing with vertex shaders.)

* Also, masks will only draw PBVH drawing, so only 'solid' drawing
  will work correctly with masks.
2012-05-10 20:36:34 +00:00
3ee0305ebb Use VertexBufferFormat for multires VBO. 2012-05-10 20:36:24 +00:00
f751d0f6ae Replace hardcoded DMGridData structure with CCGElem/CCGKey.
* Changes to DerivedMesh interface: DMGridData has been removed,
  getGridData() now returns an array of CCGElem pointers. Also added
  getGridKey() to initialize a CCGKey (implemented only by
  CCGDerivedMesh.)

* PBVH: added BLI_pbvh_get_grid_key().

* A lot of code is affected, but mainly is just replacing
  DMGridData.co, DMGridData.no, and sizeof(DMGridData) with the
  CCG_*_elem functions, removing the reliance on grid elements of
  exactly six floats.
2012-05-10 20:33:09 +00:00
d20c129a9c style cleanup: whitespace/operators 2012-05-09 09:24:15 +00:00
e701f9b670 style cleanup: whitespace / commas 2012-04-29 15:47:02 +00:00
b340f930ec style cleanup: changes to brace placement / newlines - for/while/if/switch 2012-04-28 06:31:57 +00:00
5c89138684 style cleanup: comments 2012-04-22 11:54:53 +00:00
3c1b5b5632 stule cleanup: edits for files which were recently cleaned up. 2012-04-02 22:26:00 +00:00
0740e9e464 fix [#30643] Crasher on entering edit mode with VBOs enabled 2012-03-30 06:11:59 +00:00
81d8f17843 style cleanup: pep8, indentation 2012-03-24 07:36:32 +00:00
ab4a2aaf4a style cleanup: follow style guide for formatting of if/for/while loops, and else if's 2012-03-24 06:38:07 +00:00
9751653410 Renaming CD_WEIGHT_MCOL/MLOOPCOL and their masks from WEIGHT to PREVIEW, as this layer is now also used for various preview tasks in Object mode.
“Cleanup” commit, no functional changes.
2012-03-22 08:41:50 +00:00
52418868eb Fix for size of VBO index type when drawing multires in sculpt mode.
The VBO index type can be either ushort or uint depending on the grid
size. The comparison was checking how many quads are in the array, but
this was incorrect; the size of the index elements should depend on
the maximum value they reference, i.e. the maximum coord/normal
element.
2012-03-16 23:21:40 +00:00
815beed922 Fix for multires VBO drawing in sculpt mode.
Forgot to use return value of function creating the index buffer.
2012-03-16 04:11:35 +00:00
4d3f11c66f Fix some errors in partial visibility drawing.
Also changed show-in-border key to SHIFT+H as suggested by Daniel
Salazar.
2012-03-14 07:37:47 +00:00
68b8f3b0a8 Skip hidden elements in PBVH iterator, raycast, and drawing. 2012-03-14 06:32:25 +00:00
0641f1723b Optimize index buffers for multires drawing in sculpt mode.
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.
2012-03-09 09:30:03 +00:00
4f7bdc59d3 style cleanup: spelling.
also remove large, duplicate comments from sunsky.h
2012-03-09 00:41:09 +00:00
71e5edeb6a Code cleanup: use typedefs for DerivedMesh drawing callbacks.
There are still fairly bewildering set of callbacks being tossed
around, but it's at least a little less verbose now.
2012-03-07 04:41:14 +00:00
c7ffe7f621 Draw individual face's material and shading correctly in the PBVH.
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).
2012-03-06 02:40:08 +00:00
e2003f9a6c Code cleanup: remove unused drawFacesColored from DerivedMesh.
This function pointer isn't called anymore, so removing it and the
cddm/ccgdm/gpu code associated with it.
2012-03-05 21:27:28 +00:00
87ddcab933 Bugfix: avoid reading from an OpenGL buffer mapped write-only.
When set to solid-shading, GPU_update_grid_buffers was calling
normal_quad_v3 to output into a mapped buffer, but normal_quad_v3
reads as well as writes.

This fix actually makes a huge performance difference with my drivers
(Gallium/Radeon).
2012-02-28 05:00:28 +00:00
3dd449ae4f Bugfix: don't read from a write-only VBO when updating grid buffers. 2012-02-23 10:35:23 +00:00
5e12c7feca Code cleanup: de-duplicate code in GPU_build_grid_buffers() with a macro. 2012-02-22 23:30:56 +00:00
fd87bf3ef6 Code cleanup: don't use GHash for GPU_build_mesh_buffers().
At the point where GPU_build_mesh_buffers is called, the
face_vert_indices map has already been built; it contains the same
data in an easier-to-access format.
2012-02-22 22:48:34 +00:00
88a2be1846 Another fix for non-VBO flat-shading in sculpt mode, this time for non-multires meshes.
As with multires, this change calculates face normals rather than
using vertex normals when the node is flat-shaded.

Flat-shading with VBO on non-multires meshes is still wrong, but
fixing that would require larger changes to our vertex buffers.
2012-02-21 04:24:30 +00:00
a6dc47b0ca Remove call to GPU_update_mesh_buffers from GPU_build_mesh_buffers.
Building the mesh buffers already gets the PBVH_UpdateDrawBuffers flag
set, so this was double-updating the vertex buffer.
2012-02-21 04:16:27 +00:00
d31e1533a3 Fix normals for flat-shaded non-VBO sculpt drawing.
Example here, original on left, fixed normals on right:
http://www.pasteall.org/pic/show.php?id=26925
2012-02-20 21:25:24 +00:00
c0eec8f379 svn merge ^/trunk/blender -r43062:43085 2012-01-03 02:16:52 +00:00
0eb8a384c9 Remove some silly variable copies that stuck around from a previous refactor. 2012-01-02 19:01:16 +00:00