Compare commits

..

2257 Commits

Author SHA1 Message Date
69f366eff0 Center now works for multiple objects 2018-04-10 19:03:19 +02:00
dbccbc63de Merge branch '28' into temp-object-multi-mode-xform-not-compiling 2018-04-10 16:20:01 +02:00
8d1c21998a Merge branch 'master' into blender2.8 2018-04-10 16:15:30 +02:00
917edd5e1e Merge branch '28' into temp-object-multi-mode-xform-not-compiling 2018-04-10 16:15:07 +02:00
549d4a55ab Fix transform nearest axis check
Was mixing up global/local coords
2018-04-10 16:14:29 +02:00
71980945bc Draw Manager: Fix lazy compilation on certain hardware.
Before, the drawing functions sometimes froze with `AMD Radeon HD 7570M`.
2018-04-10 11:03:15 -03:00
bee47fe7d5 Vertex slide now works on a basic level 2018-04-10 15:46:03 +02:00
aa93d417fc tmp 2018-04-10 13:52:15 +02:00
6962119e7f Merge branch 'master' into blender2.8 2018-04-10 12:00:10 +02:00
5c3857b305 Depsgraph: Build relations for objects linked via pchan constraints
This is similar to previous fix for missing ID nodes, just the original
fix missed this part of change because it looked like it is already
happening.
2018-04-10 11:57:20 +02:00
a74e782f5b BLF: Fix broken shadows on certain hardware.
This was due to uninitialized texture space.
2018-04-10 10:26:09 +02:00
814f143acf Fix T54423: Messages from RNA_property_editable_info() were not translatable. 2018-04-10 10:24:02 +02:00
bd76c88754 Depsgraph: Flush debug prints
Makes it more reliable to see what was updating last when
crash happens.
2018-04-10 09:54:27 +02:00
f0a3aa88c8 Use macro for case of single TransHandle access 2018-04-10 08:51:36 +02:00
4f392784e6 Finally compiles, not working though 2018-04-10 08:26:01 +02:00
f0083fc1d2 TMP 2018-04-10 08:10:59 +02:00
c0ac908fe8 Fix crash when no object is active
Could happen when deleting the active object or opening an old file
2018-04-09 22:03:33 -04:00
16b795cb95 Fix crash in graph editor id remapping
Dopsheet pointer isn't set...?
2018-04-09 21:40:52 -04:00
Julian Eisel
77e9193c23 Fix invalid context when refreshing popups
Patch D2759 by @raa, with minor edits by me.
2018-04-09 19:31:39 +02:00
8d9a5d5062 UI: Fix widget shader on certain compiler.
There was a crash with Intel(R) HD Graphics 4000.
2018-04-09 14:07:32 -03:00
ec91948dd7 Cleanup: unused variable 2018-04-09 19:01:49 +02:00
Julian Eisel
7213553c84 UI: Clamp scrollbar offset to lower view boundaries
Fixes the "emtpy scrolling" glitch by clamping the scroller offset to
the boundary of the view when it's smaller than the previous.

Fixes T45197. Patch by @januz.

Differential Revision: D1580
2018-04-09 18:55:50 +02:00
4a656f5d16 GPU Shader: Cleanup: Remove unnecessary ";" 2018-04-09 13:45:57 -03:00
2a0dca4252 UI: Fix widget shader on certain compiler.
There was a crash with `Intel(R) HD Graphics 4000`.
Thanks to @fclem for the help and review.
2018-04-09 13:45:17 -03:00
bbcbbf7212 TMP 2018-04-09 18:20:05 +02:00
26a283deae Use the newer version of the bullet 6dof spring constraint for rigidbody.
The new constraint is slower and not backward compatible, but should
be better, especially in the damping side. The new constraint also
has a different valid range of the damping coefficient, and a limit
implementation that bounces instead of making the object stationary.

Reviewers: sergof

Differential Revision: https://developer.blender.org/D3125
2018-04-09 19:14:35 +03:00
fbccb08c28 TMP 2018-04-09 17:43:27 +02:00
05617a068e TMP 2018-04-09 17:36:47 +02:00
fcff5f80f9 Temp 2018-04-09 15:59:33 +02:00
c1a2f973da Merge branch 'master' into blender2.8 2018-04-09 15:44:28 +02:00
7e39d151d8 Added support for the WEBM/VP9 video codec
WEBM is the codec name, and VP9 is the encoder (the older encoder "VP8"
is less efficient than VP9).

WEBM/VP9 and h.264 both have options to control the file size versus
compression time (e.g. fast but big, or slow and small, for the same
output quality). Since WEBM/VP9 only has three choices, I've chosen to
map those to 3 of the 9 possible choices of h.264:

- BEST → SLOWER
- GOOD → MEDIUM
- REALTIME → SUPERFAST

The VERYSLOW and ULTRAFAST options give very little extra benefit.

Reviewed by: @Severin
2018-04-09 15:27:11 +02:00
39116a4340 Remove commented-out code 2018-04-09 15:26:12 +02:00
d533b70b23 Fix build error with GCC, make depsgraph iterator compatible with C++. 2018-04-09 15:09:22 +02:00
f0edb853be Build: fix make deps using system webp/sndio libs. 2018-04-09 15:08:40 +02:00
Julian Eisel
867f96c234 Fix crash and invalid context when changing workspace
Caused by 1c24c04e60.
2018-04-09 13:19:19 +02:00
3703483d03 Merge branch '28' into temp-object-multi-mode-xform-not-compiling 2018-04-09 12:46:03 +02:00
09ee3eb173 Merge branch 'master' into blender2.8 2018-04-09 12:44:25 +02:00
2872965652 Cleanup: avoid recalculating global center 2018-04-09 12:40:10 +02:00
3cb42e5917 GPU Codegen: Fix assert caused by GC of failled shaders. 2018-04-09 12:10:03 +02:00
020c4e19f2 BLF: Fix assert when drawing very small chars. 2018-04-09 12:10:03 +02:00
209c5cebb0 Freestyle: use depsgraph to get geometry, instead of Blender Internal.
Some of the code is simpler because we use Blender's triangulation directly
instead of dealing with quads. Also some progress printing code was removed
because the depsgraph can not tell us the number of objects ahead of time.

Differential Revision: https://developer.blender.org/D3127
2018-04-09 11:21:14 +02:00
99b8c0fe5d Work in progress transform code 2018-04-09 09:00:35 +02:00
d7c0421493 Revert transform changes, in favor of more comprehensive ones 2018-04-09 09:00:35 +02:00
cf4041eb05 UI: Widgets: Fix text edit cursor not drawing.
Actually it was drawn before the widget. Flushing widget cache and
everything is fine again.
2018-04-08 18:54:34 +02:00
9960feb7e3 GPU Select: Remove warnings on Intel GPU.
- Disable scissor test for fast clear. This could lead to some issues but
   I cannot think of one and could not find one either.
 - Manually wait for queries to be available instead of making the driver
   wait and issue warnings.
2018-04-08 18:31:50 +02:00
fc6b69bedc UI: Perf: Use GWN_draw_primitive for drawing viewport textures. 2018-04-08 18:31:50 +02:00
0b06e73258 UI: Perf: Use GWN_draw_primitive for drawing triple buffers texture. 2018-04-08 18:31:50 +02:00
17aad5ad97 UI: Perf: View3D: Batch view infos BLF calls together. 2018-04-08 18:31:50 +02:00
ccbc14d995 UI: Perf: Batch horizontal scrollers numbers together. 2018-04-08 18:31:50 +02:00
651ea84471 Clay: Improve loading time.
Only compile hair shader if we need it.
2018-04-08 18:31:50 +02:00
e9f048052f Merge branch 'master' into blender2.8 2018-04-08 17:54:07 +02:00
d6a1a0ebb8 Alphabetically ordered audio and video codecs 2018-04-08 17:52:30 +02:00
afbc73ab72 BLF: Perf: Use BLF_KERNING_STEP_FAST for other functions. 2018-04-08 15:57:24 +02:00
47cfdb3c0c Eevee: Reduce loading time.
Only compile the needed shadow shaders to reduce the startup time.

Theses shaders is taking forever to compile on intel (~5s each).
2018-04-08 15:57:24 +02:00
0c9bc69f42 DRW: Profiling: Batch BLF strings and add shadowing
Shadows makes it more readable and are relatively cheap now.
2018-04-08 15:57:24 +02:00
6b109da114 BLF: Fix BlenderPlayer compilation. 2018-04-08 15:57:24 +02:00
a981206fd1 Merge branch 'master' into blender2.8 2018-04-08 14:07:34 +02:00
245e01c30a Encoding panel clarifications
The encoding panel mentions "None" in a few places, which is confusing.
- "Codec: None" now reads "No Video"
- "Audio Codec: None" now reads "No Audio"
- "Output Quality: None; ..." now reads "Constant Bitrate"

When selecting "No Video" the remaining video encoding options are
hidden, making it even more explicit that there will not be video in the
output file.

The label "Codec" now reads "Video Codec" for symmetry with "Audio
Codec".
2018-04-08 13:46:29 +02:00
0b5ebb3265 BLF: Fix problem with bound texture.
Previous code was assuming that the glyph texture would remain bound to
GL_TEXTURE0 until the cache would be drawn. This is not always the case,
so better save the texture and rebind it before drawing.
2018-04-08 01:14:43 +02:00
3725d82cee BLF: Opti: More clever sampling for blured glyphs.
Reduce the number of sampled required for blurring by using filtered
texture samples.

This changes the result a bit but it is not noticable.
2018-04-08 01:00:55 +02:00
987c56c4b6 BLF: Opti: Draw only one quad per shadow/blurred glyph.
This port the Blurring of blf fonts to the final drawing shader.

We add a bit of extra padding to each glyph so that jittering the texture
coord does not sample the neighbor glyphs.
2018-04-08 00:44:35 +02:00
e0452cc5a9 Fix edit-mesh select next
Last change introduced error, return would stop looking over candidates.

D3137 by @nBurn
2018-04-07 19:54:59 +02:00
4db3b4da46 Bullet: Fix velocity calculation of new spring constraint
This is a backport of bullet commit: 86ca7dc
2018-04-07 17:37:23 +02:00
1a33707417 UI: Fix waveform widget text drawing.
Flush the text cache so that we have proper scissor test and ordering.
2018-04-07 14:03:32 +02:00
8a410572c2 Merge branch '28' into temp-object-multi-mode 2018-04-07 11:13:13 +02:00
2d618974d1 UI: Perf: Port color widgets to batch.
This is more for completeness than perf.

Shader is tiny bit more complex but we get less overdraw and drawcalls.
2018-04-06 23:54:39 +02:00
3e998b8860 Fix object mode workspace check 2018-04-06 18:31:32 +02:00
4a2b64e43d Minor change to last commit 2018-04-06 18:17:18 +02:00
6b2cf4e86e Delete object crashed (missing NULL check)
Error in recent removal of workspace.object_mode
2018-04-06 18:15:51 +02:00
4e52724aa8 UI: Perf: Optimize F-curve handles drawing.
50% less time in my test when all handles are selected.
2018-04-06 15:39:09 +02:00
5441e4802a Style: Remove duplicated struct declaration. 2018-04-06 14:30:44 +02:00
39b654f4ff UI: Perf: Use widget base batching
Overall 10% more performance on general UI drawing time.

This commit can introduce ordering problem on some elements.
In this case you need to flush the widget cache to ensure the element that
is going to be drawn is drawn on top of any widget base.

To flush the cache use UI_widgetbase_draw_cache_flush.

This is already done for BLF and Icons.
2018-04-06 14:30:20 +02:00
21113ad834 UI: Perf: Add batching capability to widgets.
Similiar to how we batch Icons together. This is not enabled in this
commit.
2018-04-06 14:25:55 +02:00
fcb4aaf7a9 GPUShader: Add GPU_SHADER_2D_WIDGET_BASE_INST shader.
This will let us draw multiple widget base at once.
2018-04-06 14:22:20 +02:00
d2e1a14a57 Fix Collada: nullptr is a c++11 keyword. Changed to NULL 2018-04-06 13:06:46 +02:00
fe73c12990 Fix Collada: Import of animations for objects with multiple materials
When importing multiple materials for one object,
the imported material animation curves have all been
assigned to the first material in the object.

This fix also improves the console logging whenever the importer
finds a consistency problem with the imported animation data.
2018-04-06 12:42:38 +02:00
4de70da73a Cleanup: style, doxy headers 2018-04-06 10:47:39 +02:00
4a73127a2b UI: Perf: Improve ui_draw_dropshadow.
Replace the 12 iterations of UI_draw_roundbox_4fv with only one batch.

This mean less overdraw and less drawcalls.

I had to hack the opacity falloff curve manually to get approximatly the
same result as previous technique. I'm sure with a bit more brain power
somebody could find the perfect function.
2018-04-06 10:25:53 +02:00
80d4d71360 UI: Perf: Modify UI_draw_roundbox to use GWN_batch API.
This commit also rename and move a few thing to clean things up.

Major improvment is using one drawcall instead of 8 for UI_draw_roundbox_aa.
2018-04-06 10:25:53 +02:00
Julian Eisel
72e5082b67 UI: Add accelerator keys to quit confirmation popup 2018-04-05 19:15:37 +02:00
eb7b701137 Fix error where find-next missed None check
Thanks to @nBurn
2018-04-05 18:48:48 +02:00
ba821ad2ad Depsgraph: Avoid build-time armature expanding
With index-based pchan evaluation we don't need to go into
a mess of expanding armature at relation construction time.
2018-04-05 18:40:10 +02:00
58ba5a65bc Cleanup: use string macros to avoid duplicate args 2018-04-05 18:39:23 +02:00
3a864f5ee4 BLI_string_utf8: macros that de-duplicate sizeof arg 2018-04-05 18:37:54 +02:00
025bf11a9f Merge branch 'master' into blender2.8 2018-04-05 18:25:05 +02:00
1c24c04e60 Remove workspace object mode, reverts changes w/ 2.8
This caused too many problems syncing object modes
with multiple objects/windows/workspaces, see: D3130 for details.
2018-04-05 18:21:14 +02:00
9b8a92b874 Depsgraph: Pull indirect dependencies via pchan constraints
Was missing ID looper for pchan constraint.
2018-04-05 18:03:36 +02:00
57329304b0 Merge branch 'master' into blender2.8 2018-04-05 16:58:41 +02:00
ea0e2f9bd3 Load metadata from video files and expose via RNA
The MovieSequence and MovieClip classes now have a metadata() function
that exposes the `IDProperty *` holding the video metadata.

Part of: https://developer.blender.org/D2273

Reviewed by: @campbellbarton
2018-04-05 16:50:24 +02:00
6c3110a661 Write the scene render frame range to image/video files
This is useful to create a mapping from the frame range in the video to
frame index in the blend file.

Part of: https://developer.blender.org/D2273

Reviewed by: @campbellbarton
2018-04-05 16:50:24 +02:00
6374d390d3 Write StampData metadata to video files
This is currently only supported by FFmpeg (so not frameserver, AVI RAW,
or AVI JPEG), and only seems to work when using Matroska or Ogg Theora
containers.

Only metadata that doesn't change from frame to frame is written to
video files. This distinction is visible in the UI by looking at the
stamp checkbox tooltips (they either mention "image" or "image/video").

Part of: https://developer.blender.org/D2273

Reviewed by: @campbellbarton
2018-04-05 16:50:23 +02:00
b0a767b85b IMB_metadata improvements
- Metadata handling is now separate from `ImBuf *`, allowing it to be
  used with a generic `IDProperty *`.
- Merged `IMB_metadata_add_field()` and `IMB_metadata_change_field()`
  into a more robust `IMB_metadata_set_field()`. This new function
  doesn't return any status (it now always succeeds, and the previously
  existing return value was never checked anyway).
- Removed `IMB_metadata_del_field()` as it was never actually used
  anywhere.
- Use `IMB_metadata_ensure()` instead of having
  `IMB_metadata_set_field()` create the containing `IDProperty` for
  you.
- Deduplicated function declarations, moved `intern/IMB_metadata.h` out
  of `intern/`. Note that this does mean that we have some extra
  `#include "IMB_metadata.h"` lines now, as the metadata functions are
  no longer declared in `IMB_imbuf.h`.
- Deduplicated function declarations, all metadata-related declarations
  are now in imbuf/IMB_metadata.h.

Part of: https://developer.blender.org/D2273

Reviewed by: @campbellbarton
2018-04-05 16:50:23 +02:00
f0f6c96a92 BLI_string: macros that de-duplicate sizeof arg 2018-04-05 16:44:48 +02:00
3eaf77fdd3 Merge branch 'master' into blender2.8 2018-04-05 16:19:43 +02:00
1c1dc39466 UI: Node Editor: Make nodelink arrow size and link width dpi dependant. 2018-04-05 16:08:46 +02:00
fb8a1a58d9 UI: Node Editor: Batch nodelinks together.
This will do only one drawcall for every 256 nodelinks.
2018-04-05 16:08:46 +02:00
72bfa849ee UI: Node Editor: Port nodelink drawing to shader based drawing.
Use the new GPU_SHADER_2D_NODELINK and GPU_SHADER_2D_NODELINK_INST to
accelerate nodelink drawing.

This commit does not include the batching functionnality. So this should
not make a lot of difference.
2018-04-05 16:08:46 +02:00
c65c4fb77b GWN: Add GWN_batch_uniform_2fv_array. 2018-04-05 16:08:46 +02:00
cadef79a52 GPUBatch: Change preset managment system.
Now use a list of preset batches with a function to add new ones to this
list.

This removes the need of new functions all over the place to reset/exit.
2018-04-05 16:08:46 +02:00
d48597eb54 GPUShader: Add 2D Nodelink shader.
Special shader to draw nodelinks for the node editor.

We only pass bezier points to the GPU and vertex position is handled inside
the vertex shader.
The arrow is also part of the batch to avoid separate drawcalls for it.

We still draw 2 pass one for shadow and one for the link color on top.

One variation to draw instances of theses links so that we only do one
drawcall.
2018-04-05 16:08:46 +02:00
ad1ea9a427 Undo: split text undo steps out of the data-block
This moves undo storage into a separate struct which is passed
in from the undo system.
2018-04-05 15:22:33 +02:00
79c3c56894 Undo System: return undo step from undo push init
Also improve logging
2018-04-05 14:11:51 +02:00
1761095abc Logging: use -1 log level to log all levels 2018-04-05 13:55:04 +02:00
cd474b913b ED_undo: use logging 2018-04-05 13:41:52 +02:00
47b6e23271 Fix crash w/ empty text undo operations 2018-04-05 10:01:12 +02:00
5fba4458e9 Fix Cycles motion blur and engine.frame_set() not working. 2018-04-04 17:59:46 +02:00
db3c3d1338 Depsgraph: Fix/workaround crash with animation and drivers and CoW
The issue was caused by component tag forcing CoW component to be run,
without actually flushing changes down the road from the CoW operation.

In a way, this is what we want: we do want CoW to run on changes, but
we don't want tiny change forcing full datablock update.

This commit makes it so order of updates is all correct, but the bigger
issue is still open: what parts of datablock CoW should be updating?

Now it's possible to open spring file and play around.
2018-04-04 17:49:08 +02:00
b561707bed Gawain: Make removing batches more thread safe
The issue was mainly visible when copy-on-write was enabled. This was forcing
lots of meshes to be freed from multiple thread, causing all sorts of race
conditions in Gawain's VAO code.

OpenGL resources seems already to be doing deferred deletion, need to do the
same for CPU side arrays.
2018-04-04 17:49:08 +02:00
160e62b88c Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/BKE_object.h
2018-04-04 15:03:55 +02:00
d59c2d12b1 Fix modifier freeing code re. ID refcounting.
Free code should not handle ID refcounting at all. This has to be done
at higher level, since in some case we want to free (temp) data that
actually did not refcount at all its IDs.

This change seems to be working OK, but as usual in that area, only
lots of testing in real-case situation will say whether there are some
hidden bugs or not.
2018-04-04 14:58:52 +02:00
59562e5b25 Fix Cycles particle info node not working. 2018-04-04 13:18:06 +02:00
7db4b935e1 Depsgraph: Cleanup, reduce indentation level 2018-04-04 13:02:28 +02:00
ef22b837e8 Merge branch 'master' into blender2.8 2018-04-04 12:57:36 +02:00
0c7ec58966 Depsgraph: Make sure textures used by modifiers are in the graph 2018-04-04 12:56:04 +02:00
49f77b0d83 Proper fix for T54337
Accidentally checked the wrong variable in fa01a1738b.
2018-04-04 06:36:16 -04:00
39585e1abc Fix undefined workspace in UI script 2018-04-04 12:33:10 +02:00
3a17dab2b1 Fix Eevee crash with generated coordinates on non-objects. 2018-04-04 12:28:20 +02:00
9c7bd1fad9 Cleanup: simplify fix for T53497, this part is not strictly needed. 2018-04-04 12:28:20 +02:00
3a566687e1 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/intern/readfile.c
2018-04-04 12:00:57 +02:00
677d699645 Tweak ID->tag reset on file load (no visible change expected!).
Issue was, *some* IDs (like infamous nodetrees from materials etc.)
would not go through the 'main' read_libblock() func, so their tags were
never reset.

So now, we ensure direct_link_id() always clear the tags, and move
setting them in read_libblock() after the call to direct_link_id().

Needed for depsgraph, but general healthier fix actually.
2018-04-04 11:59:16 +02:00
948f4e8c94 Depsgraph: Get pchan index from correct pose
This code should be replaced with evaluation-time ID block expansion,
but before that it will be helpful to get old design to work again.
2018-04-04 11:55:06 +02:00
a6999a869e Merge branch 'master' into blender2.8 2018-04-04 11:49:24 +02:00
c128738926 Depsgraph: Ensure root pchan is always found 2018-04-04 11:49:01 +02:00
c9ad9b260a Depsgraph: Pass CoW version of object to armature update done 2018-04-04 11:47:33 +02:00
fb5a57ab97 Fix part of T53497: Eevee stuttering on macOS for the first few seconds of usage.
The problem was that textures were assigned to different slots on different draw
calls, which caused shader specialization/patching by the driver. So the shader
would be compiled over and over until all possible assignments were used.
2018-04-04 11:30:55 +02:00
3f4df3f847 Fix missing hair in fishycat and everything else after particle recalc changes
The cache was getting reset always, due to special case of flag being 0.

Bug introduced by: 44cd24a9ce
2018-04-04 05:10:47 -04:00
e217fb439f Merge branch 'master' into blender2.8 2018-04-04 10:36:39 +02:00
909efe6be5 Depsgraph: Assert that pchan index is always valid 2018-04-04 10:35:32 +02:00
d54a058f35 Merge branch 'master' into blender2.8 2018-04-04 10:16:38 +02:00
f913e69093 Depsgraph: Add missing expansion od custom bone shapes
This was fixed in 2.8 branch but not in master.
2018-04-04 10:15:45 +02:00
eaf8608ba5 Merge branch 'master' into blender2.8 2018-04-04 09:54:50 +02:00
4674e02562 Depsgraph: Only bind ID-data and indices to depsgraph callbacks
This is a part of copy-on-write sanitization, to avoid all the checks
which were attempting to keep sub-data pointers intact.

Point is: ID pointers never change for CoW datablocks, but nested
data pointers might change when updating existing copy.

Solution: Only bind ID data pointers and index of sub-data.
This will make CoW datablock 7update function was easier in 2.8.

In master we were only using pose channel pointers in callbacks,
this is exactly what this commit addresses. A linear lookup array
is created on pose evaluation init and is thrown away afterwards.

One thing we might consider doing is to keep indexed array of
poses, similar to chanhash.

Reviewers: campbellbarton

Reviewed By: campbellbarton

Subscribers: dfelinto

Differential Revision: https://developer.blender.org/D3124
2018-04-04 09:48:41 +02:00
fa01a1738b Fix T54337: Cycles crash with simple subd object in debug build 2018-04-03 23:37:12 -04:00
8c4d28cdb9 Fix T54400: Some GCN 1 cards available to select for use with Cycles
Hainan was missing from the list of GCN 1 cards.
2018-04-03 23:15:07 -04:00
2f723a414f BMesh: remove redundant loop in select-next-active
Thanks to @nBurn for spotting
2018-04-03 18:32:55 +02:00
cd6daea7d3 Missed in last merge 2018-04-03 18:22:52 +02:00
48eaddfae0 Missed in last merge 2018-04-03 18:22:05 +02:00
e52beb3733 Merge branch 'master' into blender2.8 2018-04-03 18:12:39 +02:00
ab695c3297 Undo: make id-map use binary search to keep sorted 2018-04-03 18:07:51 +02:00
1f0f234b07 Fix own error w/ undo ID lookup
Was testing with small number of items, so this went unnoticed.
2018-04-03 17:58:37 +02:00
c713e9c472 Draw Manager: Improve description of draw_frustum_boundbox_calc variables 2018-04-03 12:18:56 -03:00
b2c9fdfe87 Cleanup: rename BMesh count_ex -> count_at_most 2018-04-03 17:06:36 +02:00
bfdb88f3f4 Cleanup: rename list count_ex -> count_at_most 2018-04-03 17:05:21 +02:00
06a62d4e06 Undo: use with_prev verisons of id-map lookups 2018-04-03 17:03:33 +02:00
5a7deab65a Undo: use general id-map for image undo lookups.
Was doing own name based lookups to keep compatible w/ global undo.
2018-04-03 17:03:33 +02:00
75de21f072 Undo System: id-map avoid duplicate add/lookup
Add versions of add/lookup that check the previous item.
2018-04-03 17:03:33 +02:00
53f068454e Fix mistake logging w/ undo 2018-04-03 17:03:33 +02:00
6744c34a26 Merge branch 'master' into blender2.8 2018-04-03 16:13:13 +02:00
96f565b380 Fix T54477: Broken utf8 strings in old .blend files
Back in the days (2.4x and before), it was rather easy to get some
invalid utf-8 strings in Blender. This is totally breaking modern code,
so this commit adds a simple 'check & fix strings' operator, available
from the main File menu.
2018-04-03 16:03:11 +02:00
269e4e9b81 Undo support for multi edit-mode 2018-04-03 14:57:56 +02:00
8a20cd92a9 Merge branch '28' into temp-object-multi-mode 2018-04-03 14:34:37 +02:00
601835cd31 Fix (unreported) crash when accessing some bl_rna.properties.
E.g. typing `bpy.data.bl_rna.properties[8].<tab>` in console would hard-crash
trying to dereference NULL pointer. Was a missing check in rna_Property_tags_itemf().
2018-04-03 14:32:23 +02:00
7e9a80530f Cleanup: remove unused mtexpoly array
Not needed in 2.8
2018-04-03 14:30:12 +02:00
a2c0a382cd Merge branch 'master' into blender2.8 2018-04-03 14:19:51 +02:00
feb7852e1b Fix duplicate Cycles panels in properties editor. 2018-04-03 14:04:59 +02:00
3a96cfcd26 Fix crash on startup on macOS, after recent framebuffer refactoring. 2018-04-03 09:36:31 +02:00
b3004d30f5 Undo: remove particle undo push
Was only called on copy particle system
which is already doing an undo push.
2018-04-03 08:57:01 +02:00
72ae0e1b6d Cleanup: editor BKE_main includes 2018-04-03 08:42:12 +02:00
a0eb54142f Undo: replace global access w/ ED_undo_stack_get
While I'd like to avoid using this too much since the operator
system should handle.
It's less trouble than accessing it inline each time.
2018-04-03 08:35:42 +02:00
a7a25fed2b Fix mode switching error on undo
For 2.8 there is already a utility function for this,
wrap it - avoiding an undo step.
2018-04-03 08:05:18 +02:00
751782c8df Correct own error in string lookup 2018-04-03 07:44:37 +02:00
Dalai Felinto
495b21fa0c Move to Collection: Reduce memory leakage
This is really minor but anyways, now it will only leak if you cancel the menu.
And that only if htis is the last time you called this operator before closing
Blender.
2018-04-02 18:52:22 -03:00
Dalai Felinto
89eb9c7f3e Move to Collection: Use automatic fallback name for new collections popup 2018-04-02 17:25:22 -03:00
Dalai Felinto
1f291d5814 Collections: API to get automatic name of new collection 2018-04-02 17:25:22 -03:00
Dalai Felinto
0faa065ed4 Move to Collection: Popup for naming new collection 2018-04-02 17:25:22 -03:00
Dalai Felinto
80e7a48f21 Fix blenderplayer (tm) 2018-04-02 17:24:20 -03:00
31f2a6755d PyAPI: Add PyC_Tuple_Pack_F64 utility 2018-04-02 19:48:34 +02:00
71d7d6cd8c Build: add WITH_OPENVDB_3_ABI_COMPATIBLE option.
Better fix for T54457. It seems Debian compiles OpenVDB without ABI 3
compatibility, while Arch does enable it as is the default in the OpeVDB
CMake build system.

So now there's an option that the distribution can set depending on how
they compile their OpenVDB package.
2018-04-02 19:13:04 +02:00
72c57a755e UI: Fix: Center vertical scrollbar circles. 2018-04-02 18:47:56 +02:00
e1d6e524b3 UI: Perf: Batch Trias with widgets.
This remove another portion of imm calls and reduce overall drawcall count.
2018-04-02 18:47:56 +02:00
4041385ddd Cleanup: remove redundant imbuf return values
Some functions always returned the input argument
which was never used.

This made code read as if there might be a leak.

Now return a boolean (true the imbuf is modified).
2018-04-02 17:34:52 +02:00
b49290be14 Partial fix for T54491: Use a more accurate solution to calculate the frustum boundbox 2018-04-02 12:21:09 -03:00
Milan Jaros
888a04c7e4 Build: fixes for the Intel compiler versions 2016, 2017, 2018.
Differential Revision: https://developer.blender.org/D3109
2018-04-02 16:39:04 +02:00
692aeb6fe0 Cleanup: newlines left in messages 2018-04-02 15:46:31 +02:00
89fdd88906 Merge branch 'master' into blender2.8 2018-04-02 15:18:10 +02:00
57bbd478a5 Cleanup: remove unused view_layer argument 2018-04-02 15:11:53 +02:00
4ffa05c30b Cleanup: move undo into it's own directory
Split out undo API from ED_util.h into ED_undo.h
2018-04-02 15:07:40 +02:00
b186592b21 Cleanup: move BKE_global include under ifdef's 2018-04-02 14:19:44 +02:00
44efbef41e Undo: store active curve shape key in edit-mode 2018-04-02 13:13:57 +02:00
017c731cf3 Logging: use for Python API
Adds categories "bpy.context" & "bpy.rna"
2018-04-02 13:13:57 +02:00
21fcc723e9 imbuf: revert some of the changes of rBb6ba3c682dd6615e760905572a5bcd69bb46371f since they broke the build. 2018-04-01 15:17:17 -06:00
b29ecbfc6b Fix compiling with Alembic
Still need G.main
2018-04-01 19:50:19 +02:00
c0eab1fde5 Workaround for undo steps not storing object modes 2018-04-01 19:33:02 +02:00
557db587b7 Merge branch 'master' into blender2.8 2018-04-01 11:14:09 +02:00
b65ea517eb Merge branch 'master' into blender2.8
- Undo that changes modes currently asserts,
  since undo is now screen data.

  Most likely we will change how object mode and workspaces work
  since it's not practical/maintainable at the moment.

- Removed view_layer from particle settings
  (wasn't needed and complicated undo).
2018-04-01 11:03:25 +02:00
f48895f74a Correct accidental changes by C Logging addition
Error in 891c1cfc9a
2018-04-01 10:23:28 +02:00
473f17b3d5 Resolve unsigned comparison error w/ MSVC 2018-04-01 07:41:23 +02:00
b6ba3c682d Cleanup: remove global header 2018-04-01 07:24:45 +02:00
951d89b7b4 Cleanup: warning 2018-03-31 23:51:38 +02:00
d18116a297 Removed by accident in last commit 2018-03-31 23:47:05 +02:00
651b8fb14e Undo: unified undo system w/ linear history
- Use a single undo history for all operations.
- UndoType's are registered and poll the context to check if they
  should be used when performing an undo push.
- Mode switching is used to ensure the state is correct before
  undo data is restored.
- Some undo types accumulate changes (image & text editing)
  others store the state multiple times (with de-duplication).
  This is supported by checking UndoStack.mode `ACCUMULATE` / `STORE`.
- Each undo step stores ID datablocks they use with utilities to help
  manage restoring correct ID's.
  Needed since global undo is now mixed with other modes undo.
- Currently performs each undo step when going up/down history
  Previously this wasn't done, making history fail in some cases.
  This can be optimized to skip some combinations of undo steps.

grease-pencil is an exception which has not been updated
since it integrates undo into the draw-session.

See D3113
2018-03-31 20:40:37 +02:00
916c91bd08 BLF: Remove debug print
"this is not the commit you're looking for"
2018-03-31 20:33:05 +02:00
4ae7235637 BLF: Fix Vertical/Horizontal layout switch.
This was breaking the first drawcall after a simple/non-simple shader
switch.
2018-03-31 20:26:09 +02:00
c77870fc78 UI: Perf: Batch icons drawcalls together.
For this we use a new shader that gets it's data from a uniform array.
Vertex shader position the vertices using these data.

Using glUniform is way faster than using imm for that matter.

Like BLF rendering, UI icons are always (as far as I know) non occluded and
displayed above everything else. They also does not overlap with texts so
they can be batched at the same time.
2018-03-31 19:43:22 +02:00
4dc0c923fb BLF: Perf: Do not call FT_Set_Char_Size every time.
Using FT_Set_Char_Size is slow. Calling it only when needed is more clever.
2018-03-31 19:32:53 +02:00
f9691bae84 BLF: Perf: Add a kerning cache table for ascii chars.
This adds less than a megabyte of mem usage.
FT_Get_Kerning was the 2nd hotspot when profilling. This commit completly
remove this cost.

One concern though: I don't know if the kerning data is constant for every
sizes but it seems to be the case. I tested different fonts at different
dpi scalling and saw no differences.
2018-03-31 19:32:53 +02:00
91d0825b55 BLI_sort_utils: add pointer sorting callback
Also rename Pointer -> Ptr
2018-03-31 19:25:27 +02:00
ae3a1da1e6 Logging: fix own error with formatting 2018-03-31 15:43:47 +02:00
b237a1c2ea Use int instead of bool
Causes issues when including in some files.
2018-03-31 15:33:15 +02:00
db8e7f9780 Logging: add argument --log-show-basename
Optionally strips leading path from filenames when logging.
2018-03-31 15:29:46 +02:00
5cb440492e Cleanup: --help text output
Some arguments missed their <value>.
2018-03-31 14:53:15 +02:00
22d40fdfd8 Cleanup: blf internal struct naming
- use x/y/width/height/max as a suffix.
- replace 'num' prefix /w 'len' suffix.
2018-03-31 13:40:23 +02:00
0ef38879b3 Cleanup: BLF batch drawing naming
- batching -> batch_draw.
- ct & size -> len.
- start/end -> begin/end (follow GL convention).
2018-03-31 13:11:38 +02:00
ac4513a5b8 Logging: add ability to exclude categories. 2018-03-31 12:52:47 +02:00
5f59c22bf1 Docs: doxygen docs for clog 2018-03-31 12:27:18 +02:00
b8a66973ac Fix clog: own error allocating from static buffer 2018-03-31 11:25:49 +02:00
af11eea3fd Fix logger build w/ MSVC 2018-03-31 09:18:30 +02:00
1ebc14064b Build deps: do sndfile patch also on linux platform 2018-03-31 02:15:13 +03:00
8b74741b9e GWN: Perf: Bypass glUseProgram(0)
I left a flag to quickly debug if something is wrong.
But now that everything uses shader, it seems to be alright since a shader
is always set active before drawing.
2018-03-30 23:27:45 +02:00
ddbde6d1c0 UI: Perf: Do not use implicit Attrib fill. 2018-03-30 22:51:28 +02:00
4241d6a9cc BFL: Fix broken vertical texts.
I've made a separate version of the geom shader that works with full
3D modelviewmat.

This commit also includes some fixup inside blf_batching_start().
2018-03-30 22:50:17 +02:00
96d6a928ab DRW: Add BLF_batch_reset to be able to use BLF inside DRW. 2018-03-30 21:10:24 +02:00
f44d3e83cc UI: Perf: Add BLF batching for File browser and UI blocks.
This batch together most of the calls that can be batch together.
2018-03-30 21:09:24 +02:00
963e48e1df BLF: Add Batching capabilities.
You can now use BLF_batching_start and BLF_batching_end to batch every
drawcall to BLF together minimizing the overhead introduced by BLF and the
opengl driver.

These calls cannot be nested (for now).

If the modelview matrix changes, previously batched calls are issued and a
the process resume with the new matrix.

However the projection matrix MUST not change and gl scissors as well.
2018-03-30 20:59:45 +02:00
fb1463ff2b GPUFramebuffer: Fix assert triggering another assert. 2018-03-30 20:15:03 +02:00
ab9adf9cdc BLF: Use Batch API instead of IMM.
This is not a perfect win just yet. It's now calling glBufferSubData for
every call (instead of using glMapBufferRange which is almost faster), but
with this system we will be able to batch drawcalls together.

See next commit.
2018-03-30 20:09:26 +02:00
8568d38f1b GWN: Add GWN_vertbuf_vertex_count_set.
This allows us to specify a the number of vertices to upload to the gpu.
This is to keep the same allocation on the System Memory but send the least
amount of data to the GPU/Driver.
2018-03-30 20:09:26 +02:00
891c1cfc9a C Logging: use instead of printf for messages
- See `--log` help message for usage.
- Supports enabling categories.
- Color severity.
- Optionally logs to a file.
- Currently use to replace printf calls in wm module.

See D3120 for details.
2018-03-30 18:57:41 +02:00
c647c93f63 build_deps: Disable building docs for OIIO
Two issues are fixed with this commit:

1) When we build OIIO (on unixoid build environments) and no /src/doc/oiiotool was present we had no build target for it (which led to a build error). As we don't need docs for OIIO, we disable it now.

2) We specified a var that OIIO does not recognize (was removed upstream a long time ago): ILMBASE_VERSION.
2018-03-30 15:22:40 +02:00
Dalai Felinto
cc69831796 Select Grouped: Collection Part II
Selecting not only the objetcs directly linked to the selected collection.
So we also do it for the objetcs in the nested collections, just as we can
do from the outliner.
2018-03-29 20:03:47 -03:00
Dalai Felinto
41a81fece4 Collections: API to select all scene collection objects 2018-03-29 20:03:47 -03:00
Dalai Felinto
534916258d Select Grouped: Collection Part I
Use Shift+G > Collection. If there is only one collection, it just selects it,
if there are multiple ones user get to pick which one to select.

This is the same behaviour we have for groups. Note, we only select objects
directly in the collection, not the ones in any nested collection.

Feature suggested by Pablo Vazquez (venomgfx)
2018-03-29 20:03:47 -03:00
Dalai Felinto
024395170c Fix typo in outliner Select Objects tooltip 2018-03-29 20:03:47 -03:00
Dalai Felinto
156b548208 Collections: API to get collection from index 2018-03-29 20:03:47 -03:00
Dalai Felinto
1251043636 Collections: API to check if object is in collection 2018-03-29 20:03:47 -03:00
ee2aa31982 PyDoc: Merge manual docs for bge.texture
https://docs.blender.org/manual/en/dev/game_engine/python_api/videotexture.html

Had a few things that this file did not while this file having things the other did not.
To fix, I merged both documents into the python api.
2018-03-29 18:02:04 -04:00
b882257fbd BLF: Reduce the size of the buffer requested to IMM.
There is no point to not call strlen if the number of char is large.
2018-03-29 21:32:26 +02:00
7144fdf285 BLF: Perf: Divide by 6 the amount of verts sent to the GPU.
This means smaller imm buffer usage.

This does not reduce the number of drawcalls.

This uses geometry shader which is slow for the GPU but given we are really
CPU bound on this case, it should not matter.

A perfect implementation would:
- Set the glyph coord in a bufferTexture and just send the glyph ID to the
  GPU to read the bufferTexture.
- Use GWN_draw_primitive and draw 2*strllen triangle and just retrieve the
  glyph ID and color based on gl_VertexID / 6.
- Stream fixed size buffer that the Driver can discard quickly but this is
  the same as improving IMM directly.
2018-03-29 21:32:26 +02:00
c48b6fae9a GWN: Add immVertex4f. 2018-03-29 21:32:26 +02:00
354dfdac88 UI: Edit mode move edge data tool into a menu
UI: Edit mode move edge data tool into a menu

See also:

- D1741
- T46853

Reviewers: Severin, meta-androcto, campbellbarton

Subscribers: mont29, #user_interface

Tags: #user_interface

Differential Revision: https://developer.blender.org/D2259
2018-03-29 14:26:49 -04:00
0f6d52cd29 PyDocs: Adde link to Wikipedia page for mathutils.Euler class
This update adds a link to the Wikipedia article "Euler angles" to the description of the mathutils.Euler class.
I initially was not sure what a "Euler" represented in Blender API, but found the Wikipedia article helpful. I believe others will find the link helpful too if it appears in the class documentation.

This is similar to the Wikipedia links that appear in the mathutils.Matrix class, e.g: https://docs.blender.org/api/blender_python_api_current/mathutils.html?highlight=euler#mathutils.Matrix.adjugate

Author: @justasb

Reviewers: campbellbarton, trumanblending, Blendify

Reviewed By: Blendify

Subscribers: Blendify

Tags: #bf_blender

Differential Revision: https://developer.blender.org/D3077
2018-03-29 14:25:13 -04:00
Julian Eisel
b3ef5a04d1 Cleanup: Use uppercase UI_ prefix for external functions
Using uppercase prefixes is our convention for external functions.
"External" as in functions exposed to the outside of interface/ directory.
2018-03-29 17:21:02 +02:00
Julian Eisel
973eeff2ea Fix Blenderplayer compile error 2018-03-29 17:15:35 +02:00
8b45fd8b61 UI: Fix out of bound read catched by asan. 2018-03-29 16:46:28 +02:00
d93e7e6430 UI: Perf: Group fill/border/emboss batches together.
This roughly halves the number of drawcalls from widgetbase_draw.
2018-03-29 16:36:01 +02:00
Dalai Felinto
26b9c502ed Merge remote-tracking branch 'origin/master' into blender2.8
Fix for T54437: Sequencer preview uses last updated scene

The fix started in master, moving EvaluationContext initialization
before we leave `deg_evaluate_on_refresh()`.

Upon merging master we can fix the actual issue which was to set
the EvaluationContext depsgraph even if the depsgraph was already updated.
2018-03-29 10:36:34 -03:00
Dalai Felinto
11130970c6 Merge commit 'origin/master^' into blender2.8 2018-03-29 10:36:01 -03:00
Dalai Felinto
9f60c850f9 Depsgraph: initialize EvaluationContext even if nothing to update
This is required to T54437 (sequencer preview uses last updated scene).
Although the fix itself needs to be in 2.8, for the 2.8 specific
initialization code.
2018-03-29 09:56:09 -03:00
f6ad538040 UI: Perf: widgetbase: Replace imm usage by a batch cache.
Introduce a UI batch cache. For the moment it's only used by widgetbase so
leaving it interface_widgets.c. If it grows, it can have its own file.

Like all preset batches (batches used by UI context), vaos must be refreshed
each time a new window context is binded.

This still does 3 GWN_batch_draw in the worst cases but at least it does
not use the IMM api.

I will continue and batch the 3 calls together since we are really CPU
bound, so shader complexity does not really matters.

I cannot spot any difference on all the widgets I could test. I did not use
any unit tests so I cannot tell if there is really any defects.

This is not a complete rewrite but it adresses the top bottleneck found
after a profilling session.
2018-03-29 14:22:50 +02:00
ba9c2746b6 GPUShader: Add specialized widget base shader.
This vertex shader let us draw widgets with batches instead of imm calls.
2018-03-29 14:22:50 +02:00
3c48a21833 GWN: Batch: Add GWN_batch_uniform_4fv_array 2018-03-29 14:22:50 +02:00
8301b26452 EEVEE: Fix bad framebuffer configuration
Was causing black / corrupted scene because of broken downsample

Add a debug check to not run into this problem again.
2018-03-29 13:43:30 +02:00
72b4d444f6 Particles: Fix missing hair dynamics
Only if all the nasty looking bugs had such a simple solution...
2018-03-29 12:43:00 +02:00
44cd24a9ce Particles: Remove dedicated recalc field from ParticleSettings
Use more generic id->recalc flag.

Also sanitize flag flush from settings to particle system.
Need to do such flush before triggering point cache reset, since
point cache reset will do some logic based on what flags are set.

This will solve crash caused by threaded update which will set
some bitflags while point cache reset is in progress.
2018-03-29 12:41:11 +02:00
526719bccb Cleanup, silence compiler warning in release build 2018-03-29 12:40:23 +02:00
95b9680597 Draw manager: Make particle code drawing closer to old viewport
The way how particle state is to be accessed or used did not change
in Blender 2.8, so the drawing code should follow old design.

This code is somewhat duplicated from drawobject.c, but old draw
code is on the way to be removed anyway.

This fixes issue with disappearing particles when tweaking number
of particles.
2018-03-29 12:31:32 +02:00
0cbf747ffa Draw manager: Make evaluation context a part of context state
This way we don't have to re-initialize the full evaluation
context in every area we need it.
2018-03-29 12:18:07 +02:00
3177023104 Draw manager: Use C99 struct initialization
Allows us to easily add fields which we never want to
be initialized, but still keep sane order of fields in
the structure itself.
2018-03-29 12:07:11 +02:00
90e1a5fd27 Draw manager: Use utility functions for dealing with state memset 2018-03-29 11:43:42 +02:00
f42c6960d2 Draw manager: Cleanup, early output
Do early output and reduce level of indentation.
2018-03-29 10:34:42 +02:00
05c76990c8 Depsgraph: Tag datablock with original update flag
Tagging based on components might not be granular enough.

For example, for particles we would want to know what part
of particles was changed exactly. For the flushing we wouldn't
worry too much, because we will want less granular updates
there anyway.
2018-03-29 10:08:56 +02:00
ca5f3dd220 Fix T54457: build error with OpenVDB versions newer than 3.
Solution provided by Sven-Hendrik Haase.
2018-03-29 07:21:35 +02:00
52302757cd Fix T54455: OpenCL build error after recent changes. 2018-03-29 07:14:09 +02:00
Matt Heimlich
e3f1d98098 Cycles: take into account diffuse roughness for roughness baking.
Roughness baking previously defaulted to 1.0 for all diffuse materials,
now we also bake roughness values of Oren-Nayer and Principled Diffuse.

Differential Revision: https://developer.blender.org/D3115
2018-03-28 23:45:15 +02:00
Dalai Felinto
6456d59b6b Move to Collection - Add new collection
Include option to create new collection and move objects to this
collection.

Based on suggestion by Pablo Vazquez (venomgfx) and my own feedback.
2018-03-28 17:15:33 -03:00
Dalai Felinto
ba90597f22 Move to Collection - Skip Master Collection nested level
Have the Master Collection always opened. This removes one level of nesting.
As suggested by Pablo Vazquez (venomgfx).
2018-03-28 17:15:01 -03:00
Dalai Felinto
f167226b79 Move to Collection - initial operator
How to use: Select a few objects, and press "M" in the viewport.

If you hold ctrl the objects will be added to the selected collection.
Otherwise they are removed from all their original collections and moved
to the selected one instead.

Development Notes
=================
The ideal solution would be to implement an elegant generic multi-level
menu system similar to toolbox_generic() in 2.49.

Instead I used `uiItemMenuF` to acchieve the required nesting of the menus.

The downside is that `uiItemMenuF` requires the data its callback uses to be
always valid until the menu is discarded. But since there is no callback we
can call when the menu is discarded for operators that exited with
`OPERATOR_INTERFACE`.

That means we are using static allocated data, that is only freed next time
the operator is called. Which also means there will always be some
memory leakage.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D3117
2018-03-28 17:14:51 -03:00
1953de335e Cleanup: Tooltip spelling 2018-03-28 13:09:00 -04:00
1b6bf5b75e build_deps: disable hdf5 lib support
we do not ship with hdf5 support for alembic on any of the platforms.
2018-03-28 10:48:52 -06:00
8afc9c1e7d Fix Collada: broken tangents with Camera Animation import for xfov
When importing an xfov curve, we must transformed the data to
Lens opening angles in degrees. While the curve value itself is
correctly transformed, the transformation of the tangents has been
forgotten. this is fixed now.
2018-03-28 18:01:32 +02:00
Jeff Witthuhn
bc3a55c343 Cycles: don't require pthreads as dependency on Windows.
Use C++11 threads when available, and native critical section on Windows.
Later on we can remove pthread code when C+11 becomes required.

Differential Revision: https://developer.blender.org/D3116
2018-03-28 12:13:04 +02:00
205fe8afd7 Clay: Remove warning. 2018-03-28 11:33:23 +02:00
e49d66f22c Cleanup: typo in function name 2018-03-28 11:23:38 +02:00
a970ac5d55 BLI_array: utility to check memory is zerod 2018-03-28 11:13:54 +02:00
4bd5b824b0 Fix missing confirm quit dialog on macOS, after recent changes. 2018-03-28 10:54:17 +02:00
be587d76ef Cycles: Fix bad register cast in sseb
This is currently unused code, but causes gcc-8 to fail.
2018-03-28 10:34:31 +02:00
873c23456b UI: Perf: Don't use implicit Attrib.
Implicit attrib is doing memcpy which seems to be slower compared to
individual immAttrib*.

Only fixed the ones who appeared in my profilling logs.
2018-03-28 00:05:57 +02:00
0acf655f9d UI: Perf: Group drawcalls inside ui_draw_panel_dragwidget
16 Drawcalls > 1 Drawcall

Do I need to say more?
2018-03-28 00:05:57 +02:00
637993fafe UI: Perf: Make icon_draw_texture use GWN_draw_primitive.
This bypass the use of immediate mode for theses drawcalls. Placement and
and icon select (via uvs) is done inside the vertex shader.
2018-03-28 00:05:51 +02:00
3bb720a7de GPUShader: Cleanup: Remove unused uniform_interface. 2018-03-27 23:51:23 +02:00
7a94d4362a DRW: Opti: Make cursor use batch instead of immediate API.
This is also much cleaner and taking 1 drawcall instead of 2.
2018-03-27 23:50:26 +02:00
2117680094 UI: Fix assert cause by vertex count being too small. 2018-03-27 17:58:05 +02:00
2cbd7cc269 UI: Perf: Optimize widgetbase_draw.
Drawcall per window redraw on default layout:
- 4100+ without patch
- 1270 with patch

Theses drawcalls meant a lot of driver overhead since they each correspond
to one glMapBuffer which is slow.
2018-03-27 17:03:42 +02:00
e4d82c0dcf Fix T54435: Quit prompt fails w/ fractional scale 2018-03-27 16:46:10 +02:00
90b7bcb48d Merge branch 'master' into blender2.8 2018-03-27 15:09:00 +02:00
e22b870b4a Cleanup: global undo (minor changes to internals)
- Get memory usage from MemFile instead of MEM API
  avoids possible invalid when threads alloc memory.
- Use size_t instead of uint and uintptr_t to store size.
- Rename UndoElem.str -> filename
- Rename MemFileChunk.ident -> is_identical
2018-03-27 14:56:54 +02:00
ddecf23711 Merge branch 'master' into blender2.8 2018-03-27 07:08:58 +02:00
3bca1ef26b Cleanup: move paint curve undo into own file 2018-03-27 07:06:14 +02:00
a7aee250b8 Fix T54420: too much volume render noise with multiple volume objects.
Random numbers for step offset were correlated, now use stratified samples
which reduces noise as well for some types of volumes, mainly procedural
ones where the step size is bigger than the volume features.
2018-03-27 01:08:30 +02:00
17a4a5a553 Eevee Shaders: Fix "No matching overloaded function"
invert -> inverse
2018-03-26 19:11:02 -03:00
dff7f55cd0 GPUFramebuffer: Fix compiler warning about return value. 2018-03-26 17:54:46 +02:00
fc348a563e Fix bad merge resolution from previous commit 2018-03-26 14:59:55 +02:00
21aca14e43 Merge branch 'master' into blender2.8 2018-03-26 14:56:00 +02:00
3c45fdd171 GHOST: Solve compilation error of test programs 2018-03-26 14:51:56 +02:00
64e5f83133 BLF: Don't use user preferences
BLF is a low level module, which might (and is) used without Blender.

Thanks Campbell for review!
2018-03-26 14:49:23 +02:00
0476f8277a BLF: Cleanup, indentation inside of preprocessor 2018-03-26 14:07:19 +02:00
13f80a152a Fix T53800: Bad data editing during DEG evaluation?
Remain convinced that it should not be possible for undo code to run in
parallel with DEG eval... But for now, this whould prevent static
override code to dive into this collection.
2018-03-26 10:41:31 +02:00
0c49d83b49 Eevee: Use named EEVEE_EffectsFlag for effects flag. 2018-03-26 10:02:53 +02:00
b9ec7a9272 Eevee: Fix feedback loop warning. 2018-03-26 10:01:46 +02:00
92b61dc16d GPUTexture: Fix compilation issue. 2018-03-26 09:59:12 +02:00
41852c8a8c DRW: Fix crash/broken Metaballs display. 2018-03-25 20:06:12 +02:00
42b5328c36 DRW: Rename DRW_shgroup_uniform_buffer into DRW_shgroup_uniform_texture_ref
This is in order to not mix it with the incomming buffer textures.
2018-03-25 20:06:12 +02:00
94dd81941f DRW: Remove mentions of DRWInterface.
Theses are no longer relevant. Better talk about shgroup directly.
2018-03-25 20:06:12 +02:00
bc15ec0896 GPUFramebuffer: Refactor (Part 2)
This refactor modernise the use of framebuffers.
It also touches a lot of files so breaking down changes we have:
 - GPUTexture: Allow textures to be attached to more than one GPUFrameBuffer.
   This allows to create and configure more FBO without the need to attach
   and detach texture at drawing time.
 - GPUFrameBuffer: The wrapper starts to mimic opengl a bit closer. This
   allows to configure the framebuffer inside a context other than the one
   that will be rendering the framebuffer. We do the actual configuration
   when binding the FBO. We also Keep track of config validity and save
   drawbuffers state in the FBO. We remove the different bind/unbind
   functions. These make little sense now that we have separate contexts.
 - DRWFrameBuffer: We replace DRW_framebuffer functions by GPU_framebuffer
   ones to avoid another layer of abstraction. We move the DRW convenience
   functions to GPUFramebuffer instead and even add new ones. The MACRO
   GPU_framebuffer_ensure_config is pretty much all you need to create and
   config a GPUFramebuffer.
 - DRWTexture: Due to the removal of DRWFrameBuffer, we needed to create
   functions to create textures for thoses framebuffers. Pool textures are
   now using default texture parameters for the texture type asked.
 - DRWManager: Make sure no framebuffer object is bound when doing cache
   filling.
 - GPUViewport: Add new color_only_fb and depth_only_fb along with FB API
   usage update. This let draw engines render to color/depth only target
   and without the need to attach/detach textures.
 - WM_window: Assert when a framebuffer is bound when changing context.
   This balance the fact we are not track ogl context inside GPUFramebuffer.
 - Eevee, Clay, Mode engines: Update to new API. This comes with a lot of
   code simplification.

This also come with some cleanups in some engine codes.
2018-03-25 20:06:12 +02:00
f937123116 GPUFramebuffer: Refactor (part 1)
Move some DRWFramebuffer functions to GPUFramebuffer.
2018-03-25 20:06:12 +02:00
e5ee1ed818 Basic Engine: Remove unneeded use of Framebuffers. 2018-03-25 20:06:12 +02:00
9c1ab47fc4 GPUOffscreen: Remove unused offscreen blit. 2018-03-25 20:06:12 +02:00
619d977e1a GPULamp: Move GPU_frambuffer_blur to GPU_lamp.c
This is a bit useless because gpu lamps are only used by the game engine
and it is planned to be "remove" in some way.

Doing this to clean gpu_framebuffer.c.
2018-03-25 20:06:12 +02:00
4c66068790 GPUFramebuffer: Make current framebuffer thread local.
This make sense since we are using multiple olg contexts and two contexts
can be active at the same time with different framebuffers.
2018-03-25 20:06:12 +02:00
a78f5accbb GPUTexture: Style: Respect 120 char per line limit. 2018-03-25 20:06:12 +02:00
37a7cd8344 GPUViewport: Small simplifications + fixes.
- Use GPU_SHADER_2D_IMAGE_ALPHA.
 - Add alpha uniform.
 - bypass reseting the scissors and depth test because we used
   another context for drawing.
2018-03-25 20:06:12 +02:00
6d6c292cf8 Clay: Fix alpha problem cause by FXAA pass. 2018-03-25 20:06:12 +02:00
f63bb98223 GPUViewport: Remove depth debug.
This is not used anymore.
Debug visualisations should be moved to the draw manager.
2018-03-25 20:06:12 +02:00
b1c025d1e8 GPUTexture: Small refactor.
This includes a few modification:
 - The biggest one is call glActiveTexture before doing any call to
   glBindTexture for rendering purpose (uniform value depends on it).
   This is also better to know what's going on when rendering UI. So if
   there is missing UI elements because of this commit look for this first.
   This allows us to have "less calls" to glActiveTexture (I did not
   measure the final count) and less checks inside GPU_texture.

 - Remove use of GL_TEXTURE0 as a uniform value in a few places.

 - Be more strict and use BLI_assert for bad usage of GPU_texture functions.

 - Disable filtering for integer and stencil textures (not supported by
   OGL specs).

 - Replace bools inside GPUTexture by a bitflag supporting more options to
   identify texture types.
2018-03-25 20:06:11 +02:00
879eabedda DRWTexture: Remove DRW_texture_update 2018-03-25 20:06:11 +02:00
b9962d0070 DRW: Remove unecessary push/pull attrib.
Since we are rendering draw manager's command in a separate context, we
don't need to save/restore the UI opengl state attributes/config.
2018-03-25 20:06:11 +02:00
e02480fd16 GPU: gpu_draw.c: Fix wrong renaming.
Renaming happened in b4d053efc7 and seems to have been a bit too
agressive.
2018-03-25 20:06:11 +02:00
31bf6edf79 Text: line break always returned cancelled
Harmless but incorrect.
2018-03-25 17:51:49 +02:00
977a4e7f5d Text: re-allocate exact lengths for undo
Undo sometimes reserved too much space in the buffer,
now assert when this happens and allocate the exact size needed.

Note prepares for moving text editor undo out of the text block (D3113)
which will split the undo buffer into a list of undo steps.
2018-03-24 14:27:31 +01:00
3f9d5ea0ec Fix text editor undo w/ 4+ byte utf8 characters 2018-03-24 14:14:19 +01:00
9d1de621e2 Cleanup: move undo opcodes out of public header 2018-03-24 12:46:25 +01:00
19f148d9d0 PyDoc: Add docutils ref for "registration"
This will be used to link to from the manual.
2018-03-23 20:25:30 -04:00
Julian Eisel
357b72e0a7 Theming: Use list-item colors for all un-embossed buttons in list-items
E.g. number buttons in the shape key list would use theme colors of text
widgets.

Addresses T50862.
2018-03-23 20:46:51 +01:00
a7e4268bee UI: restore quit confirmation when dialog disabled 2018-03-23 17:32:13 +01:00
0c753c1dc4 RNA comparison/override: better control over property processing.
This commit essentially introduces a new RNA property flag, which when
set prevents affected property from being processed at all in comparison
code (also used to automatically generate static override rules).

The idea is to use it on very low-level data in RNA, like e.g. mesh's
geometry or psys' particles collections.

For now only applied to psys' particle collections, on the main mesh of
Agent327 pigeon, it goes from 100ms to 0.5ms on a full
auto-override-generating comparison...

Also added some new RNA property helper funcs to check on comparable and
overridable status.
2018-03-23 16:35:53 +01:00
15af75d79e msvc: Fix msvc2013 new despgraph related build errors.
msvc's function.hpp does not like NULL for function pointers. disabled support for this platform.
2018-03-23 09:23:08 -06:00
21f16bb93e Merge branch 'master' into blender2.8 2018-03-23 15:25:27 +01:00
4f8e407086 Libmv: Fix compilation error on Windows 2018-03-23 15:05:08 +01:00
ab48e6355d Glog/gflags: Reduce amount of local modifications
With better directory layout and more proper include
statements we can avoid several local modifications,
such as changing config.h for Windows Glog and the
ones related on pass-through statements in logging
headers in Glog.

This commit also makes unused functions not-a-warning
for external code.
2018-03-23 14:38:02 +01:00
Julian Eisel
60712d12eb UI: 4-column layout for the editor-type selector menu
The list of editor-types is rather long by now, so better to arrange them into
sections.

Original patch by @jeske with updates by @Blendify and myself.
Design Task: T36028
Patch: D3112
2018-03-23 14:28:46 +01:00
8eb8aa4939 Merge branch 'master' into blender2.8 2018-03-23 12:05:55 +01:00
da00a50f7f Merge branch 'master' into blender2.8 2018-03-23 11:56:14 +01:00
7cc2b27099 Cleanup: stray tabs
Tabs in middle of code (mostly for no reason / by accident).
2018-03-23 11:51:19 +01:00
f2f32c81d4 Cleanup: doxy header, line length 2018-03-23 11:28:25 +01:00
72c43e0285 Cleanup: move image undo into own file 2018-03-23 09:15:23 +01:00
Julian Eisel
529c21acc2 Fix issues with confirmation prompt on Windows
* Pressing "OK" wouldn't close Blender anymore
* Using File -> Quit would use popup version, not OS native window

Cleaned up code a bit to avoid duplicated logic.
2018-03-23 02:00:14 +01:00
Julian Eisel
aeec19d2e7 Fix own mistake from 4cb4556fa5
Trying to close Blender from a second window wouldn't work, the first window
would have to be hovered first. Ouch!
2018-03-22 23:52:38 +01:00
Julian Eisel
a4ea46ffc5 Fix memory leaks when doing "Save & Quit"
Steps to reproduce were:
* Open Blender (no need for factory settings, "Promt Quit" needs to be enabled)
* Edit the file (e.g. translate some object)
* Quit Blender but don't skip quit promt
* Press "Save & Quit"
* Save the file

Not sure if Windows supports the "Save & Quit" behavior, so this may not have
applied to Windows.
2018-03-22 23:29:48 +01:00
Julian Eisel
4cb4556fa5 Fix T48027: Memory leaks when exiting Blender from menu
You only had to close Blender through File -> Quit.

Leaks happened because WM_exit() was called from within operator, UI wasn't able
to free some of it's heap data then. This data was the handler added in
uiTemplateRunningJobs() and the IDProperty group added in uiItemFullO_ptr_ex().
There was obviously a general design issue which only became visible in this
specific case.

We now delay the WM_exit call by wrapping it into a handler that gets registered
as usual. I didn't see a better way to do this, all tricks done in
ui_apply_but_funcs_after() to prevent leaks didn't work here. In fact they may
be redundant now, but am not brave enough to try ;)
2018-03-22 23:25:28 +01:00
2ee4e9761f GPUCompositing: Remove last reference to gpu_shader_fullscreen_vert.glsl
It was breaking compilation with MSVC apparently.
2018-03-22 22:39:24 +01:00
150ad2238c PyDocs: Fix link syntax 2018-03-22 16:38:53 -04:00
0080878d67 Merge branch 'master' into blender2.8 2018-03-22 19:21:36 +01:00
Dalai Felinto
e5e686a667 Fix build (BLI_array_len/_count) 2018-03-22 14:37:59 -03:00
897a21e6a3 Glog: Restore some custom config for MSVC2015 2018-03-22 17:48:36 +01:00
4486eddfaa GLog: Tweak settings according to our config
We do have gflags.
2018-03-22 17:32:51 +01:00
c9e7e1987b Glog: Workaround mess around windows and non-windows headers
Seems we can not use include directories order trick, since
files are included form inside ".." string, which forces current
directory to be checked first.
2018-03-22 17:26:02 +01:00
9f45f1a6b7 GFlags: Fix usage of unused attribute 2018-03-22 17:19:56 +01:00
2a4c40f4b9 Glog: Attempt to fix compilation error on Windows
Ideally it should be possible without hacking into sources files
of Glog itself.
2018-03-22 17:02:16 +01:00
0bce7186f7 Glog: Restore haiko OS 2018-03-22 16:58:23 +01:00
27d9863fa5 Fix T54172: Avoid jumping panel length during playback 2018-03-22 11:42:35 -04:00
18e2a5df1a Merge branch 'master' into blender2.8 2018-03-22 16:41:37 +01:00
69b327d8dc Depsgraph: Report new depsgraph evaluation time
Timing is printed to the console when running with --debug-depsgraph-time.
2018-03-22 16:40:32 +01:00
d554b8a748 UI: skip confirmation menu on quit prompt to save 2018-03-22 16:24:14 +01:00
47acd706fd GPUCompositing: Remove entire module.
This module has no use now with the new DrawManager and DrawEngines and it
is using deprecated paths.

Moving gpu_shader_fullscreen_vert.glsl
to draw/modes/shaders/common_fullscreen_vert.glsl
2018-03-22 16:11:49 +01:00
161393805f Update Google libraries
This commit updates:

- gflags 2.2.0 -> 2.2.1
- glog 0.3.4 -> 0.3.4
- gmock 1.7.0 -> 1.8.0
- gtest 1.7.0 -> 1.8.0
2018-03-22 16:10:08 +01:00
cfe43f8d1a Fix T54360: FFMPEG bitrate not editable for all codecs
The bitrate selection was hidden when a CRF mode was chosen and then
switched to a codec that doesn't support CRF.
2018-03-22 14:47:22 +01:00
e35f964daa Cleanup: Use more python way of checking boolean 2018-03-22 09:33:15 +01:00
865fbe343a Fix T54348: Bone dissolve gives invalid hierarchy
Disconnected bones weren't handled correctly.
2018-03-22 07:50:58 +01:00
ce51066e47 Fix bone dissolve using wrong envelope radius
Also correctly copy bone tip selection when dissolving.
2018-03-22 07:50:03 +01:00
6939523a15 Fix T54203: crash changing engine w/ project-paint 2018-03-21 16:51:56 +01:00
a6914d8f33 Eevee: Fix missing camera animation with CoW 2018-03-21 16:39:00 +01:00
5c08d17423 Draw manager: Fix missing active camera triangle with CoW 2018-03-21 16:31:10 +01:00
d33d6d0e06 GHOST CONTEXTWGL: Remove unused member
No longer used from this commit: https://developer.blender.org/rB0940e89e604d85d717f792b73e30e5e96a42e7c6#change-kg3gZvqkYPB6
2018-03-21 12:30:36 -03:00
69eb452622 Merge branch 'master' into blender2.8 2018-03-21 16:27:48 +01:00
3ea8710b9d Depsgraph: Remove redundant operation nodes
Rather a mistake since previous merge.
2018-03-21 16:12:36 +01:00
5ba5254ec1 UI: Optional prompt to quit for non win32 systems
D566 by @januz

Use Blender native dialog when OS dialog's aren't supported.
2018-03-21 16:04:01 +01:00
75c6119dc9 Fix: GWN Indexbuf creation was replacing the index buff bound to the last VAO
This led to problems such as the drawing of the navigate manipulator.
More details in the code comments.
2018-03-21 11:55:38 -03:00
cac2415d82 Merge branch 'master' into blender2.8 2018-03-21 12:47:13 +01:00
23ffd4ec39 Tracking: Make object created form tracks active and selected 2018-03-21 12:33:04 +01:00
658fb7f453 Tracking: Warn when no tracks are selected when creating mesh
Makes it more clear why mesh was not created this way.

Fixes T54368: 3D markers to mesh In MovieClipEditor Not working.
2018-03-21 12:30:50 +01:00
1e43665a39 Fix T54378: Drivers fail with property from empty
Empties were missing Parameters component.
2018-03-21 12:17:51 +01:00
f3efa2526d Fix T54366: Custom manipulator acts on linked data 2018-03-21 07:26:58 +01:00
Julian Eisel
7701f9e35c Fix crash when changing workspaces
Steps to reproduce were:
* Append a workspace (via '+' icon) - make sure its from the default workspaces.blend
* Activate it
* Should crash

Was accessing data from view-layer which wasn't updated yet (and thus could be
NULL). Crash occured after rB8153f89518b4a.

@campbellbarton, you may want to check if all object-mode stuff still works as
expected, not sure what's the state of it.
2018-03-20 23:31:44 +01:00
Dalai Felinto
89aa4b1604 Link and expand overrides for collections
This code was neglected. Yet it is needed for when we support datablock
overrides so that the ID pointers are properly linked and expanded.
2018-03-20 14:48:54 -03:00
504319239a Cleanup: remove useless static override reference pointer from ID struct. 2018-03-20 18:12:45 +01:00
410410f57b Add basic read-only RNA access to static override data.
Will make investigating issues much, much easier!
2018-03-20 18:12:45 +01:00
8a94a82934 Fix broken tatic verride detection in RNA collections.
We have to check all items of a collection when we want to create
overrides as needed...
2018-03-20 18:12:45 +01:00
d03223850e Fix build error on Windows 32 bit. 2018-03-20 17:11:14 +01:00
e0388bc61a Merge branch 'master' into blender2.8 2018-03-20 16:55:16 +01:00
69e35429bf Remove debug only code from previous commit 2018-03-20 16:54:50 +01:00
a5bb918392 Memory allocator: Clarify consistency check function
Also make it to return truth when everything is good and
false otherwise.
2018-03-20 16:51:33 +01:00
ebbb55dd80 Depsgraph: Fix memory leak when datablock is not reused
It is possible that datablock will not be re-used for the new
dependency graph building. Freeing function was freeing all
the nested pointers of databnlock, but not datablock memory
itself.
2018-03-20 16:07:27 +01:00
c188ab7b67 Depsgraph: Prevent non-expandable datablocks from being freed
This avoids original image datablock destruction when using
copy on write.
2018-03-20 16:07:27 +01:00
4f97f58513 MSVC: Fix lite build.
MSVC still defines __cplusplus as 199711L until it's in full conformance with the newer c++ standards, however the things we need from the standard are fully supported, hence a check for the msvc version was needed.
2018-03-20 08:26:11 -06:00
cdf0df10a6 DRW: Fix bound_ubo_slots allocation size. 2018-03-20 15:16:10 +01:00
8a9be95cfb DRW: Fix ubo binding code. 2018-03-20 15:08:23 +01:00
09c88fed1f Fixed: cache clearing when using multiple Alembic files. 2018-03-20 12:54:48 +01:00
1782abf6e2 Fix BLI_assert for MSVC
Also use `_BLI_ASSERT` prefix for internal defines.
2018-03-20 11:56:11 +01:00
04b8b1a167 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/library_query.c
2018-03-20 11:33:59 +01:00
60ff803998 Fix missing ID pointer handling in materials in ID remapping code. 2018-03-20 11:32:16 +01:00
46a391b668 Fix missing array duplication when copying material
Texture paint slots were copied as a pointer, causing double-free.
2018-03-20 11:22:47 +01:00
1662c514c0 Cleanup: unused variables
Missed in own recent changes.
2018-03-20 08:03:58 +01:00
c8a7c4f245 Merge branch 'master' into blender2.8 2018-03-20 16:13:37 +13:00
8e5c407fc4 Fix compile error with MSVC2013 - Can't use __func__ (from BLI_assert) in inlined functions
ERROR: blenlib/intern/math_base_inline.c:371 - '__func__' : undeclared identifier (C:\blenderdev\master2\blender\source\blender\editors\lattice\editlattice_tools.c)  [C2065]
2018-03-20 16:03:43 +13:00
Bogdan Nagirniak
b65933e7b3 Fix T54019: copying and linking bugs with custom ID pointer properties. 2018-03-19 22:14:02 +01:00
84536d1d3c GPU Bufferes: Small optimization when updating buffers
With the API recently added to gawain, it is now possible to update the vbos linked to the batch.
So the batch does not have to be destroyed.
The optimization is more sensitive when sculpt is made on low poly meshs
2018-03-19 18:09:00 -03:00
Matthias Ellerbeck
8ecf35d850 Fix T54240: automatic node link moving should take into account type.
Without this a "Clearcoat" link could be moved to "Clearcoat Normal"
for example, which doesn't make much sense.

Differential Revision: https://developer.blender.org/D3105
2018-03-19 21:52:49 +01:00
148b0fef09 Fix T54317: overlapping volume render bug after recent changes.
Increasing the samplig dimensions like this is not optimal, I'm looking
into some deeper changes to reuse the random number and change the RR
probabilities, but this should fix the bug for now.
2018-03-19 21:22:15 +01:00
fddb4dee8a Fix T54356: volume rendering bug using just color attribute. 2018-03-19 21:22:15 +01:00
254bb922e8 Cleanup: avoid passing bContext to particle API
Also add EvaluationContext to PEData
2018-03-19 19:04:50 +01:00
402486ea7b Merge branch 'master' into blender2.8 2018-03-19 18:18:49 +01:00
b8eca8e07d Cleanup: use utility header for particle looping 2018-03-19 18:18:04 +01:00
5e81d993af Merge branch 'master' into blender2.8 2018-03-19 18:14:05 +01:00
a3486e735f Cleanup: move particle undo into own file
Also avoid extern declarations which can get out of sync.
2018-03-19 17:46:49 +01:00
a5fc0ae150 Cleanup: move armature undo into own file 2018-03-19 17:45:20 +01:00
566f4e06ba Cleanup: move metaball undo into own file 2018-03-19 16:59:34 +01:00
e7ca9d3477 Cleanup: move curve undo into own file 2018-03-19 16:30:53 +01:00
b5bf3011bf GWN: Vertex Buffer: Remove the use of glMapBufferRange
We revert to the malloc/realloc and manually manage the upload.
There seems to be a performance penalty from using glMapBuffer on some
hardware, prefering way is glBufferData(NULL) with glBufferSubData.
2018-03-19 16:13:00 +01:00
c78ebf9f26 Cleanup: split lattice into own library
Was mixed with object functionality.
2018-03-19 15:45:50 +01:00
772e558e92 GWN: Perf: Use unsync glMapBufferRange to prevent sync time. 2018-03-19 14:14:32 +01:00
f2ae7796c3 GWN: Context: Use <unordered_set> instead of <forward_list>
We cannot have duplicates so unordered_set is better suited for this case.

Removing batches is now constant time on average instead of linear.
2018-03-19 14:14:32 +01:00
cf8028e4a9 Merge branch 'blender2.8' into temp-object-multi-mode 2018-03-19 11:18:17 +01:00
8859927e6f Merge branch 'master' into blender2.8 2018-03-19 11:17:52 +01:00
7ed100f13f Merge branch 'blender2.8' into temp-object-multi-mode 2018-03-19 11:15:37 +01:00
342a18287f Cleanup: type conversion warning 2018-03-19 09:12:48 +01:00
7729966af1 Fixed typo Python API
`mathutils.geometry.barycentric_transform` used `tri_a[1-3]` for the
target triangle, but in fact they are `tri_b[1-3]`
2018-03-19 08:19:48 +01:00
e95282e783 Merge branch 'master' into blender2.8 2018-03-18 16:05:02 +01:00
0301df40e5 Fix ugly recursive pattern in RNA PointCache data layout.
PointCache was having a collection of items of PointCache type, having a
collection of items of PointCache type, having...

Nuff said.

For now, chose the 'ugly' way to fix it, that is, the one that changes
nothing to API and scripts using it: we define another 'PointCacheItem'
RNA type for items of our point cache collection, which has exact same
interface as PointCache except for the collection.

This is doomed to be rewritten at some point anyway, not worth spending
time trying to define a really correct data layout for now.
2018-03-18 15:37:23 +01:00
368c581df1 CMake: disable boost for lite builds 2018-03-18 05:10:02 +01:00
2a9f000806 Cleanup: kdopbvh, only set parent nodes once 2018-03-18 05:08:12 +01:00
a51fdd89fd Cleanup: use MEM_SAFE_FREE 2018-03-18 05:08:12 +01:00
2aa0bde3dc mathutils: replace interp w/ blend when standalone 2018-03-18 05:08:12 +01:00
07c90f3a73 build_environment: remove msvc compiler warning from boost.
Even the boost people have given up trying to keep up with the rapid release
of new msvc versions, and have removed the warn for now see: 5ad0730630 (diff-eac863c1d46c77471e54e8818aab7534)
2018-03-17 12:47:17 -06:00
7427e3e501 MSVC: ignore warning c4828 The file contains a character that is illegal.
The only place this warning is coming from is from comments in headers of 3rd party libs. we can safely repress this warning for now.
2018-03-17 12:45:27 -06:00
4a3d94c073 Eevee: Volumetrics: Fix crash when using smoke volumes. 2018-03-17 19:08:14 +01:00
1ed287058d DRW: Fix error in texture binding / unbinding. 2018-03-17 18:48:14 +01:00
c2f36c3558 GWN: Element Buffer: Refactor / Optimisation.
- Upload the data to the GPU directly when creating the element buffer in
   GWN_indexbuf_build_in_place().

 - Convert data in place when squeezing the indices and removing the need
   for another allocation.

 - GWN_indexbuf_build_in_place() can be used with already used element
   buffers and reupload their data without changing vbo id (keeping vaos
   up to date).
2018-03-17 18:23:04 +01:00
87d88581aa GWN: Vertex Buffer refactor.
We now alloc a vbo id on creation and let OpenGL manage its memory directly.
We use glMapBuffer to get this memory location.

This enables us to reuse and modify any vertex buffer directly without
destroying it with its associated Batches.

This commit does not really improve performance but will let us implement
more optimizations in the future.

We can also resize the buffer even if this can be slow if we need to keep
the existing data.

The addition of the usage hint makes dynamic buffers not a special case
anymore, simplifying things a bit.
2018-03-17 17:02:07 +01:00
dd44248219 DRW: Move cache time to GPUViewport for profiling
This enables us to average this timer over time like the others.
2018-03-17 17:02:07 +01:00
9ed7093aa6 Merge branch 'master' into blender2.8 2018-03-17 14:24:06 +01:00
64fbd50e4c Refactor: Collada: remove param, changed order of params in Function call
* In the Collada Module parameters are typically ordered
  in a similar way. I changed this to:

    extern std::string get_joint_id(Object *ob, Bone *bone);

* The Object parameter was not used in get_joint_sid().
  I changed this to:

	extern std::string get_joint_sid(Bone *bone);
2018-03-17 14:16:19 +01:00
dc08df659e Merge branch 'master' into blender2.8 2018-03-16 17:50:07 +01:00
e15591a1d7 Fix (unreported) a broken 'RNA diff collection' case.
When a name property is defined for collection's struct, but no name is
actually set, we want to also fallback to index case. We cannot handle
empty names to address items of a collection!
2018-03-16 17:49:54 +01:00
c722fd2184 Some more minor cleanups. 2018-03-16 17:49:54 +01:00
5389964eea Add an assert to BKE_icon_changed() that we are actually dealing with ID icon.
Otherwise, ID->obj is an opaque pointer, wrong usage here could lead to
a vast amount of bad things.
2018-03-16 17:17:19 +01:00
1a71d5ae85 Fix T54310: Assert when enable Brush custom icon.
We had a mix of two issues here actually:
* First, Brush are currently using their own sauce for custom previews,
this is not great, but moving them to use common ImagePreview system of
IDs is a low-priority TODO. For now, they should totally ignore their
own ImagePreview.
* Second, BKE_icon_changed() would systematically create a PreviewImage
for ID types supporting it, which does not really makes sense, this
function is merely here to 'tag' previews as outdated. Actual creation
of previews is deferred to later, when we actually need them.
2018-03-16 17:06:43 +01:00
67e2806dcb Cleanup: naming and const parameter. 2018-03-16 16:44:23 +01:00
36e7de9eb3 Merge branch 'master' into blender2.8 2018-03-16 12:26:37 +01:00
da4efaeb87 Depsgraph: Support colored addresses in debug prints
Enabled with --debug-depsgraph-pretty, only works with ANSI terminals.

Thanks Bastien for review!
2018-03-16 12:24:51 +01:00
295d8510af Add Truecolor ANSI console constants
They are used to start and end colored output in console.
Use with care, it is up to you to check that console actually
supports Truecolor ANSII.

In thew future we can extend this to other consoles and platforms.
2018-03-16 12:16:29 +01:00
f0596bf660 Hash: Add utility function to convert address to rgb values
Some magic hashing, will become handy to make debug messages
easier to follow.
2018-03-16 12:11:55 +01:00
5baf0de6e7 Merge branch 'master' into blender2.8 2018-03-16 11:24:41 +01:00
3baf31e73a Depsgraph: Move evaluation debug prints to depsgraph
This way we can easily control format and keep it consistent.

And also possibly do other trickery, like coloring addresses!
2018-03-16 11:14:38 +01:00
5de9c8f6f0 Cleanup: move mesh mirror functions to own file 2018-03-17 00:55:11 +11:00
ee0697e50b Cleanup: doxy sections for editmesh files. 2018-03-17 00:55:11 +11:00
7e954d974a GWN: Uncomment a (now) usefull assert 2018-03-16 08:50:31 +01:00
53f8c47c49 Eevee: Add warning comment about ubo/texture persistence.
More info on bindings persistence here :
8a692da7f81d8b0798f4aeebaa4a1123693fc279
2018-03-16 08:50:31 +01:00
2cfcffb057 Clay: Small cleanup.
Use persistent binds for the texture and UBOs.
Remove use of stencil.
2018-03-16 08:50:31 +01:00
93e26cb770 DRW: Fix/refactor UBO & Texture binding.
Previous approach was not clear enough and caused problems.
UBOs were taking slots and not release them after a shading group even
if this UBO was only for this Shading Group (notably the nodetree ubo,
since we now share the same GPUShader for identical trees).

So I choose to have a better defined approach:
- Standard texture and ubo calls are assured to be valid for the shgrp
they are called from.
- (new) Persistent texture and ubo calls are assured to be valid accross
shgrps unless the shader changes.

The standards calls are still valids for the next shgrp but are not assured
to be so if this new shgrp binds a new texture.

This enables some optimisations by not adding redundant texture and ubo
binds.
2018-03-16 08:50:31 +01:00
43d0943141 Merge branch 'master' into blender2.8 2018-03-17 01:43:19 +11:00
2816694b05 Code cleanup: fix various compiler warnings on clang/macOS. 2018-03-16 05:08:56 +01:00
3692a2bcb3 Merge branch 'master' into blender2.8 2018-03-16 04:35:37 +01:00
e5327afcb7 Fix T54326: Import Alembic stuck in edit mode
Switch to object mode before doing the import.
2018-03-16 04:06:34 +01:00
Cheryl Chen
07b07e53ea Fix T53971: single layer render showing the wrong render layer in image editor.
Original patch Cheryl Chen, extra fixes by Brecht.

Differential Revision: https://developer.blender.org/D3098
2018-03-16 00:58:10 +01:00
Guillaume Chereau
e56fd59f22 Code refactor: move OIIO image buffer writing outside session, into callback.
Original patch by Guillaume, modifications by Brecht.

Differential Revision: https://developer.blender.org/D3102
2018-03-15 23:05:16 +01:00
41149ca134 GHOST: Support Unity taskbar progress API
Unity itself is deprecated, but the API is also supported by KDE and the GNOME Dock extension,
which means that it will be useful for a wide variety of distributions.

To get a progress bar, the system must have a blender.desktop file and libunity installed.

The need for libunity is annoying, but the only alternative would be to integrate a DBus library...

Reviewers: campbellbarton, brecht

Differential Revision: https://developer.blender.org/D3106
2018-03-15 22:49:56 +01:00
995ccf8168 BLI_assert: extract from BLI_utildefines
BLI_utildefines is quite large, defining many unrelated things.
Add BLI_assert to include in inline headers, so math defines don't
pull in too much.
2018-03-16 06:03:29 +11:00
cca1e1b707 UV/Image Editor: Optimize UV Drawing
Use batchs to store the entire buffer of loops before drawing.
These batchs can be stored in the mesh draw cache later.
2018-03-15 13:36:16 -03:00
709ffd94ee Depsgraph: Fix missing shader updates with copy on write
Basically, don't do full in-place copy of node tree datablock if it's
already expanded. Current way how node tree is evaluated is fully
built around the idea that evaluation copies values from original
to copied datablocks.

Changing links is handled on another level.
2018-03-15 15:21:07 +01:00
1816d1f992 Mesh: Batch cache: Fix sculpt update issue.
Old solution was to create a new vbo and copy it to the location of
the old vbo hoping for the batches to update their vaos before drawing.

The issue is that the new VAO caching is not updating the VAOs at all
unless the shader interface changes.

So unless we expand gawain to support updating of vertex buffers (in a
better way than the current "dynamic" buffer) we need to delete every batch
linked to the vbo we want to recreate.

This solution might have performance implications.
2018-03-15 13:58:25 +01:00
a769cae241 GWN: Fix compilation error without VRAM_USAGE flag. 2018-03-15 13:58:25 +01:00
8d36629b4b Merge branch 'master' into blender2.8 2018-03-16 06:11:35 +11:00
d7a8a864ed Minor cleanup & commenting. 2018-03-15 09:44:16 +01:00
316ccc4a6e GHOST: Fix wrong usage of wglCreatePbufferARB.
Last argument must be a pointer to list of int terminated by a value of 0.
2018-03-15 01:51:46 +01:00
71139cedcb Missed last commit 2018-03-15 11:16:32 +11:00
e55c29b4ec BLI_math: don't use asserts in inline API
Requires BLI_utildefines.h to be included first,
(already noted in other inline code).

Possible alternative could be to move BLI_assert into own header.
2018-03-15 11:12:10 +11:00
6fa4001824 GWN: Batch: Perf: Comment out glBindVertexArray(0)
Even if they are for safety they are not free to use !

On my system (Mesa + AMD Vega GPU) calling:
glBindVertexArray(1);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
in a loop, shows the same overhead as a full vao switching (which is more
or less 10 times slower than just calling glDrawArrays)

Moreover, now that we use OpenGL 3.3 binding a VAO is REQUIRED to issue a
drawcall so it is garanted to be overwritten before the next drawcall.
Problem can only happen if someone draws directly with opengl commands.
2018-03-14 22:44:27 +01:00
75de653e4d GWN: Batch: Only revert to default Vao when needed.
Drawing ranges via glDrawArrays is already supported and should not need
a manual offset in the VAO like glDrawArraysInstanced or glDrawElements.
2018-03-14 22:44:27 +01:00
4ecc8b6786 GWN: Add primitive restart in element/index buffers.
This allows to draw multiple primitive of the type
GWN_PRIM_LINE_STRIP
GWN_PRIM_LINE_LOOP
GWN_PRIM_TRI_STRIP
GWN_PRIM_TRI_FAN
GWN_PRIM_LINE_STRIP_ADJ
with only one drawcall. This should speed up some areas that are really
sensitive to drawcall counts : UV drawing, Hair drawing...
2018-03-14 22:44:27 +01:00
2c80a4d4aa Fix T54322: partial redraw not working after recent refactor. 2018-03-14 20:39:10 +01:00
9009622b54 Merge branch 'master' into blender2.8 2018-03-14 18:10:31 +01:00
b0823962e9 Style cleanup. 2018-03-14 18:05:09 +01:00
d34b1b35bf Fix (unreported) broken IDarray case in IDP_EqualsProperties_ex.
For IDProps IDarray, IDP_EqualsProperties was called for each item,
instead of IDP_EqualsProperties_ex, discarding value of `is_strict`
option.

Probably not an issue with current code, though.
2018-03-14 17:53:29 +01:00
d0055155e8 Fix T54319: Crash after double-clicking baked F-curve 2018-03-14 16:02:46 +01:00
342593f124 Cleanup: rename BLI_array_count -> len
Match naming convention used everywhere else.
Count should only be used when this isn't directly accessible.
2018-03-15 01:53:20 +11:00
9521b67ac0 Depsgraph: Fix missing updates with drivers
The issue was only visible with copy-on-write enabled, and related to the
fact, that dependency graph builder binds original FCurves.

For now use smallest patch possible to make things to work and to make
draguu happy.

Need to think of a smarter way to deal with drivers, bones and view layers.
2018-03-14 15:21:31 +01:00
5c30121b8c Clay: Add FXAA.
I tried to use real multisampling but the main problem is the outline detection that needs to have matching depth samples.

So adding FXAA instead. Always on for now, may add a parameter for it later.

One thing to note is that we need to copy the final output once again to the main color buffer because we cannot swap the dtxl textures (they can be referenced elsewhere like GPUOffscreen).

We could improve upon this and add TAA on top if viewport is still.
2018-03-14 14:55:36 +01:00
3530ee2949 GPUViewport: Fix offscreen multisample syncing. 2018-03-14 12:55:19 +01:00
b4209b138f Clay: Refactor: Port clay to a deferred pipeline.
This means that rendering clay with AO only needs 1 geometry pass.
Thus greatly improving performance of poly heavy scene.

This also fix a self shadow issue in the AO, making low sample count
way better.

We also do not need to blit the depth anymore since we
are doing a fullscreen shading pass.

The constant cost of running the a deferred shading pass is negligeable.
This include quite a bit of code cleanup inside clay_engine.c.

The deferred pipeline is only enabled if at least one material needs it.
Multisampling is not supported yet.

Small hacks when doing deferred:
- We invert the normal before encoding it for precision.
- We put the facing direction into the sign of the mat_id.
- We dither the normal to fight the low bitdepth artifacts of the normal
  buffer (which is 8bits per channel to reduce bandwidth usage).
2018-03-14 12:41:00 +01:00
e22bc559b0 DRW: Add DRW_viewport_invert_size_get for more ease of use. 2018-03-14 12:41:00 +01:00
f7f3b08977 GPUTexture: Unlock GL_R16I format. 2018-03-14 12:41:00 +01:00
Dalai Felinto
e7c3c46e89 Fix make single user crash
How to reproduce the crash:
* Factory startup
* 'u'key (make single user)

It comes with a simple unittest to reproduce the original issue.
2018-03-14 08:13:27 -03:00
59aa8d22ef Cleanup: use flags instead of collection of bools to get RNA override status. 2018-03-14 11:47:35 +01:00
c22c2ff060 Updated bpy.props getter/setter example
- The common name in computer science are 'getters' and 'setters', so by
  adding these names to the documentation (while 'get' and 'set are still
  also mentioned) we improve findability. Having 'Getters/Setters' as a
  title also makes it clearer that this example is not just about
  getting or setting the property value.
- Added a little prefix to each printed value, so that print statement,
  expected output, and real output can be matched easier.
2018-03-14 11:42:36 +01:00
b76471c1f9 Fix T54286: bpy.props operator example misses property access
The old example had two downsides:

- It promoted a blocking UI design, where the user is shown a popup
  before actually executing the operator.
- It didn't show how to actually use the property values.

The new code avoids these mistakes. The properties are also shown in the
redo panel in the 3D view.

Note that I also changed the bl_idname, as this is an example about
properties, not about dialogue boxes, and changed the class name to use
the standard operator naming convention.

I also extended the example to include a panel that sets multiple
properties of the operator, since I see questions about this relatively
frequently.
2018-03-14 11:31:14 +01:00
4aab63d23e Move layer utility functions into own file 2018-03-14 18:35:31 +11:00
37573632f0 Merge branch '28' into temp-object-multi-mode 2018-03-14 18:18:40 +11:00
d430d12123 Merge branch 'master' into blender2.8 2018-03-14 18:08:37 +11:00
8803c5ca5d Cleanup: use sections for editmesh tools/select 2018-03-14 17:54:45 +11:00
0ae714f082 Merge branch '28' into temp-object-multi-mode 2018-03-14 14:00:01 +11:00
7314904a77 Eevee: Fix sequencer rendering.
Sequencer rendering can use multisample render targets. Be sure to sync
thoses after rendering.

Also disable the sample loop when not needed.

Do note that currently the color correction is broken with the sequencer.
2018-03-14 03:29:10 +01:00
f5d529b8e2 GPUViewport: Fix offscreen multisample rendering.
Multisample rendering needs to have both a multisample and a regular color/depth target for engines that does not support MSAA.
2018-03-14 03:29:10 +01:00
bba3b43112 GPUTexture: Save sample count inside texture struct.
This adds a quick way to know if a texture is a multisample texture and its sample count.
2018-03-14 03:29:10 +01:00
c1694540c3 API generating script: give better version for releases builds.
Was giving '2.62.1 <sha1>' even for releases, now rather giving nicer
'2.62a <sha1>' in that case.
2018-03-13 19:49:39 +01:00
5855d4051f Filtering suppoert w/ BKE_view_layer_array_from_*
Fixes mixing non active objects w/o UVs, when using UV tools/selection.
2018-03-14 03:08:55 +11:00
e9173a0389 Merge branch 'blender2.8' into temp-object-multi-mode 2018-03-14 02:24:14 +11:00
585208e0e9 Merge branch 'master' into blender2.8 2018-03-14 02:15:37 +11:00
be25a0faa7 Cleanup: pass selectmode directly
Pass instead of editmesh or toolsettings.
Needed for multi edit-mode
2018-03-14 02:08:29 +11:00
bf8f5f5142 Cleanup: doxygen comments 2018-03-14 02:08:07 +11:00
f9cdf4e20d Multi-edit-support for Select Linked Mesh 2018-03-14 00:09:46 +11:00
c99c45a1e3 Fix (unreported) crash when changing active shapekey in Edit mode.
Looks like someone changed the signature of some RNA update callback,
and for some reason that 'change skey' update function was not updated
(or later got merged from master)...

We'll need RNA to check for its func signatures, some day...
2018-03-13 14:08:17 +01:00
1f94830d6e Move to using arrays of objects/bases
This avoids stepping over the same obdata multiple times for linked
duplicates.

Also support select-linked for UV editmode.
2018-03-13 23:53:38 +11:00
81c199af83 Fix T54302 - Wrong added scene when adding a scene strip to the Sequencer
When adding scene strips to the sequencer, the wrong scenes were
getting getting added if some were skipped. For example:
Given 4 scenes (A, B, C, D) if you're trying to add the last 3 scenes
(B, C, D) as strips to the first scene (A), it would ended up adding
"A, B, C" instead of "B, C, D" as expected.

Fix provided by Andrew (signal9).
2018-03-13 23:05:57 +13:00
e0bb5109b3 Use Action datablock's own icon (instead of Animation Data's one) for File Browser's lib icons 2018-03-13 23:05:57 +13:00
e7b4e4a94a Add array utilities for getting objects in mode 2018-03-13 20:23:22 +11:00
b91185d6af Correct assert adding new object 2018-03-13 20:22:36 +11:00
e426838798 Fix assert entering edit mode w/ multiple objects 2018-03-13 20:16:15 +11:00
ad58a423ea Merge branch '28' into temp-object-multi-mode 2018-03-13 18:50:42 +11:00
028580fd1e Merge branch 'master' into blender2.8 2018-03-13 18:39:51 +11:00
3106f18176 Cleanup: long lines, use doxy sections 2018-03-13 18:07:10 +11:00
b45a464794 Fix index offset (uv unwrap works now) 2018-03-13 14:42:22 +11:00
ce08d0681b Eevee: Render: Add Info messages. 2018-03-13 04:25:50 +01:00
266cdf955e Eevee: Render: Allow cancel during probe update. 2018-03-13 03:58:27 +01:00
0f1d7a5796 Eevee: Render: Fix softlock if rendering before lazy shader compil ends.
Calling the rendering operator seems to kill any other WM_job running, leaving
uncompiled materials into a GPU_MAT_QUEUED state. This then made the probe update
looping indefinitely (all_materials_updated remaining to false).

To fix this, we resume compilation for materials that are in this state.
Cancelling Render before all material compilation could make certain material
remain uncompiled. Fortunately, this is not allowed as of now.
2018-03-13 03:58:00 +01:00
0acccda4a4 GPUMaterial: Fix non finished material status if shader has no output.
This wasn't producing any issue for now but it's better to make things clean.
2018-03-13 03:49:04 +01:00
c73d408ed8 Merge branch '28' into temp-object-multi-mode 2018-03-13 13:23:21 +11:00
8b399d3148 Eevee: Fix temporal sampling not resetting.
World Probe update was not resetting the TAA.

This also reset the volume sampling in cases that needs it (world/grid probe diffuse coefs update).
2018-03-13 01:35:16 +01:00
a3f4de64e5 Eevee: Fix bad Outlines after probe updates.
This was because the default matrices were not setup back after resetting the current TAA sample.
2018-03-13 01:24:51 +01:00
17793a66c6 Fix T54299: crash rendering objects with motion blur disabled, after recent changes. 2018-03-12 17:37:29 +01:00
733b9e4f99 Merge branch 'master' into blender2.8 2018-03-12 17:31:46 +01:00
44aa86b0a5 Cycles: reorganize tests in more evenly distributed groups. 2018-03-12 17:29:44 +01:00
e07dd9fd59 Cycles: add constant folding to displacement nodes. 2018-03-12 17:29:44 +01:00
629d44e049 Fix type in comment 2018-03-12 17:03:54 +01:00
a752bc148e Depsgraph: Make timing profile a command line option
This way we can add even more statistics, even one which will be print
to the console.

Would be nice if we also have verbosity level control.
2018-03-12 17:01:02 +01:00
Dalai Felinto
cb3fb8b259 Fix blenderplayer (tm) 2018-03-12 09:15:43 -03:00
815852e950 Fix T54296: Cycles viewport render stuck on constant re-render
Need Clear ID recalc flag on load. Otherwise it's possible to have
some IDs considered always updated by Cycles, when they were saved
in a tagged-for-update state.

Thanks Bastien for feedback and review!
2018-03-12 10:58:12 +01:00
b31a3ffc25 BMesh: fix bug where indices weren't set /w offset 2018-03-12 20:07:29 +11:00
8f4579affd Merge branch 'master' into 28 2018-03-12 16:38:41 +11:00
da62507bc8 Cleanup: remove misleading array size 2018-03-12 16:37:26 +11:00
d75456196f Cleanup: typo 2018-03-12 16:35:31 +11:00
fc2974b06d Merge branch '28' into temp-object-multi-mode 2018-03-12 15:03:24 +11:00
ba01cdc770 Merge branch 'master' into blender2.8 2018-03-12 15:01:22 +11:00
25502a9bdc Cleanup: sync EDBM_uv_* functions w/ 2.8
They're nearly the same, so keep names matching to avoid conflicts.
2018-03-12 14:51:45 +11:00
04e76696f9 Merge branch 'blender2.8' into temp-object-multi-mode 2018-03-12 14:38:10 +11:00
1d0077649d Merge branch 'master' into blender2.8 2018-03-12 14:25:20 +11:00
1966924467 UV: internal changes to picking
Nothing user visible, only things needed for multi-object support,
making picking functions more flexible too.

- Support passing in an initialized hit-struct,
  so it's possible to do multiple nearest calls on the same hit data.
- Replace manhattan distance w/ squared distance
  so they can be compared.
- Return success to detect changes to a hit-data
  which might already be initialized (also more readable).
2018-03-12 13:57:38 +11:00
acfc5f7820 Multi-Edit UV select
- (de)select all
- select linked
- mouse picking (vert/face/island)
  (refactor selecting nearest UV so it can be used with many meshes)
2018-03-12 13:11:53 +11:00
3a6f26c087 Merge branch 'blender2.8' of git.blender.org:blender into blender2.8 2018-03-11 23:47:08 +01:00
ddae05cdca Merge remote-tracking branch 'origin' into blender2.8 2018-03-11 23:45:53 +01:00
7fed3ad32b GPUImage: Add back garbage collection for the new viewport pipeline. 2018-03-11 23:44:10 +01:00
765d7242d5 GPUMaterial: Add Material shader cache.
This is mostly to avoid re-compilation when using undo/redo operators.
This also has the benefit to reuse the same GPUShader for multiple materials using the same nodetree configuration.

The cache stores GPUPasses that already contains the shader code and a hash to test for matches.
We use refcounts to know when a GPUPass is not used anymore.

I had to move the GPUInput list from GPUPass to GPUMaterial because it's containing references to the material nodetree and cannot be reused.

A garbage collection is hardcoded to run every 60 seconds to free every unused GPUPass.
2018-03-11 23:44:10 +01:00
7194259fb1 Eevee: SSS: Fix compilation error. 2018-03-11 23:44:10 +01:00
2c9c22df26 fix Collada: wrong usage of pointer and hidden redeclaration
* Suspicious usage of pointer:

  short *type = 0; // this creates a null pointer

When this is later used for anything then blender would crash.
After following the code and check what happens i strongly believe
the author wanted to use a short and not a pointer to a short here.

* local variable where reused later in same function
While this did no harm, i still felt it was better to use a different
name here to make things more separated:

- moved variable declaraiotns into loop (for int a=0; ...)
- renamed uv_images to uv_image_set
- renamed index variable from i to j in inner loop that
  reused same index name from outer loop
2018-03-11 20:59:50 +01:00
49a7cd1ba4 Cleanup Collada: Removed duplicate variable setting 2018-03-11 20:59:50 +01:00
7952ece01b Cleanup: avoid redeclaration of iterator in same function
The iterator was redeclared 3 times. I fixed this to avoid future issues.
I commit separately because so the changes are less cluttered all over
the place.
2018-03-11 20:59:49 +01:00
a2cc85b264 Cleanup Collada: Avoid unintentional reuse of previous defined variable
The variable child was redeclared multiple times in the same function.
While this has not created any issues i still changed this to avoid
confusion and keep the usage of the variables more local.
2018-03-11 20:59:49 +01:00
ca11ef7fd3 Fix Collada: Avoid unnecessary and even wrong check on unavailable data
The function validateConstraints() potentially causes a null pointer
exception. I changed this so that the function returns a failure as soon
as the validation fails. This avoids falling into the null pointer trap.
2018-03-11 20:59:49 +01:00
2de0daa179 Cleanup Collada: Make sure index variables are not reused
The variables i and j have been declared before in the same function.
I changed the names to mi and mj to keep things clear.
2018-03-11 20:59:49 +01:00
86b1887ded Cleanup Collada: make sure float array is initialised
This is just to silence a compiler warning and keeping
the code clean. The actual code never uses uninitialised
array elements.
2018-03-11 20:59:49 +01:00
01c27faed0 Refactor Collada: combined 2 almost identical functions into one
The 2 methods add_bezt() and create_bezt() do almost the same.
I combined them both into add_bezt() and added the optional parameter
eBezTriple_Interpolation ipo
2018-03-11 20:59:48 +01:00
3eaa408cb3 Fix T54274, and rename option --window-borderless to --window-fullscreen 2018-03-11 12:26:43 +02:00
d897d52659 Muli-Edit: UV select(all) / circle / border / lasso 2018-03-11 17:38:24 +11:00
8651ddeb0e Lasso Select support for multi-object edit 2018-03-11 17:03:35 +11:00
d25fea66e2 Quiet warning 2018-03-11 16:15:04 +11:00
d67d85771f Merge branch '28' into temp-object-multi-mode 2018-03-11 16:12:41 +11:00
7ecc7c46af Merge branch 'master' into blender2.8 2018-03-11 16:11:56 +11:00
63483fe417 Cleanup: long lines 2018-03-11 15:50:25 +11:00
7ba6684f3e Merge branch '28' into temp-object-multi-mode 2018-03-11 12:14:32 +11:00
93e0e716f3 Merge branch 'master' into blender2.8 2018-03-10 19:06:28 +01:00
23ccf5767f Cycles: add roughness baking support, using squared roughness convention. 2018-03-10 18:37:33 +01:00
7613ffc944 Cycles: switch to squared roughness convention for all nodes.
This was already done for the Principled BSDF to be compatible with typical
baked roughness maps in PBR workflows.
2018-03-10 18:05:01 +01:00
d27158aae9 Merge branch 'master' into blender2.8 2018-03-10 06:55:39 +01:00
8a76f8dac3 Code cleanup: fix compiler warning. 2018-03-10 06:51:52 +01:00
1f5c5fa189 Fix T54279: viewport update bug with volume meshes.
Meshes without vertex normals were not handled correctly.
2018-03-10 06:27:19 +01:00
3f2b88d195 Code refactor: reduce number of loops over meshes. 2018-03-10 06:27:19 +01:00
07d0a87b5c Fix T54278: volume artifacts with small density and color after recent changes. 2018-03-10 06:27:19 +01:00
50dde3d01a Fix T54269: saved EXR file files unreadable some editors in Blender.
Don't write the multichannel metadata when there is only a single layer,
and don't unnecessarily consider single layer images with Blender metadata
as multi layer.
2018-03-10 06:27:19 +01:00
d526b35ce2 Code cleanup: use spaces for aligned indentation. 2018-03-10 06:27:19 +01:00
db333d9ea4 Cycles: support arbitrary number of motion blur steps for objects. 2018-03-10 06:27:19 +01:00
78c2063685 Cycles: support arbitrary number of motion blur steps for cameras. 2018-03-10 06:27:19 +01:00
267d892326 Code refactor: motion blur cleanups, preparing for next commit. 2018-03-10 04:54:05 +01:00
6c4ddfc5d9 Code refactor: don't expose UpdateObjectTransformState in header. 2018-03-10 04:54:05 +01:00
b66efbecf4 Code refactor: make Transform always affine, dropping last row.
This save a little memory and copying in the kernel by storing only a 4x3
matrix instead of a 4x4 matrix. We already did this in a few places, and
those don't need to be special exceptions anymore now.
2018-03-10 04:54:05 +01:00
623141f339 Code refactor: add DecomposedTransform.
This is in preparation of making Transform affine only, and also gives us
a little extra type safety so we don't accidentally treat it as a regular
4x4 matrix.
2018-03-10 04:54:05 +01:00
516e82a900 Code refactor: add ProjectionTransform separate from regular Transform.
This is in preparation of making Transform affine only.
2018-03-10 04:54:04 +01:00
cd15d87bfc Code refactor: avoid motion transform copy, remove unused curved code.
The purpose of the previous code refactoring is to make the code more readable,
but combined with this change benchmarks also render about 2-3% faster with an
NVIDIA Titan Xp.
2018-03-10 04:54:04 +01:00
Stefan Werner
f3010e98c3 Code refactor: use KernelShader and KernelParticle instead of float arrays.
Original patch by Stefan with modifications by Brecht.
2018-03-10 04:54:04 +01:00
Stefan Werner
fa9175ff02 Code refactor: use KernelLight instead of float4 arrays.
Original patch by Stefan with modifications by Brecht.
2018-03-10 04:54:04 +01:00
Stefan Werner
f66ff4ee86 Code refactor: use KernelOject struct instead of float4 array.
Original patch by Stefan with modifications by Brecht.
2018-03-10 04:54:04 +01:00
f3161bd2ab Eevee: Planar Reflections: Fix corrupted results in downsampling step.
It only seems to happen in some drivers/gpu, the vertices gets culled if 4th component is 0.0. So lesson learned: always use 1.0 if constant.
2018-03-10 02:18:25 +01:00
92c2e2f386 Eevee: Planar Reflection: Add refraction support for reflected objects. 2018-03-10 02:18:25 +01:00
4f55ee5a3c Eevee: Add new clipping UBO.
This fixes problems with the planar reflections.
2018-03-10 02:18:25 +01:00
82957cfec8 Eevee: Make use of the new view matrix UBO. 2018-03-10 02:18:25 +01:00
41abbc271c DRW: Change UBOs binding logic.
Use the same logic than textures. Also reset bindings only on shader changes.
2018-03-10 02:18:25 +01:00
dfd8a52cd2 DRW: Change clip planes API.
The draw manager now just set the number of active clip planes. It's now up to the engine to specify the plane equations as uniform/ubo/constant.
2018-03-10 02:18:25 +01:00
1b8ba6b8b9 DRW: Add assert for uniform that needs valid data. 2018-03-10 02:18:25 +01:00
8444aaaa69 DRW: Put all view-only dependant uniform in a UBO.
This leads to less lookups to the GWNShaderInterface and less uniform upload.

We still keep a legacy path so that Builtin uniforms can still work. We might restrict this path to Builtin shader only in the future.
2018-03-10 02:18:25 +01:00
4540bd226d Eevee: Probes: Fix last planar reflections remaining after deletion. 2018-03-10 02:18:25 +01:00
13b99b7bbb Eevee: Probes: Add culling for planar probes.
Planar probes that have no influence on pixels in the view are culled.

This greatly improve performance when theses probes are offscreen.
2018-03-10 02:18:25 +01:00
7c31edb385 DRW: Culling: Expose & Add culling functions to engines.
This way engines can do preemptive culling by themselves.
2018-03-10 02:18:25 +01:00
4402633e33 BoundBox: Fix wrong max in BKE_boundbox_alloc_unit. 2018-03-10 02:18:25 +01:00
c962f7ef77 Eevee: Render: Add cancel support
You can now cancel your renders that are too long. This will still output the current status of the render. For example if you cancel at 50% rendering progress, you will have a render result with only half the render samples.
2018-03-10 02:18:25 +01:00
f043365c38 DRW: Culling: Fix precision error.
This was triggering the BLI_assert(fac >= 0.0f);.

Clamp fac to ensure correct value for release builds.
2018-03-10 02:18:25 +01:00
9cd09fee6a Eevee: Planar: Add transparent objects.
The ordering is left broken for the viewport as this can be quite heavy.
Only do it if doing a render.
2018-03-10 02:18:25 +01:00
e697c1da42 Eevee: Planar Probe: Add supersampling jitter.
This also fix a bug with the probe debug display when there was more than 2 probes. ped->probe_id was equal to 0 for all planar probes until the next frame. Resulting in all planar data debug to show probe 0.
2018-03-10 02:18:25 +01:00
Julian Eisel
41b38c5f75 Don't add "Report a Bug" button for official tracker to non-official add-ons
If no custom URL was set, add-ons would get a "Report a Bug" button opening
the default developer.blender.org bug tracker. Now we only add this default
button if the add-on is bundled and not installed by the user.
2018-03-09 21:22:24 +01:00
14e7ba0c8a Fix Pose Lib: pose is applied when selected bones don't overlap with pose
Premise: When pose bones are selected, applying a pose library should
only affect the selected bones.

This commit fixes a bug where the pose was also applied when there was
no overlap between the selected bones and the bones in the pose. For
example, applying a pose which contains only keyframes for the left
hand, while only right-hand bones are selected, would apply the pose
to the left hand anyway.

The code is now also slightly more efficient; the removed 'selcount'
counter was only used as a binary (i.e. zero or non-zero). It's now
stored as a bitflag instead.
2018-03-09 19:03:29 +01:00
cb49e77eb1 Initial proof of concept multi-mode
Entering edit-mode uses all selected mesh objects.

- drawing.
- select (picking, circle, border).
- select mode vert/edge/face switching.
- handful of tools: subdivide, delete, select(all)
- uv project & unwrap.
- transform (uv's and vertices)
  (crazy-space and islands aren't currently working).

Almost nothing else works, this is a proof of concept.

Note, missing indentation in some added loops to reduce diff noise and merge conflicts.
2018-03-09 23:38:21 +11:00
c3d7be150b Cleanup: iterator macros
This line was missing in previous commit
2018-03-09 11:00:54 +01:00
d3e14c2e2f Manipulator: disable UV widget, following prefs 2018-03-09 20:44:41 +11:00
40e62f271c FFmpeg: Add regression tests
Currently only covering handful of files from reports about wrong fps detected.

It will need D3083 applied first to get tests passed, also tests themselves
are to be committed to svn.

But there are some python code which needs to be reviewed, like blendfile
passed to run_blender().

Reviewers: sybren, mont29

Reviewed By: sybren, mont29

Subscribers: mont29

Differential Revision: https://developer.blender.org/D3096
2018-03-09 10:33:20 +01:00
370a2d6917 Fix T53857: Incorrect framerate for videos imported from OBS
This is an issue with which value to trust: fps vs. tbr. They both cam be
somewhat broken. Currently the idea is:

- If file was saved with FFmpeg AND we are decoding with FFmpeg we trust tbr.
- If we are decoding with Libav we use fps (there does not seem to be tbr in
  Libav, unless i'm missing something).
- All other cases we use fps.

Seems to work all good for files from T53857, T54148 and T51153. Ideally we
would need to collect some amount of regression files to make further tweaks
more scientific.

Reviewers: mont29

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D3083
2018-03-09 10:32:17 +01:00
f47a41a3d9 Cleanup: iterator macros
- put render iterator in own scope
  (would shadow it's own variable if used multiple times).
- enforce semicolon at end of iterator macros.
- no need to typedef one-off macro structs.
2018-03-09 11:52:11 +11:00
9342f55d12 Merge branch 'master' into blender2.8 2018-03-08 17:54:52 +11:00
222a941a2b Merge branch 'master' into blender2.8 2018-03-08 17:47:02 +11:00
ecab7bef69 Cleanup: Rename view3d context set function
Use common prefix so adding related functions share the prefix.
2018-03-08 17:30:24 +11:00
28f86bf117 Cleanup: use edit/active objects from view context
Needed to implement multiple edit-objects.
2018-03-08 17:27:36 +11:00
cb8311fecf Cleanup: set the view-context once 2018-03-08 17:27:36 +11:00
5331581ea4 Cleanup: Use BKE_ prefix for all public functions exposed by the NLA module 2018-03-08 17:15:34 +13:00
7e2100e499 T54233: NLA "Push Down" discards Blend Mode, Extrapolation, and Influence
Each AnimData block has a set of Blend/Extrapolation/Influence settings
that can be used to control how the active action is blended with the
NLA stack. However, these settings were not getting copied over to the
newly created strips (as the push-down code existed long before these
settings were added).

This commit solves this in several ways:
* Active Action Blend/Extrapolation/Influence settings now get copied
  to the new strips when adding them to the NLA stack via Push Down.

  Note: This doesn't happen when there are no existing NLA tracks,
        as these settings don't get used in that case.

* Strip Influence will be copied across when inf < 1.0 (i.e. when a
  non-default value is used), to maintain the effect. To make this work,
  the influence value will get added as a keyframe to the strip's
  "Influence" Control FCurve.

  - See code comments for an alternative approach and why that was not chosen
  - Strip Time still doesn't get keyframes added automatically yet.

* To ensure the "extrapolation mode" settings don't get always overwritten,
  I've put in place a compromise: the extrapolation will only get changed
  if the chosen setting will cause problmes (i.e. hold forward & back -> hold forward
  if there are other tracks before it already).

Not safe for backporting to 2.79[x] stable releases.
2018-03-08 17:15:33 +13:00
fb70f9bf99 Fix crash if NLA strip with "Use Animated Influence" setting is enabled without the Influence Strip F-Curve existing 2018-03-08 17:15:33 +13:00
a5d63624de Cleanup: Fix invalid name prefix 2018-03-08 17:15:32 +13:00
872df463f6 Eevee: Render: Add progress. 2018-03-08 00:09:04 +01:00
70fa15d1b8 Eevee: Save and reset matrixstate for probe rendering. 2018-03-08 00:09:04 +01:00
45ec962f68 DRW: Fix culling with inverted view (planar reflections)
Just invert the frustum planes in this case.
2018-03-08 00:09:04 +01:00
8d8f7e52c1 Make sure that the WM_opengl_context_create is always called on the main thread
Avoid the error 170 ("The requested resource is in use").
2018-03-07 20:05:51 -03:00
fef1b01553 Fix wglShareLists being called with rendering contexts in use
`wglShareLists` was failing with error code 170 ("The requested resource is in use").
2018-03-07 19:40:08 -03:00
596f33f801 Fix T54206: bevel and inset operations repeat did not remember offset.
Now repeating the operator will use the previously chosen offset, either with
the modal operator or typed in. The modal operator will still start at zero.
2018-03-07 22:53:22 +01:00
Julian Eisel
8851460174 Proper fix for User Preferences window crash
Reverts rBb9ae517794765d6a1660 and fixes the issue properly. Old fix could cause
NULL to be passed to functions that expect all arguments to be non-NULL.
2018-03-07 21:18:16 +01:00
Julian Eisel
c00b42b710 Fix Blenderplayer not compiling 2018-03-07 20:41:49 +01:00
d59627d361 Merge branch 'master' into blender2.8 2018-03-08 02:03:36 +11:00
118fb9f1f7 EditMesh: pass object data to notifiers
Both were being passed in different parts of the code,
use object data for consistency.
2018-03-08 01:49:30 +11:00
f02af0407f Cleanup: use _BEGIN suffix for group iterators 2018-03-07 20:46:27 +11:00
b9ae517794 Add missing NULL check
Caused loading user-prefs to crash.
2018-03-07 16:40:02 +11:00
49baf15a35 Merge branch 'master' into blender2.8 2018-03-07 14:31:53 +11:00
737a5efff4 Cleanup: edit-mode undo API
Move function descriptions into the struct,
minor improvements to variable naming,
use convention of 'g_' prefix for static vars.
2018-03-07 14:00:02 +11:00
4f23e13001 DRW: Fix memory leak.
This prevents the creation of a new job if no job is running.
2018-03-07 01:40:40 +01:00
cfba75a21a Eevee: Fix volume rendering glitches.
The bug was due to the Halton function returning uninitialized value for 0 iteration.
2018-03-07 01:40:40 +01:00
aa07660201 Eevee: Fix garbage on the first frames when enabling volumetrics.
Was cause by newly added shader deferred compilation.
2018-03-07 01:40:40 +01:00
267e816b9a Draw Manager: Simplify the algorithm that extract the BoundingSphere of a Frustum
The idea is to separate the most common case from symmetrical frustum. And to make a simple but efficient calculation.

The new radius is usually 98% the size of the radius size of the asymmetric solution.

Thanks to @fclem for reviewing the patch on IRC
2018-03-06 19:27:43 -03:00
faf70e1e64 Eevee: Fix crash with volumetrics + default mat + alpha blend 2018-03-06 16:52:06 +01:00
d5ecadd643 Eevee: Fix Cascaded shadowmap setup.
It was getting the wrong matrice because of the point light override.
2018-03-06 16:45:23 +01:00
6b5b61eb8c DRW: Fix DRW_viewport_matrix_override_set_all function. 2018-03-06 16:45:23 +01:00
4e7d9b7a98 Eevee: Fix probes not working after a world update. 2018-03-06 16:45:23 +01:00
f8b63b564d Eevee: Update to support shader deferred compilation.
World probe is tagged to refresh when it it's shader is updated.
Probes are recomputed only after all meshes shaders have been compiled.
2018-03-06 16:45:23 +01:00
2faa809ea6 GPU: Fix typo. 2018-03-06 16:45:23 +01:00
b55077a506 DRW: Fix broken grid in ortho view. 2018-03-06 16:45:23 +01:00
aa02c099f9 Eevee: fix wrong sizeof.
Like really? wtf dude? *self face slapping*
2018-03-06 16:45:23 +01:00
94fadd00d8 DRW: Shader Deferred compilation: Use a wmJob for threading.
Also get rid of the static var and initialization.
This enables the user to see the progress on the info header.
Closing blender or reading a file also kill the job which is good.

Unfortunatly, this job cannot be interrupt by users directly. We could make it interruptible but we need a way to resume the compilation.
2018-03-06 16:45:22 +01:00
3a209c2857 DRW: Deferred compilation initial implementation. 2018-03-06 16:44:04 +01:00
f14cbc0d07 Material: Free gpumaterials before the notree.
This is because gpumaterials can contain references to the tree when doing lazy compilation.
2018-03-06 16:44:04 +01:00
162ef15da6 Eevee: Fix bad framebuffer when changing probe resolution. 2018-03-06 16:44:04 +01:00
b7414d357a Screen: Fix screen layout preview render. 2018-03-06 16:44:04 +01:00
a6e6d7e022 Eevee: More use of DRW_viewport_matrix_override_set_all 2018-03-06 16:44:04 +01:00
2af6520007 DRW: Fix occlusion culling. 2018-03-06 16:30:27 +01:00
76122bc8f0 Cycles: Fix crash when building with no shading systems 2018-03-06 13:04:28 +01:00
ec904ed327 Cycles: Cleanup, indentation 2018-03-06 13:04:28 +01:00
8d572e8764 Cleanup: unused var 2018-03-06 22:42:32 +11:00
85b68aaf7f Merge branch 'master' into blender2.8 2018-03-06 20:04:02 +11:00
a5a0dcec90 Merge branch 'master' into blender2.8 2018-03-06 19:13:41 +11:00
4d86a432da Utility to enter sculpt mode 2018-03-06 19:11:19 +11:00
dd611dd0b8 Eevee: Optimize shadows drawing
In the gpus like `AMD Radeon HD 7570M` and `Intel(R) HD Graphics 4000` this solution improves performance a hundreds or even thousands of times depending on the resolution.

Reviewed By: @brecht and @fclem

Differential Revision: https://developer.blender.org/D3095
2018-03-05 22:03:14 -03:00
b5b5260464 Fix T54234, add BLENDER_VERSION_CHAR to .plist 2018-03-06 02:36:29 +02:00
d9d3ed16a8 Fix T53206: Array modifier doesn't merge vgroups
Vertex group remapping utility function,
now shared between object join and array modifier cap-ends.

Weights which don't exist are removed.

D3092 by @Foaly
2018-03-06 09:57:41 +11:00
84a154ac68 Merge branch 'master' into blender2.8 2018-03-05 16:14:46 +01:00
df267bd4c4 Sequencer: Expose read-only FPS property for movie-type strips
Main purpose is to make it possible to cover FPS detection with regression test.
But it might also be handy for some other scripters.

Thanks Campbell for review!
2018-03-05 15:01:23 +01:00
ae9beb1cea UI: rename panel 'Workspace Add-ons'
Show/Hide is limited to menus
2018-03-06 00:59:44 +11:00
caa0b0fadf Fix T54204: Wrong selection on Clean Tracks (Motion Tracking)
A mistake in a fix for T53612.

Regression in 2.79a, candidate for 2.79b :S
2018-03-05 12:00:25 +01:00
63d8ccf9ff Fix T54225: Blur node stopped working when Map Range was fed with image
The issue was happening with fast Gaussian blur, and caused by NaN value pixels
in the input buffer.

Now made it so Map Range output does not produce NaN, by returning arbitrary
value of 0. Still better than NaN!
2018-03-05 11:44:42 +01:00
9593a62746 Cleanup: left wrong comment in 2018-03-05 17:03:18 +11:00
f3018322c0 Fix T53478, T53430: Sequencer cut edge case fails
Previous fix for T53430 caused T54200.

The edge case for soft & hard cuts weren't working,
where the strip used start/end-still & the frame was placed exactly on
the start/end of of the sequence content.

T54200 fixed the end-still case but broke hard-cuts for all other cases.

This fixes the case for soft/hard cuts with/without start/end-still.
2018-03-05 16:58:01 +11:00
327985e887 Revert "Fix T53430: Cut at the strip end fails w/ endstill"
This reverts commit 855799ecc1.

Caused T54200
2018-03-05 16:58:01 +11:00
807663742b Error passing context arg to marker menu
own mistake in 6981861fcf
2018-03-05 14:10:43 +11:00
3607b4eb52 Fix LLVM/OSL library detection on macOS to prefer own OSL libraries. 2018-03-04 07:40:21 +01:00
74f3fb746a Fix Clang compiler detection on macOS.
"AppleClang" was not properly detected here. Now make the compiler ID
test a bit less compact but consistent with other code.
2018-03-04 07:39:04 +01:00
2adece9fbb Merge branch 'master' into blender2.8 2018-03-03 14:58:14 +01:00
dab20bd41f Fix T54211: OpenGL debug error message in texture draw mode.
Quite harmless and won't be a problem in 2.8.
2018-03-03 14:57:02 +01:00
8d575899a1 WorkSpace: use existing mode data w/ scene-switch
Check if mode data exists before attempting to change the modes.
2018-03-03 16:39:57 +11:00
b8f7538348 WorkSpace: avoid redundant notifiers w/ mode sync 2018-03-03 16:24:35 +11:00
d111f33008 WorkSpace: always change modes w/ the same active object 2018-03-03 12:28:42 +11:00
94b99949eb Fix T54202: Cycles crash rendering empty mesh volume after recent optimization. 2018-03-02 23:10:27 +01:00
Dalai Felinto
3fc2d122c4 Fix texture panel for Cycles
I keep reading that texture painting is not working yet. However it is fully
working. We even have a "Full Shading" option in the viewport display panel.

Clay/EEVEE still need their UI figured out. But the context itself is doing
its part after this patch, and at least for Cycles it's working like 2.79.
2018-03-02 17:19:04 -03:00
b6fe80ca19 Fix Cycle standalone build. 2018-03-02 19:56:22 +01:00
c43d51c1c2 Eevee: Make use of culling when rendering the shadowmaps. 2018-03-02 18:35:59 +01:00
9b47ad2974 Eevee: Cleanup & fix Warnings. 2018-03-02 18:35:59 +01:00
5e730974fe DRW: Add DRWMatrixState to manage all matrices together. 2018-03-02 18:35:59 +01:00
d63829117c DRW: Refactor simple instancing.
Instead of creating a new instancing shading group without attrib, we now have instancing calls. The benefits is that they can be culled.
They can be used in conjuction with the standard and generate calls but shader must support it (which is generally not the case).
We store a pointer to the actual count so that the number can be tweaked between redraw.

This will makes multi layer rendering more efficient.
2018-03-02 18:35:59 +01:00
62390527b2 Object Mode: Make use of optimized DRW_shgroup_call_object_add 2018-03-02 18:35:59 +01:00
1c12e1a2eb Clay: Perf: Early out of SSAO if there is no need for it. 2018-03-02 18:35:59 +01:00
Dalai Felinto
2308b5e9c5 Fix build errors in Linux 2018-03-02 13:09:32 -03:00
c327cf489c Merge branch 'master' into blender2.8 2018-03-02 16:42:27 +01:00
f76d49ed95 Depsgraph: Fix dependency cycle when ID prop drives ID property
Introduced explicit ID property node for driers in depsgraph,
so it is clear what is the input for driver, and what is the
output.

This also solved relations builder throwing lots of errors
due to ID property not being found.
2018-03-02 16:27:31 +01:00
411a781491 Depsgraph: Silence obviously noisy relations build errors
Those were happening for drivers which points to invalid drivers, and those
drivers will have their own dedicated error prints.
2018-03-02 15:51:44 +01:00
0fb55310b3 Depsgraph: Cleanup, use dedicated function to ensure node exists 2018-03-02 14:35:19 +01:00
f9f559a05f WorkSpace: Simplify exiting mode after changes
It was too tricky to know ahead of time if an object would still
be visible in the new window/workspace/scene/layer combination,
especially since other windows may share some of these data-blocks.

So store the context, make the change, then check if the object is
still visible, freeing mode data of it's not.
2018-03-03 00:23:02 +11:00
cedc7676ac Depsgraph: Cleanup, function return value
Driver build result was never used, so no reason to return operation.
2018-03-02 14:12:33 +01:00
35bd1bb957 WorkSpace: move edit mode w/ sync into own func 2018-03-02 23:04:19 +11:00
437801bec1 Correct draw manager locking flag check
Error in eeae50fc1c, thanks @mano-wii for spotting
2018-03-02 22:53:01 +11:00
42d9280b8a Depsgraph: Fix cycle detector to handle closed loops
It was possible to have relations like A -> B -> C -> A (import thing is
that no other operations points into this cluster) which were not detected
or reported by dependency cycle solver.

Now this is solved by ensuring we don't leave unvisited nodes behind.
2018-03-02 12:30:58 +01:00
99bcfb825f Cleanup: Avoid double semi-colon 2018-03-02 11:26:07 +01:00
b5b34bc2c0 Tests: Avoid access globals from abstract base class
Delegate functionality to subclasses, assert when subclasses didn't do
job the are supposed to do.

Thanks Sybren for pointing to a proper solution.
2018-03-02 11:18:12 +01:00
f2a2d5492b Cycles: Fix building of OpenCL kernels after volume optimization commit
OpenCL is C based, so no support for operators.

Related commit: 7377d411b4
2018-03-02 04:53:13 -05:00
e1f1567b56 WorkSpace: ED_workspace_object_mode_in_other_window check other windows
The same workspace can have different active objects depending on the
window. So check other windows.
2018-03-02 20:01:49 +11:00
a9509a2f8a Maintain scaling ratio of non-free axes in Maintain Volume T48079 fix.
This is probably a better way to handle it: instead of totally
discarding scaling of non-free axes, keep the ratio between them.
Basically the logic of the constraint is now that it rescales the
object uniformly in the non-free axis plane in order to force the
total volume change to the desired value.
2018-03-02 11:01:49 +03:00
8153f89518 WorkSpace: object-sync when changing workspaces. 2018-03-02 19:01:38 +11:00
eee3a4d3ab Cleanup: move ED_object_mode_generic_* to object_modes.c 2018-03-02 14:55:53 +11:00
da2d0fe43a Merge branch 'master' into blender2.8 2018-03-02 14:46:21 +11:00
4913e47aa0 Merge branch 'master' into blender2.8 2018-03-02 14:09:27 +11:00
ff74357da0 Object Mode: move logic to 'object_modes.c'
Was mixed with edit-mode, centralize mode switching in a single file.

No functional changes.
2018-03-02 14:00:47 +11:00
b7016e69b3 Cleanup: remove object-mode 'reset' check
Silently fail when attempting to enter a mode that's not compatible
with the object.
2018-03-02 13:37:35 +11:00
4df2179f19 Cleanup: rename 'screen_changed_update'
Match 'workspace_change_update'.
2018-03-02 13:25:21 +11:00
a7355c3221 WorksSpace: sync object-modes when changing scene
Note that this code will likely be generalized,
currently each new case is a little different though
so it's too early to move them into general functions.
2018-03-02 13:19:52 +11:00
7e4c23e4d7 FCurve: only calculate single axis length
Was calculating all 3
2018-03-02 12:45:25 +11:00
341ab45f7b Fix building w/o Python
Also minor cleanup.
2018-03-02 11:17:57 +11:00
bc23381a26 Cleanup: remove print 2018-03-02 10:22:10 +11:00
Dalai Felinto
b941d808c1 Remove legacy code used for sequencer preview image
This (now removed code) calls gl_Vertex deprecated draws. It was doing
background drawing (color gradient, flat background) which is not used
by any engine.
2018-03-01 18:22:31 -03:00
ec76f38b09 Discard non-free axis scaling in Maintain Volume to improve 2.79 compat.
It seems the reason the old version of the constraint overcompensates
as reported in T48079 is to allow the constraint to work with uniform
scaling on all axes. However the way it did that actually _requires_
uniform scaling for the constraint to work correctly, and breaks if
only the free scaling axis is used to avoid redundant channels.

This version attempts to allow both by discarding scaling in the non-
free directions instead of applying the correction on top of it.
2018-03-01 20:46:59 +03:00
3a3dfd4e65 Python tests: Split re-usable test related functionality to a module
The idea is to avoid re-implementing this for an upcoming FFmpeg tests.
2018-03-01 17:44:35 +01:00
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
Dalai Felinto
8f7e3600d1 More clean of macros with an _END and no _BEGIN
Follow up on 7aed2de798.
2018-03-01 12:23:25 -03:00
f242f3e75b Fix assert on exit edit-mode 2018-03-01 22:46:25 +11:00
865fdd61df 3D View: minor selection tweaks
- don't initialize the GL context when cache is used.
- don't run second pass when the first one has no hits.
2018-03-01 22:05:09 +11:00
1852e702ab Merge branch 'master' into blender2.8 2018-03-01 11:56:01 +01:00
7377d411b4 Cycles volume: fast empty space optimization by generating a tight mesh
around the volume.

We generate a tight mesh around the active voxels of the volume in order
to effectively skip empty space, and start volume ray marching as close
to interesting volume data as possible. See code comments for details on
how the mesh generation algorithm works.

This gives up to 2x speedups in some scenes.

Reviewed by: brecht, dingto

Reviewers: #cycles

Subscribers: lvxejay, jtheninja, brecht

Differential Revision: https://developer.blender.org/D3038
2018-03-01 11:54:01 +01:00
bcafdc82d8 WorkSpace: fix mode exiting w/ multi-window
Activating an object exited modes for all other objects in the layer.
Now check these objects aren't active in other windows first.
2018-03-01 21:33:06 +11:00
7aed2de798 Cleanup: macro's w/ an _END need a matching _BEGIN
Convention from 2.7x, since some looping macros don't need an '_END',
it avoids confusion to keep this.
2018-03-01 19:01:53 +11:00
1fc5eb305a Missing assignment in object mode sync
Own error in recent change (1aeb9294f4)
2018-03-01 18:37:49 +11:00
eeae50fc1c DRW: add ability to lock states from changing
Selection code relies on being able to set the depth functions
however passes have their own depth settings.

Add DRW_state_lock to ignore passes settings for particular flags.

This fixes occlusion queries cycling through objects under the cursor.
2018-03-01 17:14:35 +11:00
b5cc55c822 Merge branch 'master' into blender2.8 2018-03-01 16:48:13 +11:00
172614fb7d GPU_select: remove unused finalize function
Changed 2.8x code so this is no longer needed.
2018-03-01 16:43:45 +11:00
a459ef2827 Fix T54190: Occlusion query select failed
By default select wasn't picking the nearest object,
this could have been fixed by not clearing the depth buffer,
but calling GPU_select_(begin/end) without the binded frame-buffer
caused issues for depth-picking. So move GPU_select begin/end to a
callback.

This also has the advantage that only needs to populate the engines once
to draw two passes.

Note that cycling through objects fails with occlusion queries still,
will fix shortly.
2018-03-01 16:37:39 +11:00
68015f9d39 DRW: Initial implementation of Frustum culling.
This is very efficient and add a pretty low overhead (0.1ms of drawing time for 10K objects passing through all tests, on my i3-4100M).
The like the rest of the DRWCallState, test is "cached" until the view matrices changes.
2018-03-01 03:53:25 +01:00
dee2efb968 Clay: Make use of optimized DRW_shgroup_call_object_add. 2018-03-01 03:53:25 +01:00
5d0665d435 DRW: DRWCallState: Fix matflag being overwritten by other engines. 2018-03-01 03:53:25 +01:00
725112cce7 DRW: Codestyle: Remove DRWCallHeader and DRWCallGenerate 2018-03-01 03:53:25 +01:00
64e35f6fd2 DRW: Reuse DRWCallState for the same object.
This enables caching the matrices and reducing redraw time of the same object which is particulary important for eevee.
2018-03-01 03:53:25 +01:00
1ba96857d1 DRW: Merge calls_generate pool with calls pool & add DRWCallState pool. 2018-03-01 03:53:25 +01:00
d1da7dba47 DRW: Fix warnings in Release Build. 2018-03-01 03:53:25 +01:00
61c8ed40f5 WorkSpace: show/hode opt-out support for addons
In some cases it doesn't make sense for add-ons to be listed for hiding.
Especially for import/export which use minimal UI space.

This adds `bl_info["use_owner"]` to add-ons,
currently defaulting to True for all non Import-Export add-ons.
2018-03-01 11:22:46 +11:00
7f86afec9d Cycles: don't count volume boundaries as transparent bounces.
This is more important now that we will have tigther volume bounds that
we hit multiple times. It also avoids some noise due to RR previously
affecting these surfaces, which shouldn't have been the case and should
eventually be fixed for transparent BSDFs as well.

For non-volume scenes I found no performance impact on NVIDIA or AMD.
For volume scenes the noise decrease and fixed artifacts are worth the
little extra render time, when there is any.
2018-03-01 01:21:29 +01:00
33b6f944c6 Merge branch 'master' into blender2.8 2018-02-28 21:34:09 +01:00
03d1070378 Cycles: change principled BSDF default distribution and SSS.
* Use a subsurface color equal to the base color, and give the subsurface
  radius skin like values by default. This is how the parameter should
  typically be used.
* Use GGX by default, multiscatter GGX is still quite noisy and has some
  fireflies so let's keep it optional for now.
2018-02-28 21:31:28 +01:00
8cc7f48581 Cycles: principled absorption color now has more effect at lower values. 2018-02-28 20:11:53 +01:00
Dalai Felinto
382218beb2 Point cache: Pass EvaluationContext for all the related functions
Now the only missing bit seems to be in Cycles to pass depsgraph to
builtin_image_float_pixels().

Ideally we could get evaluation context instead of using depsgraph + settings.
But for the other rna EvaluationContext functions this is how we are doing.

Reviewers: sergey, brecht

Differential Revision: https://developer.blender.org/D3087
2018-02-28 13:55:56 -03:00
4a892adac5 merge from master (needed to fix collada headerfiles which have been modified in master and in blender2.8 slightly different) 2018-02-28 17:29:56 +01:00
4762c099d7 Fix T52685, part II: Add option to strip numbers from flipped bone names again.
While doing so with Bone_R.001, Bone_R.003, Bone_R.003 etc. is doomed to
issues, doing that on duplicates of actually correctly named bones can
be handy, and safe.

So adding back as an option (was removed in rB702bc5ba26d5).
2018-02-28 17:13:31 +01:00
e73fe77ac0 collada: EvaluationContext is now feeded into the class instances of AnimationExporter and DocumentExporter on creation. Also skipped the const qualifier for now because BKE_scene_graph_update_for_newframe() needs it to be not const 2018-02-28 17:10:57 +01:00
cee66b8cc0 Fix T52685: Flip names for bones its not working.
Flip names operator changed in rB702bc5ba26d5, to some sensible
behavior. But this breaks common workflow of 'duplicate part of the
bones, scale-mirror new ones, and flip their names'.

So now, instead of doing this in two steps, trying to guesstimate which
bones should get which name, just add option to flip names to duplicate
operator itself. Simpler, safer, and much, much more consitent behavior
and predictable results.
2018-02-28 16:59:32 +01:00
56ea42efa1 Radial control: Skip operator properties from being saved
This solves issue with tweaking brush size when interleaving particle edit
and texture paint modes. The issue was caused by texture paing setting more
operator properties then it's done for particle edit mode, which made window
manager to use saved proeprties for the "missing" ones.

Don't see any reason why we would want to save any of those properties.

This is a regression since rB83b60dac57a1.
2018-02-28 16:14:35 +01:00
a363324f7f Collada: Make EvaluationContext const as its only used for reading here 2018-02-28 16:05:29 +01:00
91c3cfbb6f collada: call from operator to Collada exporter/importer now uses structures instead of passing many parameters 2018-02-28 16:05:29 +01:00
01f732d97b Collada: Moved structure definitions for export settings to the exportSettings.h Also make typedefs for import/export structures. 2018-02-28 16:05:28 +01:00
d937d06c02 WorkSpace: UI filtering for add-ons
Allows for each workspace to have it's own add-ons on display.

Filtering for: Panels, Menus, Keymaps & Manipulators.
Automatically applies to add-ons at the moment.

Access from workspace, toggled off by default
once enabled, add-ons can be white-listed.

See D3076
2018-03-01 01:31:07 +11:00
80d1d9629e Depsgraph: Update tool settings when updating CoW scene 2018-02-28 14:57:49 +01:00
4e8bd537c3 Merge branch 'master' into blender2.8 2018-02-28 14:54:51 +01:00
8b8e16dc2c De-duplicate tool settings copy and make tool settings freeing reusable 2018-02-28 14:52:17 +01:00
bd25e73c54 Null pointer check exiting sculpt mode
Needed for 2.8x, harmless here.
2018-03-01 00:39:42 +11:00
e7aca5bd3c Null pointer check exiting sculpt mode
Needed for 2.8x, harmless here.
2018-02-28 23:23:48 +11:00
1aeb9294f4 WorkSpace: use existing objects mode on select
When selecting an object which is already visible in another window
use the mode from that workspace without performing any mode switching.
2018-02-28 23:09:33 +11:00
9e9cb9fce9 Workspace: sync object-modes to other workspaces
When changing the mode of an object, apply this to all other
workspaces that share the same active object.

Also use copy the object-mode when duplicating workspaces.
2018-02-28 20:04:21 +11:00
c0d6627dc5 Merge branch 'master' into blender2.8 2018-02-28 03:11:17 +01:00
c9a2927930 Code cleanup: fix a few harmless warnings. 2018-02-28 03:10:38 +01:00
2329cc09e6 Code cleanup: make viewport free simpler and consistent with GPU module. 2018-02-28 03:04:15 +01:00
8a7eb6c4c1 Update CUEW to latest version
Some Linux distribution have only libcuda.so.1, not libcuda.so.
2018-02-28 03:03:12 +01:00
7990105407 Code cleanup: fix a few compiler warnings. 2018-02-28 03:03:07 +01:00
be5e437bb5 DRW: Fix broken particle drawing.
Was caused by GPU_SELECT_LOAD_IF_PICKSEL_LIST not iterating at all if shgroup->instance_count == 0.
2018-02-28 02:24:21 +01:00
376e74f2aa Object Mode: Fix incorrect lightprobe wire color when in edit mode. 2018-02-28 02:10:38 +01:00
6bd53cb541 Cleanup: comment for depth picking code, const args
Note that setting `glDepthFunc` isn't important,
since 2.8 branch changes this value it might seem like an error
however it's harmless in this case - so better make note of this.
2018-02-28 11:47:54 +11:00
4d382e2564 DRW: Disable depth test when drawing statistics 2018-02-28 01:39:12 +01:00
6addaf7393 Cleanup: use 'uint' for GPU_select 2018-02-28 11:37:39 +11:00
74a22c8a8a DRW: Fix negative scale object drawing. 2018-02-28 01:29:26 +01:00
0df21e2504 DRW: Refactor & Split draw_manager.c into multiple files.
Refactor include:
- Removal of DRWInterface. (was useless)
- Split DRWCallHeader into a new struct DRWCallState that will be reused in the future.
- Use BLI_link_utils for APPEND/PREPEND.
- Creation of the new DRWManager struct type. This will enable us to create more than one manager in the future.
- Removal of some dead code.
2018-02-28 01:29:26 +01:00
d5a55b6918 BLI_link_utils: Add BLI_LINKS_APPEND(list, link) 2018-02-28 01:29:26 +01:00
11100faa5c Merge branch 'master' into blender2.8 2018-02-28 00:08:16 +01:00
bc71aa5a4c Cleanup: macros using _END, should have a _BEGIN
Also use var names not likely to be shadowed.
2018-02-28 10:05:38 +11:00
2eb94be750 Code cleanup: refactor Cycles image metadata retrieval to use a struct. 2018-02-27 23:42:30 +01:00
Dalai Felinto
000002e42d Cycles point density texture
This still does not make point density to work in Cycles, but at least it pass
the depsgraph down the line.

Note this was working fine before the depsgraph/render refactor to pass
evaluated depsgraph to the engines.
2018-02-27 18:25:54 -03:00
828f545213 Fix Cycles to mostly work with render layer / depsgraph changes.
Point density texture and motion blur are still broken, and many more changes
are needed in general to used evaluated datablocks.
2018-02-27 18:25:54 -03:00
Dalai Felinto
06420c5fe8 Refactor depsgraph/render logic to serve evaluated depsgraph to engines
User notes
----------
Compositing, rendering of multi-layers in Eevee should be fully working now.

Development notes
-----------------
Up until now we were still using the same depsgraph for rendering and viewport
evaluation. And we had to go out of our ways to be sure the depsgraphs were
updated.

Now we iterate over the (to be rendered) view layers and create a depsgraph to
each one, fully evaluated and call the render engines (Cycles, Eevee, ...) with
this viewlayer/depsgraph/evaluation context.

At this time we are not handling data persistency, Depsgraph is created from
scratch prior to rendering each frame.  So I got rid of most of the partial
update calls we had during the render pipeline.

Cycles: Brecht Van Lommel did a patch to tackle some of the required Cycles
changes but this commit mark these changes as TODOs. Basically Cycles needs to
render one layer at a time.

Reviewers: sergey, brecht

Differential Revision: https://developer.blender.org/D3073
2018-02-27 18:25:54 -03:00
Dalai Felinto
bd119ab017 Depsgraph: Expose query to get view layer to RNA 2018-02-27 18:25:54 -03:00
0f6c08c8cf Merge branch 'master' into blender2.8 2018-02-27 21:06:29 +01:00
450be3b226 Collada: Added tests for Animation export 2018-02-27 20:41:34 +01:00
1a65168c42 merge Collada changtes from master 2018-02-27 17:53:53 +01:00
Dalai Felinto
925f2280e6 Merge commit '6aadd61bd892d3908ed8151' into blender2.8 2018-02-27 13:48:26 -03:00
26fc197d49 Collada: commented out code was previously left over with an unresolved conflict in it. Deleting as its no longer needed 2018-02-27 17:14:35 +01:00
05b5958a7a Collada: Remove obsolete code 2018-02-27 17:08:40 +01:00
d1f0bdd337 fix: Collada Matrixdata Importer tried to fix rotations where nothing was to fix. The matrixdata import is now only doing a matrix decompose and then pplies the decomposed values to 3 trans-, 3 scale- and 4 rot-curves) 2018-02-27 17:02:52 +01:00
148e2ace61 Collada: removed unnecessary dup[licate matrix conversion in matrix data exporter 2018-02-27 17:02:52 +01:00
0ea110f4ea Collada exporter: Replaced numbers 0/1 by boolean values fasle/true for better reading 2018-02-27 17:02:52 +01:00
91f3cfec10 Collada Shape key export can create huge datafiles and may need some optimization. Disable export by default, user can still enable on demand 2018-02-27 17:02:52 +01:00
20c5131384 Collada enable Export of animation data by default 2018-02-27 17:02:52 +01:00
158a1de4fb DRW: Fix multithreading conflict with material previews. 2018-02-27 15:50:34 +01:00
ec0ecbe795 DRW: Refactor / Cleanup Builtin uniforms.
-Make the view and object dependant matrices calculation isolated and separated, avoiding non-needed calculation.
-Adding a per drawcall matrix cache so that we can precompute these in advance in the future.
-Replaced integer uniform location of only view dependant builtins by DRWUniforms that are only updated once per shgroup.
2018-02-27 14:50:16 +01:00
fe80d8ec3c DRW: Do not recreate the common uniform buffer every frame. 2018-02-27 14:50:16 +01:00
be284c82d4 GWN: Query builtin uniform at shader creation.
This avoids having non null entries in shaderface->builtin_uniforms and a redundant check.
2018-02-27 14:50:16 +01:00
3cc4070a30 Fix T54179: Assert changing layers in 2nd window 2018-02-28 00:08:49 +11:00
Dalai Felinto
12c8fef8c7 Eevee preview materials
Now that Eevee has support for offline rendering (F12) we can use it for
the Material previews.

Note: This makes the duplicated UI issue one panel worse. That happens when
Cycles if your scene engine, and Eevee is your workspace engine.
2018-02-27 09:31:16 -03:00
6aadd61bd8 Cleanup: remove unused duplicate code 2018-02-27 22:02:18 +11:00
3d7235fc87 MSVC 2013 Compile Fix/Workaround for "static thread_local" vars
Apparently MSVC 2013 has trouble with stuff that's been declared
"static thread_local" (and/or maybe even the "thread_local" keyword).

https://stackoverflow.com/questions/29399494/what-is-the-current-state-of-support-for-thread-local-across-platforms
2018-02-27 11:23:22 +01:00
5a1a63a858 Merge branch 'master' into blender2.8 2018-02-27 11:16:43 +01:00
26f4ce4a76 Collada: Remove unused vector of flaot[4][4] values
Was in fact causing issues on macOS, something to do with
a destructor.
2018-02-27 11:14:55 +01:00
2026179bb2 Collada: Use floating point version of abs()
Avoids implicit cast of float to int.
2018-02-27 11:14:17 +01:00
aa592cc00c Merge branch 'master' into blender2.8 2018-02-27 20:45:33 +11:00
a7ef312611 GPU_select: correction to select-pick-finalize
Would run twice, harmless at the moment but could cause issues later.
2018-02-27 20:44:12 +11:00
50d03de600 Fix error in depth picking caused by GL contexts
Depth picking needs to read the depth buffer after drawing
since GPU_select_end runs in a different OpenGL context
reading the depth buffer wasn't working.
This caused the last object to be unelectable.
2018-02-27 20:33:42 +11:00
efef0ee672 Merge branch 'master' into blender2.8 2018-02-27 20:24:02 +11:00
4de50d7572 GPU_select: utility function to finalize selection
Needed for depth picking in 2.8
2018-02-27 20:16:53 +11:00
24f759ba5a Revert "F12 offline Freestyle rendering support in Eevee"
This reverts commit 8a7c0abc2d.
2018-02-27 13:02:58 +09:00
50b95211bf Fix T54106: Save blend ignores 'check_existing' 2018-02-27 13:33:59 +11:00
8a7c0abc2d F12 offline Freestyle rendering support in Eevee
This patch adds F12 offline Freestyle rendering support to Eevee.

Most functionalities are identical with those found in Cycles.

The only major difference is that the per-view layer "use Freestyle" toggle
option is currently placed in the "Passes" panel of the "View Layers"
properties window instead of a "Layer" panel as in Cycles.  Since Freestyle
is a post-processed overlay and not a pass, the present option location is
a compromise.  To describe this fact, the per-layer "use Freestyle" option
is in a subsection labeled as "Layer".

Reviewers: fclem, brecht, campbellbarton

Reviewed By: fclem, brecht

Subscribers: dfelinto

Differential Revision: https://developer.blender.org/D3084
2018-02-27 08:53:31 +09:00
e24906759f Merge branch 'master' into blender2.8 2018-02-26 23:38:21 +01:00
b5f0e8e1a1 Collada: removed unused variables. fixed incompatible format in console output (AnimationExporter.cpp) 2018-02-26 23:37:27 +01:00
edcd30f6ab Merge branch 'blender2.8' of git.blender.org:blender into blender2.8 2018-02-26 22:55:15 +01:00
f228a08d02 merge from master 2018-02-26 22:49:30 +01:00
Dalai Felinto
96285e1ca4 VSE preview: Get depsgraph from EvaluationContext
Note: Sequencer preview is working only for Clay, for Eevee is still not working.
2018-02-26 18:04:18 -03:00
e94276d403 GWN: Fix glitches when closing a window. 2018-02-26 20:09:54 +01:00
c17042bc6d Eevee: Fix prev_persmat being used by multiple viewport. 2018-02-26 20:08:48 +01:00
f4cc9ba4c3 V3D: Vertex selection: Fix opengl error. 2018-02-26 20:07:39 +01:00
fa7e4cc685 WM/GPU: Clear VAO cache of batch preset when switching context.
This is needed for multiple windows to draw the batch presets.
This will not be needed once we use only one context for UI.
2018-02-26 19:49:06 +01:00
13261304a3 DRW: Add new Draw Manager OpenGL Context.
This separate context allows two things:
- It allows viewports in multi-windows configuration.
- F12 render can use this context in a separate thread and do a non-blocking render.

The downside is that the context cannot be used while rendering so a request to refresh a viewport will lock the UI. This is something that will be adressed in the future.

Under the hood what does that mean:
- Not adding more mess with VAOs management in gawain.
- Doing depth only draw for operators / selection needs to be done in an offscreen buffer.
- The 3D cursor "autodis" operator is still reading the backbuffer so we need to copy the result to it.
- All FBOs needed by the drawmanager must to be created/destroyed with its context active.
- We cannot use batches created for UI in the DRW context and vice-versa. There is a clear separation of resources that enables the use of safe multi-threading.
2018-02-26 19:41:17 +01:00
0940e89e60 GHOST: Add new interface to manage offscreen contexts.
Offscreen contexts are not attached to a window and can only be used for rendering to frambuffer objects.

CGL implementation : Brecht Van Lommel (brecht)
GLX implementation : Clément Foucault (fclem)
WGL implementation : Germano Cavalcante (mano-wii)

Other implementation are just place holder for now.
2018-02-26 19:10:15 +01:00
7dd0e36dc4 simplified collada integration in Blender. made functions mostly similar with blender2.8 2018-02-26 17:18:31 +01:00
a024da55af Adding support for Matrix Transformation export
The exporter does export matrix data (4*4 Transformation matrix) only for Skeletal animation. For object animation only exporting to trans/rot/loc is implemented.

This task implements Matrix export also for simple Object animation.

Differential Revision: https://developer.blender.org/D3082
2018-02-26 17:16:56 +01:00
5f9657316e collada: fix typo in if statement 2018-02-26 12:55:54 +01:00
57b378b046 as discussed on IRC this definition seems to be not necessary 2018-02-26 12:45:37 +01:00
8e826caf5e optimized the output of the collada test script for better reading 2018-02-26 12:09:48 +01:00
c52df4fc7c Cleanup: typos
D3081 by @rjg, with others.
2018-02-26 19:58:31 +11:00
f1bd96a9ab Revert "changing collada parameters"
This reverts commit d91f2ac37a.

This change makes scene.collada_export() meaningless
(ignoring the scene the method is being run on).
2018-02-26 19:35:45 +11:00
3fd5a4047c Presets: remove double underscore in preset names 2018-02-26 19:21:02 +11:00
d416e56e70 Fix T54029: Wrong preset name display in win32 2018-02-26 19:05:01 +11:00
b1414b7322 Cleanup: use function for clearing bmesh tags 2018-02-26 14:05:58 +11:00
Hugo Sales
5d54d6b479 Fix T50132: UV sticky mode is not respected with border/circle/lasso select.
Differential Revision: https://developer.blender.org/D3074
2018-02-25 22:28:54 +01:00
ec27281812 Fix incorrect text clipping on node link button in material properties. 2018-02-25 19:57:40 +01:00
d6df23d9d9 Object Mode: Display meshes without faces and edges in object mode. 2018-02-25 17:55:49 +01:00
b795f5eb7a Eevee: Cleanup cascaded shadowmap code. 2018-02-25 17:55:49 +01:00
241c90c92d DRW/GWN: Bypass glUseProgram.
Turns out to be the call that was destroying performance.

I get 18ms->6ms improvement of drawing time with 10 000 unique objects.

And we can still improve upon this!
2018-02-25 17:59:46 +01:00
24d51a05a9 Manipulator: rename is_visible -> poll
Rename to WM_manipulator_group_type_poll,
use convention of other poll functions.
2018-02-26 00:04:59 +11:00
15dfd866db Fix Player tm, a lifes job 2018-02-25 10:35:08 +01:00
2b158861a3 merged collada rework from master into blender 2.8 2018-02-25 00:06:41 +01:00
d91f2ac37a changing collada parameters
Differential Revision: https://developer.blender.org/D3080
2018-02-24 22:51:04 +01:00
0a1434ed86 Fix a whitespace slipped in 2018-02-24 18:07:05 +01:00
c23b77fe46 Fix Plyer tm 2018-02-24 17:30:37 +01:00
dd7b9a362d T45687: Rework the Export/Import of Animations
This started with a fix for an animated Object Hierarchy. Then i decided to cleanup and optimize a bit. But at the end this has become a more or less full rewrite of the Animation Exporter. All of this happened in a separate local branch and i have retained all my local commits to better see what i have done.

Brief description:

* I fixed a few issues with exporting keyframed animations of object hierarchies where the objects have parent inverse matrices which differ from the Identity matrix.
* I added the option to export sampled animations with a user defined sampling rate (new user interface option)
* I briefly tested Object Animations and Rig Animations.

What is still needed:

* Cleanup the code
* Optimize the user interface
* Do the Documentation

Reviewers: mont29

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D3070
2018-02-24 15:55:27 +01:00
94eb189752 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/BKE_blender_version.h
2018-02-24 14:02:50 +01:00
4403ca80bd Smoke: expose empty space clipping property to the UI.
This is used to determine which voxels are to be considered empty space.

Previously it was hardcoded for converting dense grids to OpenVDB grids
to reduce disk space usage.

This value is also useful for rendering engines to know, i.e. to
optimize ray marching.
2018-02-24 13:37:58 +01:00
6d8a4c10b6 OpenVDB : use underscores instead of spaces in grid names.
Some other software cannot handle grid names with spaces in them. We still check for names with spaces so as to not break old
files.

This fixes T53802.
2018-02-24 13:37:08 +01:00
Dalai Felinto
c4abb33102 Fixup for border render changes
Although I fixed border rendering, I broke non-border rendering.

Issue introduced on:  0305fc30b3
2018-02-23 17:26:57 -03:00
38ccd1fe33 Eevee: add Principled Volume shader. 2018-02-23 19:10:24 +01:00
77062e8bbb Eevee: add blackbody shader node support.
This replaces the blackbody to RGB code with the simpler and faster one from
Cycles. It's a little different but the other placing using this is the legacy
volume drawing, so no need to stay compatible with that.
2018-02-23 19:10:24 +01:00
57609993d0 GPU: fixes for string socket types in shader nodes.
These are not passed to GLSL functions, but should be used to load e.g.
a texture or attribute.
2018-02-23 19:10:24 +01:00
af061b4dac Eeevee: add temperature grid support, make color grid unpremultiplied.
This matches similar changes done for Cycles.
2018-02-23 19:10:02 +01:00
a44b08a6c4 Merge branch 'master' into blender2.8 2018-02-23 19:02:49 +01:00
0aec2dcd3a Cycles: add Principled Volume shader.
Similar to the Principled BSDF, this should make it easier to set up volume
materials. Smoke and fire can be rendererd with just a single principled
volume node, the appropriate attributes will be used when available. The node
also works for simpler homogeneous volumes like water or mist.

Differential Revision: https://developer.blender.org/D3033
2018-02-23 18:57:58 +01:00
acd619d7c9 Cycles: change smoke color grid to not include density multiplied in.
This breaks backwards compatibility some, making smoke colors brighters
than before. But it is also more correct this way.
2018-02-23 18:57:58 +01:00
a963c7d48d Code refactor: improve attribute handling for optional volume attributes.
A volume shader should be able to request attributes, and still be rendered
as homogeneous if no volume attributes are available for the object.
2018-02-23 18:57:58 +01:00
4448ed6c5e Smoke: change default flame temperatures to match OpenGL preview. 2018-02-23 18:57:58 +01:00
04896d223d Smoke: add temperature grid, with values 0..1 corresponding to 0..1000K. 2018-02-23 18:57:58 +01:00
15fb8ad6ae Nodes: left align text for color and string sockets, same as other types. 2018-02-23 18:57:58 +01:00
Dalai Felinto
0305fc30b3 Fix border rendering for eevee + stop passing render result around
Technically the original issue is that xof/yof in render result is calculated
for drawing border render. So a simpler patch could be:

```
- rr->xof = re->disprect.xmin;
+ rr->xof = re->disprect.xmin + BLI_rcti_cent_x(&re->disprect) - (re->winx / 2);
```

However everywhere in the code we are getting border directly from re->disprect
which we may as well do here too.

Besides I'm taking this as a chance to get rid of RenderResult in the internal
loop of eevee, to help prepare the code to the upcoming rendering pipeline
changes.
2018-02-23 13:26:30 -03:00
dceb8d37c2 Fix T54137: OpenEXR files with long red/green/blue channel names not loading correctly. 2018-02-23 14:34:27 +01:00
44d45e1af4 Buildbot: Enable Volta deviced CUDA binaries 2018-02-23 14:24:59 +01:00
e24dee435e Buildbot: Remove master configuration files
Those are stored in blender-buildbot repository now, so having them in
Blender only causes extra work to keep files in sync.
2018-02-23 12:37:05 +01:00
07f05e294a Buildbot: Disable cuda hack for macOS 2018-02-23 10:55:26 +01:00
5127910749 Merge branch 'master' into blender2.8 2018-02-23 17:12:55 +11:00
6618852b7f WM: Add WM_menutype_poll function
Wraps menutype poll, no functional changes.
2018-02-23 17:02:03 +11:00
171c756f20 Merge branch 'master' into blender2.8 2018-02-23 13:10:39 +11:00
f36c803e55 WM: add WM_keymap_poll function
Wrapps keymap poll, no functional changes.
2018-02-23 12:59:55 +11:00
dd77e45151 Cleanup: header guards & style 2018-02-23 12:59:55 +11:00
Dalai Felinto
d7ba1ada82 Fix T54136: Crash when deleting an object that is in an instanced group
We were not cleaning up groups after deleting objects, leaving groups with
Bases that had no object.

It includes a unittest.

Reviewers: mont29
2018-02-22 17:16:39 -03:00
e7c4a9d1ef GWN: Fix immediate mode when closing a window. 2018-02-22 19:49:59 +01:00
8115162e98 DRW: Fix T54135 : Crash caused by wrongly iterating over ListBase. 2018-02-22 19:47:52 +01:00
d4795cc5d1 DRW: Fix use of uninitialized call->obmat. 2018-02-22 19:47:52 +01:00
03d1f08282 WM: Make sure that immediate mode is active before deactivate it 2018-02-22 13:22:28 -03:00
2694c1fc60 Merge branch 'master' into blender2.8 2018-02-22 16:31:59 +01:00
71e00252f0 Depsgraph: Fix mistake in previous refactor commit 2018-02-22 16:30:47 +01:00
2f5f392453 Merge branch 'master' into blender2.8 2018-02-22 15:45:41 +01:00
5f857378af Cleanup: Fix const pointers mess in previous commit. 2018-02-22 15:41:41 +01:00
4ee3d7e3ac Merge branch 'master' into blender2.8
Conflicts:
	source/blender/bmesh/intern/bmesh_mesh.c
2018-02-22 15:22:44 +01:00
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
4b068c4d6f Cleanup: clnor code: more 'do not use same varname for two different things'. 2018-02-22 15:20:39 +01:00
e83b9cde1a Fix T54129: Moving keyframes on top of other keyframes, removes both keyframes
Regression caused by earlier commits to improve the automerge behaviour.
In this case, the problems only occurred when moving a selected keyframe
forwards in time to overlap an unselected keyframe.
2018-02-23 03:13:56 +13:00
00ba28e9f8 Fix: Don't ignore duplicate channels when doing border/circle/lasso select
While it is necessary to ignore duplicates when doing Deselect/Column Select
(where double-updates may result in nothing being selected), for borderselect,
not including the duplicates meant that sometimes, nothing would happen
if you were trying to borderselect keyframes originating from hidden channels.

This was first noticed in the greasepencil-object branch, but affects all
animation channel types.
2018-02-23 02:41:05 +13:00
5aff002f7b GWN: Context: Fix allocation/codestyle and crash on startup. 2018-02-22 14:31:40 +01:00
672e823578 Merge branch 'master' into blender2.8 2018-02-22 14:27:57 +01:00
86ad5cacfa Depsgraph: Remove unused argument 2018-02-22 14:27:29 +01:00
4a0d8f92f6 Remove old depsgraph from modifiers relations update context 2018-02-22 14:09:45 +01:00
539987766b Merge branch 'master' into blender2.8 2018-02-22 14:08:27 +01:00
3d1c0afe0e Depsgraph: Remove unused bmain from modifiers relations update context 2018-02-22 14:07:08 +01:00
62b3522da2 Fix compilation error with legacy depsgraph disabled 2018-02-22 13:05:38 +01:00
6e860bef28 Merge branch 'master' into blender2.8 2018-02-22 13:05:00 +01:00
df04520602 Depsgraph: Wrap all arguments foe modifiers relations update into a struct
Makes it easier to add or remove fields needed to update relations.
2018-02-22 12:54:06 +01:00
cc05b661f7 GWN: Fix use after free crash.
This is not an ideal solution but blender freeing system is already well tangled.
So tracking and clearing vao caches when destroying contexts does prevent bad behaviour.
2018-02-22 12:39:57 +01:00
a17de773fd Merge branch 'master' into blender2.8 2018-02-22 11:20:28 +01:00
93072e44d1 Depsgraph: Replace LIB_TAG_DOIT with hash lookup
This allows us to:

- Not mock around with tags stored in a global space,
    and not to iterate over all datablocks in the database
    to clear the tags.

- Properly deal with datablocks which might not be in main database.

    While it sounds crazy, it might be handy when dealing with preview,
    or some partial scene updates, such as motion paths.

- Avoids majority of places where depsgraph construction needed bmain.

    This is something what could help in blender2.8 branch.

From tests with production file here did not see any measurable slowdown.

Hopefully, there is no functional changes :)
2018-02-22 11:03:39 +01:00
76953a6ebd Depsgraph: Add utility class to keep track of handled ID datablocks
Currently unused, actual logic change will come in the next commit.
2018-02-22 10:58:33 +01:00
6bac7c35e8 Merge branch 'master' into blender2.8 2018-02-22 10:47:40 +01:00
51483bd49f Depsgraph: Use proper debug print flags check
Was printing some tagging/evaluation prints when only building
messages were requested.
2018-02-22 10:40:18 +01:00
9729726aa8 Depsgraph: Report graph construction time when run with --debug-depsgraph-build 2018-02-22 10:35:04 +01:00
632d66eb89 Depsgraph: Cleanup, reduce indentation level 2018-02-22 10:31:47 +01:00
4ab002bca3 WorkSpace: object-mode switching support
When changing workspaces, existing object-mode data is freed
the new workspaces mode is entered (if possible).
2018-02-22 18:18:44 +11:00
5b857102fa Add NULL checks to ED_object_base_activate
Passing a NULL active base is valid,
own changes to mode-switching didn't check for this case.
2018-02-22 17:09:25 +11:00
026ac65831 WorkSpace: Restore saved object-modes again
Was temporarily removed when moving object mode to workspace.

Note: there is an issue where eval_ctx->view_layer is NULL on load,
for now pass a view layer argument, we might wan't to set the value
instead.
2018-02-22 15:52:30 +11:00
648df0fcdb Revert "BKE: Changing ID freeing order."
This reverts commit 87c72a7d27.

Caused T54121 which breaks blend file saving.
For now crash on exit is preferable.
Possible solution is to free screen-manipulator batches in a separate
loop.
2018-02-22 15:10:43 +11:00
257cf86a05 Merge branch 'master' into blender2.8 2018-02-22 00:59:32 +01:00
5d5c6bb5ef Cycles: add Russian roulette termination for volume multiple scattering.
This mainly helps with dense volumes, rendering can be 30% faster with
little noise increase in such scenes.
2018-02-22 00:55:32 +01:00
2d81758aa6 Cycles: better path termination for transparency.
We now continue transparent paths after diffuse/glossy/transmission/volume
bounces are exceeded. This avoids unexpected boundaries in volumes with
transparent boundaries. It is also required for MIS to work correctly with
transparent surfaces, as we also continue through these in shadow rays.

The main visible changes is that volumes will now be lit by the background
even at volume bounces 0, same as surfaces.

Fixes T53914 and T54103.
2018-02-22 00:55:32 +01:00
84e92f9b3c Cycles: make principled BSDF node wider in the node editor by default. 2018-02-22 00:55:32 +01:00
6a48a9dc6e Code cleanup: fix incorrect socket names in hair and particle info nodes. 2018-02-22 00:55:11 +01:00
04964ff1f4 GWN: Fix compilation on windows 2018-02-21 18:58:29 -03:00
87c72a7d27 BKE: Changing ID freeing order.
Screen can contains manipulators that contains batches to be freed before the opengl contexts (in WM) are destroyed.

Also fix other GPU related free.
2018-02-21 22:51:35 +01:00
9a5be1fba9 Fix incorrect OSL raytype bits and add some comments. 2018-02-21 17:56:26 +01:00
606bc5f301 Fix T54105: random walk SSS missing in branched indirect paths.
Unify the path and branched path indirect SSS code. No performance impact
found on CUDA, for AMD split kernel the extra code was already there.
2018-02-21 17:56:26 +01:00
5cc1d5fe17 Fix T54107: bevel shader + normal map gives wrong result. 2018-02-21 17:56:26 +01:00
7be1928ea1 Gawain: VertexFormat: Cleanup
Reorganize struct elements by size, rename a constant.
2018-02-21 15:28:26 +01:00
c5eba46d7f Gawain: Refactor: VAOs caching AND use new VAOs manager.
A major bottleneck of current implementation is the call to create_bindings() for basically every drawcalls.
This is due to the VAO being tagged dirty when assigning a new shader to the Batch, defeating the purpose of the Batch (reuse it for drawing).

Since managing hundreds of batches in DrawManager and DrawCache seems not fun enough to me, I prefered rewritting the batches itself.

--- Batch changes ---
For this to happen I needed to change the Instancing to be part of the Batch rather than being another batch supplied at drawtime.
The Gwn_VertBuffers are copied from the batch to be instanciated and a new Gwn_VertBuffer is supplied for instancing attribs.
This mean a VAO can be generated and cached for this instancing case.

A Batch can be rendered with instancing, without instancing attribs and without the need for a new VAO using the GWN_batch_draw_range_ex with the force_instance parameter set to true.

--- Draw manager changes ---
The downside with this approach is that we must track the validity of the instanced batch (the original one). For this the only way (I could think of) is to set a callback for when the batch is getting free.
This means a bit of refactor in the DrawManager with the separation of batching and instancing Batches.

--- VAO cache ---
Each VAO is generated for a given ShaderInterface. This means we can keep it alive as long as the shader interface lives.
If a ShaderInterface is discarded, it needs to destroy every VAO associated to it. Otherwise, a new ShaderInterface with the same adress could be generated and reuse the same VAO with incorrect bindings.
The VAO cache itself is using a mix between a static array of VAO and a dynamic array if the is not enough space in the static.
Using this hybrid approach is a bit more performant than the dynamic array alone.
The array will not resize down but empty entries will be filled up again. It's unlikely we get a buffer overflow from this. Resizing could be done on next allocation if needed.

--- Results ---
Using Cached VAOs means that we are not querying each vertex attrib for each vbo for each drawcall, every redraw!
In a CPU limited test scene (10000 cubes in Clay engine) I get a reduction of CPU drawing time from ~20ms to 13ms.

The only area that is not caching VAOs is the instancing from particles (see comment DRW_shgroup_instance_batch).
2018-02-21 15:28:26 +01:00
1b3f9ecd0d Gawain: Add new context/vao manager.
This allows allocation of VAOs from different opengl contexts and thread as long as the drawing happens in the same context.

Allocation is thread safe as long as we abide by the "one opengl context per thread" rule.

We can still free from any thread and actual freeing will occur at new vao allocation or next context binding.
2018-02-21 15:28:26 +01:00
7de387f4b5 Cleanup: Don't perform borderselect on channels that aren't visible 2018-02-22 01:46:12 +13:00
cab608066a Fix: Return back to conventional way of averaging points for keyframe de-dup
The other approach was causing too much error in some cases (e.g. favouring
the lower-valued keyframes). This fix should make the resulting curves less
bumpy/jagged.
2018-02-22 01:46:11 +13:00
915d120c36 Fix: Forgot to recalculate handles after deleting keyframes 2018-02-22 01:46:11 +13:00
bba1120116 Fix: Don't average keyframe values if FCurve can only have int/discrete values
This is to prevent problems with integer/enum properties getting invalid
values set.
2018-02-22 01:46:10 +13:00
dd75211d83 Cleanup: Delete debugging code and the old version of the automerge code 2018-02-22 01:46:10 +13:00
f2cdb1c7cc Tweak/Fix for T54106 - Moving multiple selected keyframes on top of an unselected one would not merge the keys
This commit removes an earlier attempt at optimising the lookups
for duplicates of a particular tRetainedKeyframe once we'd already
deleted all the selected copies. The problem was that now, instead
of getting rid of the unselected keys (i.e. the basic function here),
we were only getting rid of the selected duplicates.

With this fix, unselected keyframes will now get removed (as expected)
again. However, we currently don't take their values into account
when merging keyframes, since it is assumed that we don't care so much
about their values when overriding.
2018-02-22 01:46:09 +13:00
63da3b79ed Minor Optimisation: Terminate early if we've passed the insertion point for tRetainedKeyframes 2018-02-22 01:46:08 +13:00
ac717928ad Feature Request T54106: When scaling keyframes, merge (by-averaging) selected keys
that end up on the same frame

Currently, when scaling keyframes in the Dopesheet, if multiple
selected keyframes end up on the same frame post-scaling, they
would not get removed by the "Automerge" setting that normally
removes duplicates on the same frame.

This commit changes the behaviour so that when multiple selected
keyframes end up on the same frame, instead of keeping all these
around on the same frame (e.g. resulting in a column of keyframes
on different values), we will instead merge them into a single
keyframe (by averaging the values). This should result in a
smoother F-Curve with fewer "stair-steps" that need to be carefully
cleaned out afterwards.

Requested by @hjalti
2018-02-22 01:46:07 +13:00
6b31a14ff7 bezt_add_to_cfra_elem() - Use same keyframe equality test as in other places
This shouldn't affect anything currently, as this function doesn't appear
to get used anywhere.
2018-02-22 01:46:07 +13:00
4d966aa19c Fix T54065: NLA-Strip Control Curves would get disabled when name-based-filtering is enabled
This bug took a while to track down. In the test file with this report,
the Nla-Strip Control Curve for strip time would get disabled if you
changed the NLA Editor to a second Graph Editor instance.

It turns out that because this second Graph Editor would have the
"filter fcurves by name" option enabled, this would trigger a lookup
of the referenced property's name (in order to test whether it matched
the filtering criteria). However, since that filtering code was written
before the introduction of these curves, it still assumed that the names
for these Control Curves should be handled the same as for standard FCurves.
Unfortunately, that doesn't work, as the property lookups fail if the standard
method is used - when the lookups fail, the F-Curves get tagged as being
invalid/disabled (and need to be reset using the "Revive Disabled FCurves"
operator).

Note: The changes in this patch look complicated, as I've had to shuffle
a bit of code around so that the name-filtering check can have access to
the additional info it needs. In the process, I've also removed the earlier
(hacky) approach where the control curves were getting added to a temp
buffer to get changed from normal FCurves to special ANIMTYPE_NLACURVES.
2018-02-22 01:46:06 +13:00
f7354119cc Fix more missing ID remapping in animation editor callbacks
Applying the same fixes as introduced in 98d797b67c
this time, for the Graph and NLA editors
2018-02-22 01:46:05 +13:00
2945831630 Depsgraph: Fix fake dependency cycle with chained IK solvers with tip excluded
Not sure why we need a relation from solver to a tip local transform, this
will be handled via parent relation.

Fixes remaining dependency cycles reported in T54083.
2018-02-21 12:04:28 +01:00
74ee98f642 Depsgraph: Fix dependency when constraint influence drives some other constraint
It is not possible to address transform at particular position of constraint
stack, and when constraint is being addressed is usually from driver variable.

This fixes some of dependency cycles reported in T54083.
2018-02-21 11:13:25 +01:00
d4ee0cee51 Merge branch 'master' into blender2.8 2018-02-21 10:51:58 +01:00
fe1a508e55 Depsgraph: Split debug flags
Now it's possible to have debug messages for following things:

- Graph construction
- Graph evaluation
- Graph tagging
2018-02-21 10:44:36 +01:00
2e73efa9b8 Depsgraph: Fix crash using --debug-depsgraph and --debug-depsgraph-no-threads
Was accessing past the array boundaries.

Should be safe for 2.79a.
2018-02-21 10:42:22 +01:00
bfa51b1b0c Fix subsurf modifier after error in merge commit
Merge commit that had the error: e99094035c
2018-02-21 04:38:29 -05:00
78ceb4b51e Merge branch 'master' into blender2.8 2018-02-21 10:30:50 +01:00
b1946e7f7a Depsgraph: Report overall number of cycles detected
Handy to quickly see if a fix fixed any of the cycles in a real rig,
or whether it's introduced new ones.
2018-02-21 10:11:43 +01:00
6535f668b4 VSE: skip non image/movie w/ proxy dir storage
This would use uninitialized filename variable,
looked into supporting this however generating proxies currently only
works for movies.
2018-02-21 18:33:48 +11:00
Dalai Felinto
813204838a Fix for draw manager cache not re-set between different render layers 2018-02-20 16:43:15 -03:00
Dalai Felinto
c14925bddf Proper implementation of compositor support for Draw Manager
We need to move the render result logic outside the render engine code.

It makes no sense for Eevee/Clay/... to have to re-implement the render resilt
creation logic. Beside the original implementation really got it wrong, by
ignoring the different render layers needed for the final render.

Finally, there is no need to re-create the logic for views. So this was also
fixed.

Note 1: This will break still if the depsgraph of the needed view layers is not
updated / created. We need to address this separately. For now if users want
to test this, just show each view layer in the viewport at least once.

Note 2: We are still getting depsgraph from scene and creating if needed.
`BKE_scene_get_depsgraph(scene, view_layer, true);` according to Sergey we need
to move the render depsgraph for the Render struct instead. I will do it
separately as well.
2018-02-20 11:03:26 -03:00
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
87e37224c7 Fix T54069: Vertex groups for hair length is wrong in some cases
This is a regression in rB4f1c0a1 which only allowed cutting haior at the
second segment only, while there is nothing wrong with cutting hair at the
first segmewnt.
2018-02-20 10:47:01 +01:00
529cc364f4 Fix T54096: Subdivision Surface + Boolean Modifiers + Transform = crash
Don't use dm->get*Array for DM you don't own. This call can allocate temporary
CD layer, which is not thread safe at all.

Also removed hard-coded logic around CDDM check. new functions will do same
logic, but are mode DM-type-=independent.
2018-02-19 16:16:56 +01:00
Dalai Felinto
a16c0ebc59 Fix warning after fix for crash on renaming group collections
Warning introduced on: 73079e01fd.
2018-02-19 11:12:46 -03:00
Dalai Felinto
73079e01fd Outliner: Fix crash when renaming Group layer collection 2018-02-19 10:52:03 -03:00
Dalai Felinto
065630e717 Outliner: Update buttons editor when renaming collection
Reported by Pablo Vazquez (venomgfx) outside phabricator.
2018-02-19 10:48:07 -03:00
dc65a6f63b Fix T53032: Image sequence works bad with Displace modifier
We shouldn't mix image pool acuisition with and without user provided,
the fact that internally image.c uses last frame from Image datablock
confuses the logic.
2018-02-19 14:33:48 +01:00
Dalai Felinto
30d0194585 Fix collection object mode panels
They were broken since we moved object mode into workspace.
2018-02-19 09:53:39 -03:00
0e4829eb05 Cleanup: rename SequenceEditor instance to 'ed'
Name 'sequencer' & 'sequence' are too similar.
2018-02-19 22:32:41 +11:00
264691e563 Merge branch 'master' into blender2.8 2018-02-19 17:46:42 +11:00
860939ccc2 Cleanup: remove BMeshToMeshParams.calc_tessface
This wasn't used, tessface is being phased out.
Caller can run explicitly if needed.
2018-02-19 17:41:37 +11:00
05f3e245a8 Fix T54098: Crash existing /w dyntopo sculpt
Optionally don't remap indices for objects.

Checking all objects parent's would reference a freed pointer
while freeing all objects.

In the case of dynamic topology there is no use in keeping track
of hook/vertex-parent indices.

Also disable this when creating meshes for undo storage
since adding an undo step shouldn't be modifying other objects.
2018-02-19 17:34:30 +11:00
34e76c7162 Merge branch 'master' into blender2.8 2018-02-19 15:59:20 +11:00
7f65ab86e5 Cleanup: sync vertex-paint and sculpt from 2.8
Sync API changes from 2.8 to master.
2018-02-19 15:54:06 +11:00
569273c234 Merge branch 'master' into blender2.8 2018-02-18 19:59:27 +01:00
1beb6b43c1 Fix T54089: missing GLSL material draw update when changing object pass index. 2018-02-18 19:28:46 +01:00
2bc952fdb6 Merge branch 'master' into blender2.8 2018-02-18 22:33:05 +11:00
7ff3cd2693 Cleanup: group BLI_ghash_utils.c API in BLU_ghash.h 2018-02-18 22:12:27 +11:00
41ad08f3c3 Cleanup: split GHash helpers from implementation 2018-02-18 21:44:56 +11:00
deacb3d6b8 Cleanup: add 2d suffix to BLI files
Some of these API's can have 3D versions, explicitly name them 2D.
2018-02-18 21:27:33 +11:00
fee4b646c4 Cycles: tweak CUDA messages and avoid build errors with existing sm_2x configs. 2018-02-18 00:53:25 +01:00
1dcd7db73d Code cleanup: remove some more unused code after recent CUDA changes. 2018-02-18 00:53:03 +01:00
9e717c0495 Cycles: Remove Fermi texture code.
This should be the last Fermi removal commit, unless I missed something.
It's been a pleasure Fermi!
2018-02-17 22:56:58 +01:00
e1ef902058 Cycles: Remove fermi related defines from the code.
Did not touch Texture related defines, that comes next.
2018-02-17 22:19:54 +01:00
2eaf90b305 Cycles: Remove Fermi support from CMake and update runtime checks in device_cuda.cpp.
Fermi code in Cycles kernel and texture system are coming next.
2018-02-17 16:15:07 +01:00
75396edb31 Buildbot: Disable Cycles CUDA support on 32bit, and stop building sm_2x. 2018-02-17 15:49:37 +01:00
5d3f679013 Code cleanup: remove WM subwindows.
These no longer made much sense after regions were added, they just
duplicated state that was already in the regions.
2018-02-17 14:23:19 +01:00
cbd0e09898 Fix GL_FRAMEBUFFER_UNSUPPORTED warning in console on macOS. 2018-02-17 14:12:54 +01:00
f2453ecdcd Merge branch 'master' into blender2.8 2018-02-17 01:39:29 +01:00
09eb790f4b DRW: Fix assert with DRW_shgroup_material_instance_create. 2018-02-16 23:06:43 +01:00
85f179eb23 Fix T53399: Dopesheet keyframes and the drawing of points were not visible with some Intel cards 2018-02-16 18:02:06 -02:00
4b1904c8df GHOST: Windows: Print information on the GPU 2018-02-16 16:46:58 -02:00
5bc2c17161 fix:T50079 collada matrix and blender matrix are transposed. This was not regarded by the animation importer, so it was creating very odd results 2018-02-16 16:58:20 +01:00
e1a686e444 fix: limit precision also for animation matrixes if the limit option is set (gives nicer output for inspection) 2018-02-16 16:55:20 +01:00
c45f28ce95 New function to check if running opengl render 2018-02-16 16:52:27 +01:00
7fdf720fb1 Fix rotation issues due to matrix to quaternion ambiguities
Reviewers: mont29

Reviewed By: mont29

Subscribers: mont29

Differential Revision: https://developer.blender.org/D3066
2018-02-16 15:19:35 +01:00
18bb0bc569 Object Mode: exit sculpt on selection 2018-02-17 00:01:25 +11:00
ce4d52c4f3 Object Mode: exit vert/weight paint on selection
Was keeping data, since objects no longer store modes,
object mode can't be properly detected.
2018-02-17 00:01:25 +11:00
c28dea5e24 Vertex Paint: expose exist paint-mode to API 2018-02-17 00:01:25 +11:00
31f47f44de Cleanup: avoid shadowing w/ name 'base' 2018-02-17 00:01:25 +11:00
233a886ceb Code cleanup: deduplicate code for running Python scripts outside Blender. 2018-02-16 12:51:49 +01:00
3d2d58391a Tests: add OpenGL UI drawing tests.
This reuses the Cycles regression test code to also work for OpenGL UI drawing.
We launch Blender with a bunch of .blend files, take a screenshot and compare
it with a reference screenshot, and generate a HMTL report showing the failed
tests and their differences.

For Cycles we keep small reference renders to compare to in svn, but for OpenGL
developers currently have to generate the references manually. How to use:

* WITH_OPENGL_DRAW_TESTS=ON in CMake
* BLENDER_TEST_UPDATE=1 ctest -R opengl_draw
* .. make code changes ..
* ctest -R opengl_draw
* open build_dir/tests/opengl_draw/report.html

Differential Revision: https://developer.blender.org/D3064
2018-02-16 12:51:49 +01:00
0f23f618f3 Tests: split off render report test code from Cycles tests.
This renames test environment variables from CYCLESTEST_* to BLENDER_TEST_*.

Differential Revision: https://developer.blender.org/D3064
2018-02-16 12:51:49 +01:00
5fde26454c Fix bplayer (c) 2018-02-16 12:40:11 +01:00
c3ace7950d Merge branch 'master' into blender2.8 2018-02-16 11:51:41 +01:00
8dfe9ef4e3 Fix bplayer (c) 2018-02-16 10:42:43 +01:00
451d5cef0f Fix part II of T53977: Severe problem with multiple instances of a library (save and reload).
Once 'losing lib' issue is fixed (in previous commit), we have new issue
that this could lead to several copies of the same linked data-block in
.blend file. Which is not good. At all.

So had to add a GHash-based check in libraries reading code to ensure we
only load a same ID from a same lib once.
2018-02-16 10:34:00 +01:00
8165234b46 Fix part I of T53977: Severe problem with multiple instances of a library (save and reload).
The issue was that when a same lib was found several times in loaded
.blend, we'd only keep the first occurence. But since Blender expects
next data-blocks to belong to last found library, we could actually
be adding data-blocks assigned to copies of the duplicated lib to
another, totally unrelated lib.

Those data-blocks were then obviously not found when actually loading
libs content, and lost.

Note that this only fix one part of the issue, current code can
generate several copies of same linked data-block now, will fix in
another commit.
2018-02-16 10:34:00 +01:00
fa0e89b9e8 Metalball drawing: rename mball helpers to handles
and also rename some related functions
2018-02-16 02:01:09 -02:00
3ba6ff6750 Cleanup: quiet warning 2018-02-16 09:14:25 +11:00
a24be95b0f GWN: Fix ubo debug printf 2018-02-15 19:16:08 +01:00
e401e2d89c GWN: Fix attrib arrays giving incorrect name depending on the platform.
It seems that some opengl implementations are returning "[0]" after array names but some others dont.

Remove the "[0]" so everything is consistent.
2018-02-15 19:16:08 +01:00
4438325ec9 Merge branch 'master' into blender2.8 2018-02-15 18:15:00 +01:00
e03f335b1d Code cleanup: simplify switch statement, ensure we catch missing enums. 2018-02-15 18:13:07 +01:00
b1ee10aa1b Fix T54073: crash and uninitialized memory in Cycles displacement hashing. 2018-02-15 18:00:55 +01:00
ad37ccbc32 Fix crash reading deg_point_cache_transform.blend test, saved with 2.8.
In general 2.8 files may not be readable in master, but might as well fix
this case so all the lib/tests can be opened still.
2018-02-15 18:00:55 +01:00
4fd3f8db9d Cleanup: Remove debug-only code 2018-02-15 17:57:51 +01:00
b879502da4 Fix T54076: MCE in Graph mode - clip.graph_select_border does not work by header menu
While the script should be using INVOKE_PREVIEW for operators in clip view,
window manager was lacking some switch statements.

Thanks Brecht fore review!
2018-02-15 16:58:56 +01:00
ca5fdd857b Merge branch 'master' into blender2.8 2018-02-16 01:17:43 +11:00
2aef87bfae Cleanup: rename BLI_thread.h API
- Use BLI_threadpool_ prefix for (deprecated)
  thread/listbase API.
- Use BLI_thread as prefix for other functions.

See P614 to apply instead of manually resolving conflicts.
2018-02-16 01:13:46 +11:00
df1c88b652 Merge branch 'master' into blender2.8 2018-02-15 14:15:55 +01:00
ccdacf1c9b Cleanup: use '_len' instead of '_size' w/ BLI API
- When returning the number of items in a collection use BLI_*_len()
- Keep _size() for size in bytes.
- Keep _count() for data structures that don't store length
  (hint this isn't a simple getter).

See P611 to apply instead of manually resolving conflicts.
2018-02-15 23:39:08 +11:00
4da6c49613 Cleanup: Style, braces with macros
See https://wiki.blender.org/index.php/Dev:Doc/Code_Style#Braces_with_Macros
2018-02-15 12:41:35 +01:00
c0bbc4abf5 Cleanup: Remove BLI_ prefix from listbase macro
This is kind of doesn't matter where macro itself is defined.

We should stick to the following:

- If some macro is actually more an inline function, follow regular
  function name conventions.
- If macro is a macro, type it in capitals. Use module prefix if that
  helps readability or it if helps avoiding accidents.
2018-02-15 12:38:21 +01:00
2589f55a55 Merge branch 'master' into blender2.8 2018-02-15 12:33:44 +01:00
6d4022f619 Simple hair children: Make twist affected by texture
This completes twist feature, which is now possible to also control by
texture. Since textures can not easily contain negative values as well,
same trick with 0.5 neutral as vertex groups is used.

All in all, this twist features allows to do following things.

Original hair:

{F2287535}

Hair with scientifically calculated twist value of 0.5:

{F2287540}

And we can also twist braids in opposite directions dependent on left/right
side:

{F2287548}
2018-02-15 12:24:48 +01:00
5ce6ca0536 Fix T54078: Adding subsurf prior to particle system breaks simple children vgroups and textures
cpa->num points to a face index on BASE mesh, but get_child_modifier_parameters()
expects index on a FINAL dm. So wrong index was used here.
2018-02-15 11:53:58 +01:00
67cec97387 Simple hair children: Make twist affected by vertex group
The idea is to give a control over direction of twist, and maybe amount of
twist as well. More concrete example: make braids on left and right side of
character head to be twisting opposite directions.

Now, tricky part: we need some negative values to flip direction, but weights
can not be negative. So we use same trick as displacement map and tangent normal
maps, where 0.5 is neutral, values below 0.5 are considered negative and values
above 0.5 are considered positive.
2018-02-15 11:53:58 +01:00
ffde74a878 Simple hair children: Initial implementation of twist control
It allows to have children hair to be twisted around parent curve, which is
quite an essential feature when creating hair braids.

There are currently two controls:

- Number of turns around parent children.
- Influence curve, which allows to modify "twistness" along the strand.
2018-02-15 11:53:58 +01:00
bb3efe6127 Blenlib: Assert when attempting to rotate point around vector and store result in the point
This isn't supported since there are subsequent reads to all point coordinates
after modification started.

Probably we need to create a temp copy of point, but that's like extra CPU
ticks.
2018-02-15 11:53:57 +01:00
ff82968a6c Particles: Wrap insane amount of arguments to child modifier evaluation
Use single structure. It seems we will need to pass more information soon,
so better to do it via the structure.
2018-02-15 11:53:57 +01:00
9d2a699a90 Avoid unnecessary sqrt calls 2018-02-15 21:38:24 +11:00
c1784824ff Fix crash when rendering particles with cycles
view_layer is NULL when the render engine is created, this gets passed
around and ends up in this code causing a crash. This should be reverted
after the render engine api is updated to set view_layer.
2018-02-15 03:26:59 -05:00
144a661152 Make particle edit draw mode a noop
Seems this was just a template, but that template painted everything
green. Not sure what this draw mode should do really.
2018-02-15 03:26:59 -05:00
c4a783bdf7 Fix lack of particles updates and disappearing particles
The conditionals in particle code are... some sort of madness... I'm not
even sure what the correct behavior should be from looking at it.

In this case the path cache generation was being skipped in edit mode.
2018-02-15 03:26:59 -05:00
5dba0b68f8 Tag update when using particle edit brushes 2018-02-15 03:26:59 -05:00
eb0d430b4d Fix crash with particle cut brush and other brushes
Why is bedit->data.context NULL?
2018-02-15 03:26:59 -05:00
7f38e59810 Start bringing back particle edit
Its kind of broken, but have to start somewhere
2018-02-15 03:26:59 -05:00
c98af0faaf Add versioning code to make particles with default size visible again
Due to changes in draw code particles from old files that may have had a
default draw size of 0 will not be visible. Old draw code would check
for this and adjust the size, however the unit for draw size has changed
from pixels to BU, and it no longer makes sense to have such checks.

This patch is to ensure particles from such files remain visible.
2018-02-15 03:26:59 -05:00
ca7f826c6f Merge branch 'master' into blender2.8 2018-02-15 18:05:02 +11:00
b8b8669b28 Cleanup: style, warning 2018-02-15 18:03:55 +11:00
58ba89b5be Fix T54075: Align Objects fails w/ empty mesh 2018-02-15 11:33:47 +11:00
70f1b8cc40 Cleanup: style 2018-02-15 11:13:54 +11:00
56fa48969e Fix T54072: Crash splitting edges 2018-02-15 11:05:37 +11:00
e6386ed286 Merge branch 'master' into blender2.8 2018-02-14 21:49:13 +01:00
b5fe00d1ac Cycles: restore Particle Info Index for now, keep it next to Random.
It seems to be useful still in cases where the particle are distributed in
a particular order or pattern, to colorize them along with that. This isn't
really well defined, but might as well avoid breaking backwards compatibility
for now.
2018-02-14 21:45:57 +01:00
2464dcef37 Eevee: Fix broken AO and Contact shadows on certain platform.
This was caused by ce0f70fbd6
2018-02-14 19:02:03 +01:00
0ef981f603 DRW: Refactor: Less feature duplication with Gwn.
This removes the need of custom attribs for instancing.
Instancing works fully with dynamic batches & Gwn_VertFormat now.

This is in prevision of the VAO manager patch.
2018-02-14 18:59:42 +01:00
629a874817 DRW: Add instance buffer manager.
This manager allows to distribute existing batches for instancing
attributes. This reduce the number of batches creation.
Querying a batch is done with a vertex format. This format should
be static so that it's pointer never changes (because we are using
this pointer as identifier [we don't want to check the full format
that would be too slow]).

This might make the original Instance Data manager useless but it's currently used by DRW_object_engine_data_ensure().
2018-02-14 18:59:42 +01:00
ab7e7a005b GWN: Add new dynamic type of batches and remove
Theses batches keeps their memory chuck allocated after transfer to be reused and updated very often.

NOTE: This commit break instancing in DRW. (it's fixed in the next commit)
2018-02-14 18:59:42 +01:00
1e9ef2a25e GWN: Add GWN_batch_draw_procedural
This allow to drawn large amounts of primitives without any memory footprint.
2018-02-14 18:59:42 +01:00
0f3bc636c8 GWN: Allow drawing instances without batch_instancing 2018-02-14 18:59:42 +01:00
01244df007 DRW: Refactor: Make use of the new Gawain long attrib support. 2018-02-14 18:59:42 +01:00
df86e9cab5 GWN: Extend support for multiple of 4 components in batches. 2018-02-14 18:59:42 +01:00
27a7174546 GWN: Fix style and line of code that does nothing! 2018-02-14 18:59:41 +01:00
a5afe13e1c GWN: Add support for 4x4 Matrices and instancing attributes.
Only support float matrices specifically for code simplicity.
2018-02-14 18:59:41 +01:00
3102bf2889 Merge branch 'master' into blender2.8 2018-02-14 15:16:50 +01:00
f6107af4cf Cycles: change Index output of Hair and Particle Info to Random, in 0..1 range.
These are used for randomization, so it's convenient if the index is already
hashed and consistent with the Object Info node.
2018-02-14 14:55:46 +01:00
618bc6c679 GPU: use alpha blend that works for drawing to transparent buffer.
It's unlikely to ever be intentional to square the source alpha, as happens
with glBlendFunc, so this changes the blending throughout the code.
2018-02-14 14:00:57 +01:00
7028a11db9 GPU: don't use multisample for entire window, only for offscreen 3D viewport.
Now that the new 3D viewport draws to a multisample offscreen buffer, there is
no good reason anymore to create an entire multisample window and pay the
performance/memory cost for other regions that don't need it.

GL_MULTISAMPLE now only gets enabled for offscreen buffers, so we don't need
to check for it throughout the UI code anymore.

Differential Revision: https://developer.blender.org/D3062
2018-02-14 14:00:48 +01:00
8049ad21b0 Fix incorrect RNA path to view_render settings. 2018-02-14 13:31:37 +01:00
3851033a06 Code cleanup: simplify subwindow code. 2018-02-14 12:31:13 +01:00
c8e661706f Particles: Avoid multiple function declarations in multiple places
This makes it really hard to spot errors when function signature changes.
2018-02-14 11:52:58 +01:00
8003059646 Particles: Cleanup, remove trailign whitespace 2018-02-14 11:46:33 +01:00
1c34825b4f Hair child: Use clamp function to clamp curve evaluation
Avoids redundant calls to the curve evaluation.
2018-02-14 11:42:09 +01:00
c09e4ae08a Math utils: Add clamping functions 2018-02-14 11:21:27 +01:00
a966852362 CMake: Expose Cycles devices support as CMake option
Handy to disable GPU based devices when it's needed to run Valgrind.
2018-02-14 10:32:32 +01:00
c341dd0585 CMake: Fix cimpilation error when CUDA dynload is disabled but toolkit is not installed 2018-02-14 10:20:26 +01:00
88bd994a37 Merge branch 'master' into blender2.8 2018-02-14 16:04:07 +11:00
b48815a9b7 Cleanup: use prefix for tests
Allows for running all `bmesh_*` or `object_*` tests.
2018-02-14 16:02:21 +11:00
769c9a2363 Object Mode: remove Scene.obedit
This means we can support having the same scene in different windows
with different edit-objects.
2018-02-14 08:49:20 +11:00
6e040b045a GPU: add offscreen buffer drawing utility functions. 2018-02-13 20:02:31 +01:00
e9b1163162 Code cleanup: stop using rectangle textures in window draw, simplify code. 2018-02-13 20:02:31 +01:00
afb213f876 Code cleanup: fix incorrect reading of GL scissor coordinates.
These are often the same as the viewport, but not always.
2018-02-13 20:02:31 +01:00
96a2807e73 Code cleanup: remove unneeded gla* 2D drawing functions. 2018-02-13 20:02:31 +01:00
ff2d1edcd4 Fix blenderplayer build. 2018-02-13 20:02:31 +01:00
b330804ff3 Merge branch 'master' into blender2.8 2018-02-14 01:06:41 +11:00
9fb1f9c5cd Add ED_object_editmode_exit_ex
Allow exiting editmode from non-active scene.
2018-02-14 00:39:39 +11:00
37f65e9dc4 Cycles: Implement index output for hair node
This is like the only way to add variety to hair which is created
using simple children. Used here for the hair.

Maybe not ideal, but the time will show.
2018-02-13 14:20:47 +01:00
9e2ec6c86a Fix T54064: Can't create new Cycles materials
Was caused by object mode removal
2018-02-13 07:03:12 -05:00
cd517c002f Object Mode: remove Scene.obedit for RNA 2018-02-13 21:06:51 +11:00
8234f24838 Object Mode: Loop over objects for ED_editors_exit
We could loop over active objects but this ensures don't miss any
and avoids complicated context checks.
2018-02-13 21:00:26 +11:00
c8597a465f Object Mode: remove Scene.obedit
Add ED_screen_window_find, BKE_workspace_edit_object
2018-02-13 20:55:12 +11:00
754d3a2fe6 Object Mode: remove Scene.obedit for 3D View 2018-02-13 19:44:21 +11:00
d8992192e5 Object Mode: pass edit-object to outliner drawing
Also add 'OBEDIT_FROM_EVAL_CTX' macro.
2018-02-13 18:45:35 +11:00
2c6d079a90 Object Mode: pass edit-object to UV API 2018-02-13 18:29:49 +11:00
dacc6d4b02 Object Mode: remove Scene.obedit in draw manager
Part of larger change to remove this variable entirely.
2018-02-13 18:15:47 +11:00
d640ce40aa (Nodes) Display image name if any in the Cycles Image and Environment Texture node title 2018-02-13 00:58:26 +01:00
fc99eed5be Fix random walk SSS issues with different base and subsurface color.
Burley SSS uses a bit of strange thing where the albedo and closure weight are
different, which makes the subsurface color act a bit like a subsurface radius
indirectly by the way the Burley SSS profile works.

This can't work for random walk SSS though, and it's not clear to me that this
is actually a good idea since it's really the subsurface radius that is supposed
to control this. For now I'll leave Burley SSS working the same to not break
backwards compatibility.
2018-02-12 21:08:59 +01:00
b37dff9239 Fix part of T53080: don't use current scene world for icon previews.
This can be very slow if it contains a big texture, and it's not
necessarily setup in a useful way anyway, and materials can be used
in multiple scenes.
2018-02-12 20:39:40 +01:00
37ce77ba06 Buildbot: Remove usage of deprecated chroot 2018-02-12 17:56:19 +01:00
ce8b5bd90d Add boolean regression test. 2018-02-12 07:23:50 -05:00
147c24aeeb Fix T54032: Adding torus test fails
rna_LayerObjects_active_object_update used wrong viewlayer.

Regression in 345c6298e9
2018-02-12 19:39:52 +11:00
bbb2fa14c8 Merge branch 'master' into blender2.8 2018-02-12 17:57:53 +11:00
657396be08 Error in last commit, disable cycles when not enabled
Would only disable when loading old preferences.
2018-02-12 17:56:14 +11:00
2c3d4f7e65 Merge branch 'master' into blender2.8 2018-02-12 17:39:58 +11:00
53431a560e Disable cycles when WITH_CYCLES=OFF 2018-02-12 17:37:39 +11:00
fc97e120f6 BKE_addon: new/free/ensure functions 2018-02-12 17:24:18 +11:00
0bf615fc24 GHOST: Optimize and simplify the creation of a GHOST_Context on Windows
Instead of cloning the window to create dummyHWNDs and dummyHDCs to avoid calling the SetPixelFormat more than once in the same window, use the original window and HDC and do not call the SetPixelFormat again.

In addition to avoiding a lot of unnecessary calls, it simplifies the code and makes it match the others OS
2018-02-10 00:32:13 -02:00
832f7a6648 Merge branch 'master' into blender2.8 2018-02-09 20:36:59 +01:00
Dalai Felinto
5216eaec1d Eevee: Film filter default to 1.5 instead of 1.0
Cycles already uses 1.5 as default. BI original 1.0 filter doesn't look good for
Eevee. The ideal scenario would be for both Cycles AND Eevee to use the same DNA
setting.

But for now it is nice to at least have Eevee renders to look better by default.

Note: This handles doversion for 2.7x files only. Files previously created in
2.8 need to be manually corrected.
2018-02-09 17:16:36 -02:00
a6968e87f1 Cycles: add random walk subsurface scattering to Principled BSDF.
Differential Revision: https://developer.blender.org/D3054
2018-02-09 19:58:42 +01:00
0df9b2c715 Cycles: random walk subsurface scattering.
It is basically brute force volume scattering within the mesh, but part
of the SSS code for faster performance. The main difference with actual
volume scattering is that we assume the boundaries are diffuse and that
all lighting is coming through this boundary from outside the volume.

This gives much more accurate results for thin features and low density.
Some challenges remain however:

* Significantly more noisy than BSSRDF. Adding Dwivedi sampling may help
  here, but it's unclear still how much it helps in real world cases.
* Due to this being a volumetric method, geometry like eyes or mouth can
  darken the skin on the outside. We may be able to reduce this effect,
  or users can compensate for it by reducing the scattering radius in
  such areas.
* Sharp corners are quite bright. This matches actual volume rendering
  and results in some other renderers, but maybe not so much real world
  objects.

Differential Revision: https://developer.blender.org/D3054
2018-02-09 19:58:33 +01:00
7978306cbb Merge branch 'master' into blender2.8 2018-02-09 17:24:23 +01:00
3ab5ef7b4f Fix (unreported) error on freeing timers which customdata pointer shall not be freed.
Looks like there was no way to avoid that so far, since
WM_event_add_timer_notifier can set mere int-in-pointer there, this can
cause issues. So added mere flags system to wmTimer to allow
controlling this.
2018-02-09 17:23:35 +01:00
7e3e542aab Merge branch 'master' into blender2.8 2018-02-09 16:26:05 +01:00
ea9099473a Fix (unreported) crash when duplicating a FileBrowser window in preview draw mode.
We did not clear preview or smoothscroll timers pointers in copy code...
2018-02-09 16:15:42 +01:00
be4ebb7fa6 Merge branch 'master' into blender2.8 2018-02-09 14:27:32 +01:00
97597ed600 Doc: attempt to document RNA's FunctionFlag.
Tired of searching through code to find which is what, and how to use it
in the C callback, everytime I need anot-so-common option...
2018-02-09 13:34:18 +01:00
908ee2e0f2 Paint Dirt: remove operator call from Python
Instead of calling an operator I just call `collection.new()`. Moving the
code into a separate function also simplifies it. In its new form there is
also no undefined behaviour when me.vertex_colors is non-empty but without
active layer.
2018-02-09 12:52:46 +01:00
5db950e860 Cleanup: use workspace for object_mode when possible 2018-02-09 22:14:39 +11:00
Dalai Felinto
25074be697 Fix collection syncing when creating new collections from the outliner
We were not passing a scene collection parent to the BKE_collection_add
function, which in turn made syncing not work.

Right now we:
* Explicitly pass the master collection in this case
* Fallback to the master collection in other cases

With unittest.
2018-02-09 09:05:27 -02:00
3c09077e3b Paint Dirt: some small fixes
- normalize → average the vector: the vector isn't normalized here, because
  it doesn't necessarily becomes unit length. Instead, the sum is converted
  to an average vector.
- angle is the acos()…: the dot product between the vertex normal and the
  average direction of the connected vertices is computed, and not the
  opposite.
- The initial `con` list was discarded immediately and replaced by a new
  list.
- File didn't end with a newline.
2018-02-09 10:35:03 +01:00
37e53ca5f3 Missed opencollada edit in recent changes 2018-02-09 20:25:32 +11:00
07ccb8b97c Fix crash with font on curve
Was a mistake from recent texspace changes.

Reported by Pablo here in the studio!
2018-02-09 10:14:08 +01:00
32287212f5 Cleanup: pass eval_ctx to sculpt_init_session
Matches vertex paint mode
2018-02-09 17:46:46 +11:00
9b9861578d Merge branch 'master' into blender2.8 2018-02-09 13:56:49 +11:00
8f9386596f CMake: include missing headers 2018-02-09 13:50:05 +11:00
8a6b83d27e Fix T53958: Sequencer zoom 1:1 fails 2018-02-09 13:39:47 +11:00
5e65791516 Fix T53347: Vertex paint crash
Vertex paint was still using sculpt mode brush (which can be NULL).
2018-02-09 12:00:26 +11:00
Dalai Felinto
518d59970d Fix blenderplayer (tm) 2018-02-08 17:44:25 -02:00
3b61d2bb68 Merge branch 'master' into blender2.8
Conflicts:
	intern/cycles/blender/addon/ui.py
2018-02-09 03:00:20 +09:00
859379ac48 Fix for missing "Use Freestyle" toggle in the Cycles "Layer" options panel.
Reviewed By: Brecht Van Lommel (brecht), Dalai Felinto (dfelinto)

Differential Revision: https://developer.blender.org/D3048
2018-02-09 02:48:21 +09:00
29d2ff7b31 Cycles: unify OSL BSSRDF closure into a single bssrdf() closure with method.
This is similar to the upstream unified microfacet() closure, and makes it
easier to extend in the future.
2018-02-08 16:56:11 +01:00
aabafece03 Code refactor: tweaks in SSS code to prepare for coming changes.
This also fixes a subtle bug in the split kernel branched path SSS, the
volume stack update can't be shared between multiple hit points.
2018-02-08 16:56:11 +01:00
28e2bc90dd Code refactor: remove unnecessary RNG offset in branched path code.
This is only needed for SSS which bounces to a different shading point.
2018-02-08 16:56:11 +01:00
8c8e53c12d Cycles tests: separate directory for sss tests. 2018-02-08 16:56:11 +01:00
d3248bb50b Disable fast adjust code. Add other end spec matching.
This fixes a few caess where new width adjustment code

was less than ideal.
2018-02-08 10:48:24 -05:00
74fa84f37f Remove redundant check for armature mode
Caller ensures pose-mode, this flag is only set while drawing.
2018-02-09 02:39:54 +11:00
be2bd5d722 Fix mixed weight-paint & pose mode 2018-02-09 02:34:32 +11:00
9278614115 Merge branch 'master' into blender2.8 2018-02-08 16:27:28 +01:00
e0597baed5 Remove Carve boolean
We've got quite comprehensive BMesh based implementation, which is way easier
for maintenance than abandoned Carve library.

After all the time BMesh implementation was working on the same level of
limitations about manifold meshes and touching edges than Carve. Is better
to focus on maintaining one boolean implementation now.

Reviewers: campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D3050
2018-02-08 15:37:44 +01:00
bdc708762c Merge branch 'master' into blender2.8 2018-02-08 15:14:22 +01:00
9dc7dca3a2 Depsgraph: Fix missing camera animation after visibility changes
Synchronize code in on_visible_update with depsgraph building.

Need to update all cameras, since they might be hooked up to marker.
2018-02-08 15:12:38 +01:00
c3e61cab8a Merge branch 'master' into blender2.8 2018-02-08 23:48:36 +11:00
f088c6b9f6 Mesh: concave quad support
Previously quads always split along first-third vertices.
This is still the default, to avoid flickering with animated deformation
however concave quads that would create two opposing triangles now use
second-fourth split.

Reported as T53999 although this issue has been known limitation
for a long time.
2018-02-08 23:38:17 +11:00
5f2b4002f4 Dopesheet: Synchronize selection on bones when selecting everything
This is also how box selection and mouse selection is working.

Requested by Hjalti, reviewed by Joshua. Thanks!
2018-02-08 12:36:39 +01:00
022a481789 Fix error in object-mode removal
Wasn't setting transform context
2018-02-08 21:58:45 +11:00
127d515f3d Merge branch 'master' into blender2.8 2018-02-08 21:43:37 +11:00
1ddd03b793 Fail gracefully when editmode data doesn't exist
Sync changes from 2.8
2018-02-08 21:36:16 +11:00
345c6298e9 Object Mode: move to workspace struct
- Read-only access can often use EvaluationContext.object_mode
- Write access to go to WorkSpace.object_mode.
- Some TODO's remain (marked as "TODO/OBMODE")
- Add-ons will need updating
  (context.active_object.mode -> context.workspace.object_mode)
- There will be small/medium issues that still need resolving
  this does work on a basic level though.

See D3037
2018-02-08 21:14:26 +11:00
Dalai Felinto
14a19fed78 Fixing builds for 2.8 - outliner typo 2018-02-08 08:03:35 -02:00
611712fcc8 Linux: Add appdata.xml file for packagers
D3025 by @januz
2018-02-08 15:59:16 +11:00
8fa19e1950 Fix: Data-Blocks view in Outliner no longer displayed property values, making it semi-useless
Partially revert efe1af3d11

The offending commit over-zealously removed the datablocks viewer case
as well, when only the condition needed to be modified.
2018-02-08 16:15:49 +13:00
42c99ee5f5 DRW: Fix crash caused by fixing the leak (badly).
Previous commit was af425f3f7a
2018-02-08 00:41:27 +01:00
44aaffc684 Merge branch 'master' into blender2.8 2018-02-07 22:27:08 +01:00
00d2dfa93a Forgot to return actual value in previous own commit.
Sorry about the noise...
2018-02-07 22:26:37 +01:00
b8d376174c Merge branch 'master' into blender2.8
Conflicts:
	source/blender/windowmanager/intern/wm_files_link.c
2018-02-07 22:19:11 +01:00
49745aa5ff Library linking code: proper early out in case there is nothing to link. 2018-02-07 22:09:44 +01:00
749caf4984 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/windowmanager/intern/wm_files_link.c
2018-02-07 21:54:52 +01:00
843271d0a5 Library reload code: add early out in case there is nothing to reload. 2018-02-07 21:52:38 +01:00
af425f3f7a DRW: Fix memory leak with dupli objects.
This was caused by dupli's ObjectEngineData that were not free.

This allocates the data using the instance data manager (no alloc/free between frames). Though the data should be treated as not persistent in this case.
2018-02-07 19:15:55 +01:00
8a2f93b2ab DRW: Opti: Use less bytes in DRWUniform. 2018-02-07 19:15:55 +01:00
25c8b5046f Clay: Small refactoring of matcap_colors and put ubos into sldata.
Ubos needed to be free correctly.
Also the matcap colors are statics and does not need to be uploaded each drawcall.
2018-02-07 19:15:55 +01:00
ade2aaba09 Merge branch 'master' into blender2.8 2018-02-07 17:17:24 +01:00
56f6938b5e Depsgraph: More fixes for shape keys
Made shape keys to work for meshes. Also added missing code for curves.

Curves and lattices will not have shape keys visible, since modifiers support
is still to be done for them.
2018-02-07 14:15:24 +01:00
84155ab21a Depsgraph: Fix crash with shape keys and lattices
Only crash is fixed, still need to do something about missing recalc
or something like that.
2018-02-07 12:26:30 +01:00
1dafe759ed Update CUEW to latest version
This brings separate initialization for libcuda and libnvrtc, which
fixes Cycles nvrtc compilation not working on build machines without
CUDA hardware available.

Differential Revision: https://developer.blender.org/D3045
2018-02-07 11:53:01 +01:00
5892efa883 Depsgraph: Fix crash when visible update is called after tagging for updates
It is possible to have non-NULL scene in graph which was never built yet,
this happens when ID is tagged for update for non-built graph.

Was causing crash opening deg_anim_pose_bones.

Reported by Mai in IRC, thanks!
2018-02-07 11:21:16 +01:00
60eef5c7ff Depsgraph: Fix node sockets as driver variables
Fixes empty not moving int deg_anim_material_driving_empty.

Reported by Mai in IRC, thanks!
2018-02-07 10:57:54 +01:00
da128c12b5 Fix error with Main.eval_ctx.object_mode being unset
This made vertex/weight/sculpt crash.

Add BKE_workspace_update_object_mode which sets the object mode from the
workspace.

We may want to re-visit exactly when this is set, for now call within
wm_event_do_refresh_wm_and_depsgraph.
2018-02-07 18:35:05 +11:00
17f5d7f3c5 Depsgraph: Add missing relationship between object transform and point cache reset
This fixes an issue where old cache data was used after an object has been moved.
Particles were coming from very wrong positions. Reproduction case is to move an
object while animation is running and then let the animation loop back and
play again.

Differential Revision: https://developer.blender.org/D3044
2018-02-07 01:18:04 -05:00
5b01e428a9 Move eval_ctx after object mode changes 2018-02-07 16:38:17 +11:00
e99094035c Merge branch 'master' into blender2.8 2018-02-07 15:59:16 +11:00
38d35603f2 Correct header guard in last commit 2018-02-07 15:52:34 +11:00
6981861fcf Cleanup: Python context access
Avoid access from bpy when it's already declared.
2018-02-07 15:47:54 +11:00
ce0f70fbd6 Eevee: Fix SSR & AO on Vega + Mesa.
Really strange bug. Maybe gl_FragDepth is broken on this implementation.
2018-02-07 05:44:05 +01:00
708ef19d88 GPU: Remove Mesa + Vega hack.
This is not needed anymore with linux 4.15 + Mesa 17.3.3.
2018-02-07 05:44:05 +01:00
17577c53c6 Merge branch 'master' into blender2.8 2018-02-07 11:19:01 +11:00
1e4b612d6a Cleanup: add _types.h suffix to DNA headers 2018-02-07 11:14:08 +11:00
Dalai Felinto
77b61b554c Outliner: Add object(s) to new collection
Suggested by Pablo Vazquez (venomgfx).

The idea here is that it should be easy to work in the outliner by picking a
bunch of objects and adding them to a new collection.
Where is the new collection? In the same level as the "outliner active" object.

Note, since the outliner has no pure concept of an active object, I'm using
the highlight tag for this. Hopefully it works fine.

It should work in "Collections", "View Layer", and "Groups".
Only when collections are not filtered out.
2018-02-06 18:39:14 -02:00
Dalai Felinto
107486e673 Fix poll for OUTLINER_OT_object_remove_from_collection
Outliner groups mode support no filtering.
2018-02-06 18:37:37 -02:00
Dalai Felinto
fcb430afba Rename OUTLINER_OT_collection_object_remove > _object_remove_from_collection
Better make it clear it is different than OUTLINER_OT_collection_objects_remove.
2018-02-06 13:28:37 -02:00
Dalai Felinto
9631c1ac1a Outliner: Operator to delete outliner selected elements from collection
Suggested by Pablo Vazquez (venomgfx).
2018-02-06 13:19:58 -02:00
Dalai Felinto
5633bab2d0 Fix crash when no active object
To reproduce the crash: delete the active object of the scene.

This bug was introduced on e9c40b7339.
2018-02-06 13:19:12 -02:00
66521b382b Depsgraph: Correction to previous particle fix
The reason it appeared working was due to left-over debug code to force
time dependency.

Real fix seems to include force tagging objects used by duplication,
similar to what we do for some other modifiers already.
2018-02-06 14:51:02 +01:00
1ae5dfd049 Fix T54005: Broken IDProp copying from RNA code.
When destination IDProp did not exist, new code (related ot static
overrides) would not do nothing...

IDProps and RNA are really not easy to tame, thinking more and more we
should totally bypass RNA and directly use (add) IDP code to handle
comparison and diff creation/application of IDProps.

But for now, this bandage should to the trick.
2018-02-06 14:39:39 +01:00
0eb9d2adc6 Merge branch 'master' into blender2.8 2018-02-06 23:36:12 +11:00
f9f64ca4a3 Use eObjectMode for function arguments 2018-02-06 23:34:58 +11:00
885d78150d Use eObjectMode for function arguments 2018-02-06 23:27:49 +11:00
5376c739f5 Merge branch 'master' into blender2.8 2018-02-06 23:06:23 +11:00
486e2547ee DNA: move eObjectMode into own header
Add a enum headers to DNA, to be included in other headers
so function signatures can use enums for better type safety.

Add DNA_*_enums.h matching DNA_*.types.h as needed.
2018-02-06 22:58:13 +11:00
98dcd33238 Fix Collada building after changes in API.
Seriously guys... *Full* build when you change APIs!
2018-02-06 12:11:00 +01:00
f9deea57d9 Fix bplayer (c) 2018-02-06 12:10:41 +01:00
ce0cb4de8d Object Mode: use eval_ctx for modifiers_isCorrectableDeformed
Some other minor changes from D3037 as well
2018-02-06 19:35:06 +11:00
f9da89a38d Partially revert changes from 2a184f3d2b
Ended up removing the need for eval_ctx,
but left it being initialized.
2018-02-06 19:17:28 +11:00
74f7fb084c Object Mode: use eval_ctx for get_active_constraints 2018-02-06 18:03:29 +11:00
fa588e9ef4 Object Mode: pass eval_ctx to ED_object_iter_other 2018-02-06 18:03:29 +11:00
2a184f3d2b Object Mode: use eval_ctx for paint & object 2018-02-06 18:03:29 +11:00
906ed54d28 Object Mode: ED_mesh_mirrtopo_* check edit-mode data
Replace object mode checks for edit-mode data
2018-02-06 18:03:29 +11:00
e9c40b7339 Object Mode: pass as arg to stats_string 2018-02-06 18:03:29 +11:00
5ec016169b Object Mode: use eval_ctx for context/screen code 2018-02-06 18:03:28 +11:00
269ed0a770 Object Mode: pass eval_ctx in outliner functions 2018-02-06 18:03:28 +11:00
021bf4c2fe Object Mode: use eval_ctx for keyframe & weight calculation 2018-02-06 18:03:28 +11:00
c7fecab2ef Object Mode: Use eval_ctx mode for drawing, paint & modifiers 2018-02-06 18:03:28 +11:00
ef11113399 Object Mode: use eval_ctx mode in transform code
This adds EvaluationContext into TransInfo
2018-02-06 18:03:28 +11:00
91db372b48 Object Mode: pass object mode to CTX_data_mode_enum_ex 2018-02-06 18:03:28 +11:00
28dfc47cf0 Object Mode: Add to EvaluationContext & DRWContextState 2018-02-06 18:03:28 +11:00
1c600cc643 Object Mode: use obdata when loading from editmode
Avoids having to check the objects mode in 'update_from_editmode'.
2018-02-06 18:03:28 +11:00
7b0cb7e00d Object Mode: don't check posemode in the BGE
No reason pose mode should change behavior
2018-02-06 18:03:28 +11:00
a3409d3f53 Fix T54003: Particles - Size and random size not present in "physics" tab in Advanced mode
The check to see if `use_advanced_hair` was enabled was actually in two places
(render panel `draw` function and physics panel `poll` function). As these
properties are only in one place now the check in `draw` isn't needed anymore.

Related: T53513, a6c69ca57f
2018-02-05 20:25:08 -05:00
78c6684ee9 Freestyle: Unnecessary repeats of Cycles property copying.
As a follow-up to the commit rB354f92a49458795c69f857de927c5b1531cd3618
for fixing Freestyle crash when using Cycles (thanks Brecht for the fix), this revision
applies a related bugfix addressed partly in D3040 (item #2 in the description).
2018-02-06 09:11:59 +09:00
9810f4a11c Freestyle: Additional debug info for the render engine used for stroke rendering. 2018-02-06 08:53:59 +09:00
ce3e0afe59 Fix T54001: AMD OpenCL fails with certain resolutions, after recent changes.
We should actually be using CL_DEVICE_MEM_BASE_ADDR_ALIGN for sub buffers,
previous change in this code was incorrect. Renamed the function now to
make the specific purpose of this alignment clear, it's not required for
data types in general.
2018-02-05 22:19:49 +01:00
Dalai Felinto
e75c04898f Fix duplicator visibility logic
Cycles old behaviour is to hide the duplicator on rendering at all times.

We have since a few months an option in 2.8 to control the duplicator
visibility on its own. However when the duplicator is also duplicated, things
were not working properly.

What we do now is, in addition to the duplicator visibility control, is to not
have the source collection of the duplicator object to ever influence its
visibility when the object is been duplicated.

So if the user wants to reproduce Cycles old behaviour all that is required is
to have different collections, one for the original to-be duplicated objects
that you hide in for the view layer used in the final render. And another
collection with only the first duplicator (which in turn duplicates other
duplicators).

I know this all may sound confusing, so please just give it a try, it's simpler
than it sounds.
2018-02-05 19:01:27 -02:00
bd9ed0228b Fix bevel profile=1 problems, see T39132, T38458, T40278, T51010,
T53783.

Before, profile=1 ("square outside") only worked well in a few cases
(some "pipes", cube corners). This makes it work well pretty much
everywhere.
2018-02-05 14:21:43 -05:00
354f92a494 Fix Freestyle not copying Cycles properties to stroke rendering scene. 2018-02-05 18:57:26 +01:00
a8a77609d3 Fix Cycles + Freestyle rendering crash, due to bug in RNA override code. 2018-02-05 15:08:04 +01:00
Nathan Letwory
f9fcda533b Fix typo in struct name obejct to object.
Reviewers: sergey

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D3041
2018-02-05 11:31:33 +02:00
a1c45a453f Merge branch 'master' into blender2.8 2018-02-05 17:58:31 +11:00
f911fb0744 Minor change to last commit
Keep mode checks simple, nest other checks in their body.
2018-02-05 17:56:09 +11:00
ceb645bc56 Fix T53986: Crash saving during sculpt stroke
Also remove unused struct member.
2018-02-05 17:54:13 +11:00
23d2f708f3 Eevee: Pixel Filter: Add parameter & rescale final LUT. 2018-02-05 01:59:14 +01:00
cc1e88b37a Eevee: AA: Add Blackmann-Harris pixel filter distribution.
This leads to a huge improvement of AntiAliasing quality.
There is no other distribution now and there is not settings displayed to the user. That's for another commit.
2018-02-05 01:59:14 +01:00
08112c2acf Eevee: Style: More Const correctness. 2018-02-05 01:59:14 +01:00
143b0ab52a Eevee: Render: Reset winmat before jittering it again. 2018-02-05 01:59:14 +01:00
c8e87edccb Eevee: Render: Fix Ao pass background contamination.
It was poluted by the additive blend mode.
2018-02-05 01:59:14 +01:00
f61bcc70e1 Eevee: Render Fix black normals on blended material in the normal pass. 2018-02-05 01:59:14 +01:00
956a7bc3ea Eevee: Render: Force normal buffer creation if needed. 2018-02-05 01:59:14 +01:00
e1d5d55b56 Eevee: Codestyle: Indent #ifdefs 2018-02-05 01:59:14 +01:00
07e1212e34 Eevee: Render: Fix black reflections in 1st sample. 2018-02-05 01:59:14 +01:00
e84e8cb497 cycles: fix black render with cycles_cubin_cc.
I have honestly no idea how this got swapped..
2018-02-04 15:12:35 -07:00
f8236e4869 cycles: fix cxx11 usage for cycles_cubin_cc 2018-02-04 15:11:08 -07:00
eeb621566a Merge branch 'master' into blender2.8 2018-02-04 10:46:34 +11:00
36c1122b96 msvc: Use source folder structure for project file.
This patch changes the huge list of projects in visual studio into a nice tree matching the source folder structure. see D2823 for details.

Differential Revision: http://developer.blender.org/D2823
2018-02-03 16:38:27 -07:00
a5052770b8 cycles: Add an nvrtc based cubin cli compiler.
nvcc is very picky regarding compiler versions, severely limiting the compiler we can use, this commit adds a nvrtc based compiler that'll allow us to build the cubins even if the host compiler is unsupported. for details see D2913.

Differential Revision: http://developer.blender.org/D2913
2018-02-03 10:59:09 -07:00
1bc0cd0071 Merge branch 'master' into blender2.8 2018-02-03 16:10:01 +01:00
db989e1f11 Fix more Cycles incorrect principled BSDF mixing due to missing initialization.
Spotted by Ha Hyung-jin, thanks!
2018-02-03 13:43:44 +01:00
7ea7ce970c Fix build error with CUDA 9.1 and compute capability 2.x. 2018-02-03 13:36:38 +01:00
bb6f1d159a Cycles: make displacement a supported feature.
Adaptive subdivision remains experimental, still needs more work.
2018-02-03 12:20:58 +01:00
f9ea097a87 Cycles: add Vector Displacement node and extend Displacement node.
This adds midlevel and object/world space for displacement, and a
vector displacement node with tangent/object/world space, midlevel
and scale.

Note that tangent space vector displacement still is not exactly
compatible with maps created by other software, this will require
changes to the tangent computation.

Differential Revision: https://developer.blender.org/D1734
2018-02-03 12:20:26 +01:00
065a84c8d0 Eevee: Fix crash when using Ogl render and subsurface. 2018-02-03 02:19:10 +01:00
226685d3a0 Eevee: Render: Fix hashed-alpha testing. 2018-02-03 02:19:10 +01:00
4820c7400f Eevee: Render: Make sure all probes are refreshed before rendering. 2018-02-03 02:19:10 +01:00
e530d0ccaa Eevee: Perf: Put transparent sorting before the render loop. 2018-02-03 02:19:10 +01:00
36b259fa88 Eevee: Render: Add ambient occlusion pass support. 2018-02-03 02:19:10 +01:00
39706a0a3d Eevee: Subsurface: Release separate albedo texture if not used. 2018-02-03 02:19:10 +01:00
269d9eb54c Eevee: Render: Fix emission shader normal output 2018-02-03 02:19:10 +01:00
Dalai Felinto
217bc17a3c Fix draw manager F12 evaluation mode
This effectively allows for ob duplicator_render/viewport to work properly
when doing final renders.
2018-02-02 18:03:04 -02:00
dcea87b58e fix: rBc4a19e988bb4 error stepped in by a merge from mmaster 2018-02-02 17:30:54 +01:00
Dalai Felinto
c7c070c2ec Collections: Operator to duplicate a collection
When duplicating a layer collection directly linked to the view layer we copy
the collection and link it.

For all the not directly linked layer collectionns, we try to sync the layer
collection flags, overrides, ...

Also we make sure the new collection is right after the original collection.

We also expose this in RNA, via collection.duplicate().
2018-02-02 12:25:05 -02:00
Dalai Felinto
a4d2b102f3 Collections: Operator to select collection objects
This is only supported by layer collections (the ones accessible
in the outliner when you see "View Layer").
2018-02-02 12:25:05 -02:00
26dff781b3 Merge branch 'master' into blender2.8 2018-02-02 12:21:24 +01:00
37beac8eb8 Fix missing group duplicated by hair in render
Was happening when viewport visibility on the particle system is disabled.
This became an issue after c45afcf, but the actual issue goes a bit deeper
and the following aspects were involved:

- Relations builder for particle system was ignoring particle system if
  it's visibility is not enabled for viewport. This is something what
  shouldn't have been done -- depsgraph relations are supposed to be the
  same no matter if it's viewport or render.

- Relation builder was only dealing with duplication set to object, but
  was ignoring group duplication.

This is technically a regression in 2.79a-RC as well, so would need to
backport this fix to the branch after extra testing is done here in the
studio.
2018-02-02 12:05:11 +01:00
c4a19e988b fix: silence warnings about unused local variable (thanks to dfelinto for the hint) 2018-02-02 11:57:10 +01:00
fe82a09f89 Fix T53980: IK influencing REST POSE with New Depsgraph 2018-02-02 10:37:06 +01:00
c3eb22e2ab Merge branch 'master' into blender2.8 2018-02-02 14:15:29 +11:00
88e69806b9 Cleanup: wrap function args 2018-02-02 14:11:14 +11:00
b2dc0e6970 Fix T53978: Bad memory access after recent fix to BSDF mixing
Added proper checks after BSDF allocation and cleaned up existing
inline checks.

Was introduced in 7261d675e6
2018-02-01 20:03:29 -05:00
7003c8a143 Eevee: Render: Fix volume sampling. 2018-02-02 01:18:25 +01:00
263083c7e6 Eevee: Render: Make sure background does not write to ssr data. 2018-02-02 00:50:18 +01:00
78a77fe622 fix: unintentionally commented out collada animation export 2018-02-02 00:49:42 +01:00
9173a6f519 Eevee: Render: Fix NaNs in Normal pass. 2018-02-02 00:48:33 +01:00
44c4d62092 Eevee: Render: Make render passes appear in compositor. 2018-02-01 21:38:16 +01:00
7049bcf76e Eevee: Render: Fix broken "non-multiview" render. 2018-02-01 21:08:05 +01:00
00f1bc1685 Eevee: Render: Add support for multiview. 2018-02-01 20:48:30 +01:00
ab5f86a04e Eevee: Render: Add Transparent Background option.
... under a new "Film" tab in the render properties panel.
2018-02-01 20:48:30 +01:00
e52c5bcdb5 Eevee: Add mist pass support.
Eevee: Render: Fix crash when not enabling mist pass.
2018-02-01 20:47:56 +01:00
12bd214b9a World: Use enum for mist falloff parameter. 2018-02-01 18:09:17 +01:00
d57741d91f Eevee: Simplify/Fix view_vecs calculation.
Now view_vecs[0][2] ALWAYS contains Near clip plane and view_vecs[1][2] = far - near.
2018-02-01 18:09:17 +01:00
c95f3a3616 Eevee: Render: Fix Normals of refraction shader. 2018-02-01 18:09:17 +01:00
253b412ace Eevee: Render: Add Subsurface Pass support. 2018-02-01 18:09:17 +01:00
7884ae6eb2 Fix T53686: VSE Render crash when zooming timeline
This is rather a workaround to avoid main thread freeing all glyph caches
at the same time as sequencer uses fonts to draw text sequences.

Ideally we need to either make cache more local, or user-counted or to make
somewhat more global locks. All this ends up in a bigger refactor which is
better for 2.8. For the meantime let's make Blender more stable with a tiny
workaround.

Downside is that keeping zooming things up and down in interface during render
will increase memory usage by unused glyph caches. It's not too bad though,
all unused caches will be freed first time at area zoom after render.

Thanks Bastien for review!
2018-02-01 16:34:30 +01:00
1a840c3e27 Fix T53951: Copy ms runtime dlls using InstallRequiredSystemLibraries.cmake
Differential Revision: https://developer.blender.org/D3032
2018-02-01 08:26:14 -07:00
Dalai Felinto
a57063a432 Merge remote-tracking branch 'origin/master' into blender2.8 2018-02-01 13:13:44 -02:00
7e928c3bbc Fix: msvc build error with bli_fileops.h
bli_fileops.h was using uint64_t without including the proper header.

issue triggered by rBb0af44fa4d7a2e134b315c49a4fbdf573f781004
2018-02-01 07:59:52 -07:00
0bf54dd66b Fix T53686: VSE Render crash when zooming timeline.
Epic fail from recent 'security' fixes (rBe04d7c49dca9). ;)

To be backported to 2.79a!
2018-02-01 15:55:38 +01:00
ff54dbd8fa Cycles: Attempt to fix 32 bit linux compilation 2018-02-01 15:13:54 +01:00
7bd86d74ba Cycles: Fix for non-vectorized version of bitscan()
It was doing bit search in an opposite direction comparing to a
vectorized version.
2018-02-01 15:11:17 +01:00
b8bb15f744 Finalize/enable new static override for linked groups.
Behavior is expected to be simillar to 'make proxy' on linked groups, it
basically allows you to select which object in the group will be to
'root' override (usually, the armature), checks which other objects
needs to be overridden as well, overrides the group itself too, and
instantiates the group and the root overridden object.

It seems to be working, though handling of armature deformation is kind
of totally broken in blender2.8 currently (modifiers...). ;)
2018-02-01 14:08:18 +01:00
73b4cb5c89 Fix some issues in new RNA diff code. 2018-02-01 14:07:51 +01:00
Dalai Felinto
781dd5edb5 Fix audaspace mess in 2.8
All these files were removed since accidental commit, revert and merge in 2.8.

ea31f0ac3b + 0a4e170c28 + 11f9a23a28 + 7b27b10fa6
2018-02-01 09:22:57 -02:00
cd317fab65 Fix wrong attempt to get depsgraph from RNA Groups ViewLayer. 2018-02-01 12:10:10 +01:00
1ce8a7f3d0 Fix incorrect message bus tag count 2018-02-01 15:56:36 +11:00
70841e58c4 Merge branch 'master' into blender2.8 2018-02-01 15:18:58 +11:00
653746f5f8 Cleanup: pass userdef to write_userdef, const args 2018-02-01 15:16:36 +11:00
4174524cb0 Error in last commit 2018-02-01 15:15:57 +11:00
6ffc6b30aa Merge branch 'master' into blender2.8 2018-02-01 14:59:14 +11:00
4d96202c9e Cleanup: Python code-style 2018-02-01 14:58:05 +11:00
e4c9cf7088 Merge branch 'master' into blender2.8 2018-02-01 14:02:33 +11:00
10fec1f153 Cleanup: Python code-style (addons, wm) 2018-02-01 13:58:44 +11:00
078e012cd9 Cleanup: rename BLI_*_empty() -> clear()
Consistent with other BLI API's
2018-02-01 13:40:53 +11:00
7b27b10fa6 Merge branch 'master' into blender2.8 2018-01-31 22:36:16 -02:00
0a4e170c28 Revert "tmp"
This reverts commit ea31f0ac3b.
2018-01-31 22:35:46 -02:00
11f9a23a28 Merge branch 'master' into blender2.8 2018-01-31 22:34:29 -02:00
42ca1fe89c gpu_shader_material: Correct incorrect glsl texture of Voronoi, Noise, and Musgrave on some Intel GPUs 2018-01-31 22:31:08 -02:00
ea31f0ac3b tmp 2018-01-31 22:11:01 -02:00
4bd72586aa Merge branch 'master' into blender2.8
Apply Fix T50198 also in blender2.8
2018-02-01 00:43:01 +01:00
22faf66c8b fix T50198: The OpenCollada error handler must return true after detecting uncritical errors. 2018-02-01 00:41:39 +01:00
4b5ac3b768 Merge branch 'master' into blender2.8 2018-01-31 17:17:43 +01:00
9d39980cfd I18n disambiguation: IRIS is both a file format and a VSE wipe effect...
At some point, we could probably think about removing IRIS file format
support, don't think there are much of those around anymore. But for
now, let's add a translation context to wipe effect. :)

Reported in T43295 by @blend-it, thanks.
2018-01-31 16:43:04 +01:00
6a6f7547e3 DRW: Finish 85d3de94c6 2018-01-31 15:00:39 +01:00
616182ea44 Eevee: SSS: Fix SSS perturbating SSR normals. 2018-01-31 14:41:26 +01:00
458dd4100f Merge branch 'master' into blender2.8 2018-01-31 14:24:38 +01:00
483b981d63 Outliner: Fix crash when invoking operators of a collection or group
The crash occurred when trying to see a tooltip or activate any of the operator's tools with the cursor outside the outliner area.
2018-01-31 11:07:25 -02:00
f309becf2d Fix possible concurency issue in mesh normals computation.
Failure in own code from last December, thanks @sergey for finding it.

To be backported to 2.79a.
2018-01-31 12:30:39 +01:00
6d55b522fe Merge branch 'master' into blender2.8 2018-01-31 19:03:45 +11:00
87608e66e1 WM: correct comment, variable name for addons 2018-01-31 19:02:43 +11:00
afaca68ea8 Eevee: Render: Fix crash when using a sun lamps with shadow. 2018-01-31 02:53:03 +01:00
55a238edd6 Eevee: Render: Add Normal pass output. 2018-01-31 02:53:02 +01:00
76135d6b72 Eevee: Fix indentation and fix output normal of emission shader. 2018-01-31 02:53:02 +01:00
251fd91064 Eevee: Fix Crash when rendering using Render Border. 2018-01-31 02:53:02 +01:00
85d3de94c6 Eevee: Fix crash when Rendering (F12) using camera mapping. 2018-01-31 02:53:02 +01:00
4801e3fd92 Eevee: Display compositing tab. 2018-01-31 02:53:02 +01:00
807713e4f2 UI: re-enable alt-key for editing selection
Fixes T53950 where changing node layers applies to all selected nodes.
2018-01-31 11:54:04 +11:00
Dalai Felinto
d8059a5f11 Make layers unittest pass after filter cleanup
Update your svn lib.

Unittests broken since 7628961391.
2018-01-30 19:06:23 -02:00
Dalai Felinto
133afc07b2 Compositor / Render Layer Node: Fix wrong layer after deleting view layers
I was calling the ntree syncing function too late. So the index of the layer
was -1 since it was no longer in the ListBase, making all RenderLayer nodes
to decrease their respective `custom1` (even going to negative sometimes).
2018-01-30 18:31:38 -02:00
7b675e0dc4 Fix blender player (tm) 2018-01-30 16:36:15 -02:00
97d225ed6f Fix Cycles incorrect principled BSDF mixing with some parameter variatons.
Spotted by Ha Hyung-jin, thanks!
2018-01-30 16:36:15 -02:00
7a868d127f Fix blender player (tm) 2018-01-30 16:11:58 +01:00
Dalai Felinto
dbed11d272 Fix FOREACH_OBJECT_RENDERABLE using stack data
Since 30a966a726 when I removed the recursion, the code was still relying
on stack data. This would crash in release often, and it should crash always.

Big thanks to Sergey Sharybin for spotting the issue.
2018-01-30 13:07:08 -02:00
7261d675e6 Fix Cycles incorrect principled BSDF mixing with some parameter variatons.
Spotted by Ha Hyung-jin, thanks!
2018-01-30 15:05:47 +01:00
0d64857c3f Merge branch 'master' into blender2.8 2018-01-30 14:32:27 +01:00
Dalai Felinto
b5cbc8bb60 Fix FOREACH_OBJECT_RENDERABLE going over the same object twice
Which is really silly because we were already tagging the ids, but simply
never checking them back.
2018-01-30 11:27:12 -02:00
b3c4a2a8da Fix T52520: Metaballs in edit mode causes infinite Cycles viewport reset
The issue was introduced by eb016eb as a fix for T41258, which added depsgraph
tagging with zero flag. The comment was saying that it's to make derived caches
to be updated, however bot sure how that could possibly work: tagging ID for
update with 0 flag only sets updated tags in bmain in old dependency graph.

In the new depsgraph, where object data is a part of depsgraph, doing such a
tag forces object to be updated, which re-triggers viewport rendering, which
is causing such an infinite viewport render rest.

Can not reproduce any crashes here, so maybe it's fine to move on with this
change.
2018-01-30 14:20:23 +01:00
Dalai Felinto
30a966a726 Fix FOREACH_OBJECT_RENDERABLE recursion going over the roof
This was leading to so much recursion that it was failing here.
How to test it: Open wanderer.blend and try to render (F12).

Note: This won't fix F12 rendering for wanderer with Eevee. Something else is
going wrong there.
2018-01-30 10:53:09 -02:00
c80b1f5410 Cleanup: warning, spelling 2018-01-30 21:02:27 +11:00
d0f63d402d Fix T53943: Weight paint crash in new scene 2018-01-30 20:33:20 +11:00
b0af44fa4d Fix T50630: Fluid fails on win32 w/ unicode paths
Allow overriding gzip open w/ elbeem.
2018-01-30 14:31:04 +11:00
e83cbf4610 Fix crash drawing light probe 2018-01-30 13:36:41 +11:00
58c92f9f0d Fix light probe callbacks
Even though this wasn't crashing here, the arg types were wrong.
2018-01-30 13:15:04 +11:00
3e8c96ae46 DRW / Render: Make render result show when using final render with eevee. 2018-01-29 22:27:22 +01:00
1fe2b4bf60 Eevee: Remove unused variable. 2018-01-29 22:00:15 +01:00
376d42304b Eevee: Add Z pass render result. 2018-01-29 22:00:15 +01:00
0f93d67617 Eevee: Display render button in render panel 2018-01-29 22:00:15 +01:00
f107af3519 Eevee: Add support for TAA/SuperSampling for final render. 2018-01-29 22:00:15 +01:00
8cce339131 Eevee: Add new "render samples" properties. 2018-01-29 22:00:15 +01:00
ba9a4dedda Eevee: Initial Final Render support.
TAA / multiple samples is not working at the moment.
2018-01-29 22:00:15 +01:00
847613c34e Render: Abort operator if there is no render_to_image() function 2018-01-29 22:00:15 +01:00
b6dbd8723c DRW / Render: Add support for render pipeline in drawmanager.
For simplicity we choose to execute the rendering of Opengl engines in the main thread and block the interface.
This might be addressed in the future at least for video rendering.

A drawmanager wrapper (DRW_render_to_image) is called by the render pipeline to set up the Opengl state and then call the specific draw_engine->render_to_image function.
2018-01-29 22:00:15 +01:00
01a62515cb DRW: Add "hardcoded" stipples for sun ray display. 2018-01-29 22:00:15 +01:00
Dalai Felinto
0f35436bcf Outliner: Moving object context menu to Python, and adding hierarchy
As suggested by Pablo Vazquez, though I think we can refine it a bit with icons.
I will wait for his feedback on it.
2018-01-29 18:01:57 -02:00
38bc973a6c uvedit_draw: Ensure first if it has any UV to draw
Otherwise an assert could be launched
2018-01-29 16:56:52 -02:00
d072022bbf Deduplicate GLSL frag code in particle drawing
Differential Revision: D2993
2018-01-29 15:51:23 -02:00
9577ebde79 Fix T53598: OpenGL Render Animation does not update shadows
General idea of the fix: skip the whole draw manager callback madness which
was used to tag object's engine specific data as dirty. Use generic recalc
flag in ObjectEngineData structure instead. This gives us the following
benefits;

- Sovles mentioned bug report.
- Avoids whole interface lookup for opened viewports for EVERY changed ID.
- Fixes missing updates when viewport is temporarily invisible.

Reviewers: dfelinto, fclem

Differential Revision: https://developer.blender.org/D3028
2018-01-29 17:54:20 +01:00
006c66b1ff Refactor object engine data storage
Main idea is to make specific engine types be a subclass of generic
ObjectEngineData structure.

This required following changes:

- Have extra size argument to engine data allocation function.

  Not sure whether there is less error-prone way of doing this.

- Add init() callback to engine data allocation function.

Additionally, added some extra checks to Eevee's engine data getters, so we do
not silently cast lamp data to lightprobe data.

Reviewers: dfelinto, fclem

Differential Revision: https://developer.blender.org/D3027
2018-01-29 17:53:51 +01:00
1eeb846e78 Fix Cycles viewport render not updating when tweaking displacement shader.
This was disabled to avoid updating the geometry every time when the
material includes displacement, because there was no way to distinguish
between surface shader and displacement updates.

As a solution, we now compute an MD5 hash of the nodes linked to the
displacement socket, and only update the mesh if that changes.

Differential Revision: https://developer.blender.org/D3018
2018-01-29 17:07:08 +01:00
fb941679bb Fix Cycles allocating too much device memory, after recent memory refactoring.
Spotted by Ha Hyung-jin, thanks!
2018-01-29 17:07:08 +01:00
282b3d0fcd Revert "Fix T53914: Volumetric scattering now goes correctly through transparent surfaces."
This reverts commit 3c852ba074. This is breaking
the regression tests, and maybe requires some deeper changes to really fix.
2018-01-29 17:07:08 +01:00
cebc7bb198 Fix nan problem in previous bevel commit.
For chains, access to g_prod[0] was undefined.
And two minor style (whitespace) changes.
2018-01-29 10:01:19 -05:00
263efb0b9a Depsgraph: Correction for previous fix
Original fix only worked when there is one custom property.
2018-01-29 15:06:44 +01:00
Dalai Felinto
d174f3bd60 Outliner: Remove Toggle options from object RMB
Task suggested by Pablo Vazquez (venomgfx).
2018-01-29 12:05:04 -02:00
68c1e3c28d Depsgraph: Fix missing update when property from proxy rig drives something 2018-01-29 14:53:27 +01:00
6eb2b57f5a Depsgraph: Disable labels on relations
This code was disable a while back and got re-enabled by some previous debug
process. Having relation names in dot file helps understanding what's going
on in one cases, but makes things spread too far away in others.
2018-01-29 14:45:45 +01:00
70286a7652 Depsgraph: Cleanup, line wraps 2018-01-29 14:43:12 +01:00
083f6af8f8 Fix more filebrowser not refreshing correctly after new message bus system.
This does not affect current blender2.8, but is mandatory for asset
engine branch.

Bottom line being, we also need to 'survey' changes in actual
SpaceFileBrowser struct, not only its FileSelectParams sub-struct.
2018-01-29 12:50:15 +01:00
c501855eb6 Fix filebrowser not refreshing correctly after new message bus system.
Generic ED_area_do_msg_notify_tag_refresh callback only tags area for
refresh, not redraw. This was not updating view e.g. when changing
ordering options in top region, until you'd mouse-over main filelisting
region...

So now, always tag area for redraw in filbrowser's refresh callback.
2018-01-29 10:24:30 +01:00
be0b2ac18b Manipulator: ignore mouse location w/ view widgets
When pressing on a button to zoom for eg,
using zoom-to-mouse-position doesn't make any sense.

There is also zoom speed scaling which increases the closer the cursor
is to the top-edge of the screen, which was noticable since the
navigation widget is currently at the top of the screen.
2018-01-29 17:40:19 +11:00
da885b922c Merge branch 'master' into blender2.8 2018-01-29 17:32:20 +11:00
45fdea48c1 Fix T53614: New Depsgraph ignores NLA strips
The new depsgraph was only considering the active action
when attaching relations from the AnimData component/operation
to the properties that are affected by the animation data.
As a result, only properties animated by the active action
were working, while those animated by NLA strips did not change
when playing back/scrubbing the timeline.

This commit fixes this introducing a recursive method to properly
visit all NLA strips, and calling DepsRelBuilder::build_animdata_curves_targets()
on each of those strips.
2018-01-29 19:01:59 +13:00
79639ccd6b 3D View: use_mouse_init for zoom & trackball orbit 2018-01-29 17:01:51 +11:00
961602f7ae Cleanup: move boolean options into flag
- Rename eViewOpsOrbit to eViewOpsFlag
  since VIEWOPS_ORBIT_DEPTH isn't just used for orbiting.
- Move use_ensure_persp & use_mouse_init into the flag.
- Remove viewops_data_create_ex.
2018-01-29 15:38:37 +11:00
64888eabfd Fix: Disable leftover debug prints from earlier work on the rna path renaming/fixing code 2018-01-29 17:22:03 +13:00
d13b943853 Fix T53909: Joining armatures did not remap names on merged action data
Technically this was not a bug, as this functionality was not meant to
work. (Drivers were already handled though, as they are part of the rig)
It was assumed that there was little value in having this functionality
available, as in most pipelines, animation production only begins after
the rig has been locked down (see bug report comments for more details).

On reflection, in most common situations, there's probably no harm in
doing these rna path fixups. This commit takes advantage of some similar
code I recently put in place in the Grease Pencil branch (for joining GP
objects and their layers).

Important Note for Animators/Riggers/TD's:
Please be aware that after joining armatures, some of the animation may
still need to be redone (due to changes in the transform hierarchies/
transform spaces that the animation is applied in). We do not attempt
to correct for these problems, and it is unlikely that we will in future.
2018-01-29 17:22:03 +13:00
5dd5286995 Apply Pose as Rest Pose: Bendy Bone support
The "Apply Pose as Rest Pose" operator now affects Bendy Bone settings
too, making it possible to use interactive posing tools (e.g. Pose Sculpting
brushes) to get the desired shape for the rest-pose shape of Bendy Bones.
When such posing tools are available, this change makes it easier to get
the desired Bendy Bone shapes, as you are no longer restricted to using
buttons to get the desired effects.
2018-01-29 17:22:02 +13:00
5b67a7a2e7 Cleanup: rename user preference flags
USER_ZBUF_ORBIT -> USER_DEPTH_NAVIGATE
The name didn't make sense since it's used for all view navigation.

Also rename USER_ZBUF_CURSOR -> USER_DEPTH_CURSOR since zbuf
is an internal detail.
2018-01-29 15:07:43 +11:00
42a8799efa Cleanup: comments & whitespace 2018-01-29 14:59:56 +11:00
ca116153fa Cleanup: ViewOpsData struct members
- Group initial/previous/current members
  Was using terms old/prev/last/orig in confusing way.
- Replace x,y variables with vectors.
- Remove unused members.
2018-01-29 14:42:50 +11:00
902198a117 3D View: internal option not to use mouse location
When accessing view-port operators from widgets
we need the ability not to use auto-depth or zoom-to-mouse.

Trackball rotation still needs to be supported.
2018-01-29 13:56:35 +11:00
5964c34f8c Cleanup: minor simplification for zoom/dolly
Make args more consistent.
2018-01-29 13:42:28 +11:00
02832c4ca1 Cleanup: de-duplicate common 3D view properties 2018-01-29 13:26:35 +11:00
561d738eaa Fix T53459, inconsistent bevel on identical edges.
The old algorithm depended on vertex order.
The new one uses a global least squares solution on chains
and cycles of edges where loop slide induces a dependency.

See https://wiki.blender.org/index.php/Dev:Source/Modeling/Bevel
in the "Consistent Widths for Even Bevels" for derivation of
the new algorithm.
2018-01-28 19:19:02 -05:00
045f3bda64 Merge branch 'master' into blender2.8 2018-01-28 17:49:58 +01:00
d099b1073b Usual i18n/UI messages fixes. 2018-01-28 17:27:53 +01:00
dfbe415372 Merge branch 'master' into blender2.8 2018-01-28 17:18:56 +11:00
bff1dae767 Cleanup: style, spelling 2018-01-28 17:00:39 +11:00
1c905046d1 Merge branch 'master' into blender2.8 2018-01-28 16:40:23 +11:00
d386d4e7c4 Cleanup: use doxy sections for view3d_view.c
Also move ..._needs_opengl functions into view3d_utils.c
2018-01-28 16:29:32 +11:00
9a5d198cd2 Use factory startup for icon generation
Avoids using local preferences.
2018-01-28 16:03:32 +11:00
87215bbae4 Merge branch 'master' into blender2.8 2018-01-28 15:58:11 +11:00
88174bd22c Merge branch 'master' into blender2.8 2018-01-28 15:18:33 +11:00
7aaede920f Cleanup: warning 2018-01-28 15:15:32 +11:00
1164a70634 Cleanup: move 3D view utilities into own file
Operators and utility functions were getting too mixed up,
the files were also quite large.
2018-01-28 15:01:35 +11:00
Stefan Werner
3c852ba074 Fix T53914: Volumetric scattering now goes correctly through transparent surfaces.
There was a check for volume bounces at every surface intersection. That could lead to a volume scattered path being terminated
when passing through a transparent surface. This check was superfluous, as the volume shader evaluation already checks the
number of volume bounces and once it passes the max, volume shaders will not return scatter events any more.

Reviewers: #cycles, brecht

Reviewed By: #cycles, brecht

Subscribers: brecht, #cycles

Tags: #cycles

Maniphest Tasks: T53914

Differential Revision: https://developer.blender.org/D3024
2018-01-27 21:39:19 +01:00
3cc8b35699 Speed up a little drawing of UVs in the Image Editor
In my tests the previous loop was running in 200 ms. With this change it now runs in 17 ms.

The difference in the end is still not great because the `draw_uvs_lineloop_bmface` function is called for each face and has an ImmBegin and ImmEnd in the function itself
2018-01-26 20:42:30 -02:00
7b29e91711 Code refactor: make mixed small/large BSSRDF radii more robust. 2018-01-26 23:06:53 +01:00
Dalai Felinto
492145f8ac Collections: As it turned out, this is quite harmless to have accessible everwhere
I think ultimately we may move these operators from the outliner space to scene.

Partial revert of a08f687b91.
2018-01-26 19:42:42 -02:00
Dalai Felinto
6634eb3490 Make outliner new collection operator work via viewport too
Technically this revert b3bcbc9e85. This however doesn't seem to be needed
any longer.
2018-01-26 19:37:08 -02:00
Dalai Felinto
5798345c99 Outliner: If a collection is empty and you drag something inside it, it opens up.
Idea by Pablo Vazquez.
2018-01-26 17:10:31 -02:00
d611cf9233 Fix mixed BSDF + BSSRDF sampling bug in path tracing, after 095a01a73a.
Spotted by Ha Hyung-jin, thanks!
2018-01-26 18:47:21 +01:00
ce4915cddb Code refactor: store RGB BSSRDF in a single closure.
Previously we stored each color channel in a single closure, which was
convenient for sampling a closure and channel together. But this doesn't
work so well for algorithms where we want to render multiple color
channels together.
2018-01-26 18:47:21 +01:00
47a3bbcc34 IMB: Add asserts that returned fps and fps base are strictly positives.
Forgot to add that in previous commit, also related to T53003.
2018-01-26 15:14:32 +01:00
567afcca20 Related to T53003: tweak scene fps range.
Move restricted 'reasonable' range to ui_range, and allow wider values
for manual settings.
2018-01-26 15:12:18 +01:00
c528b9b777 Fix T53003: IMB: Invalid framerate handling due to short integer overflow.
FFMPEG uses int for the numerator, while Blender uses a short. So in
cases people gave weird exotic framerate values and we cannot reduce
enough the numerator, we'd get totally weird values (even negative frame
rates sometimes!)

Now we add checks for short overflow and approximate as best as possible
in that case (error should not matter unless you have shots of at least
several hundreds of hours ;) ).
2018-01-26 14:59:16 +01:00
376fc19b24 fix:T53271 now using the context scene layer as requested 2018-01-26 13:37:45 +01:00
Dalai Felinto
f71d8f6b48 Fix Collada importer (crash)
We were not tagging depsgraph to update its nodes after importing new objects.
2018-01-26 09:16:31 -02:00
Dalai Felinto
0e2bc1a4ac Make object_update comment about lack of ID even more clear 2018-01-26 09:15:56 -02:00
Dalai Felinto
ab77363619 Fix silly crash on Collada
Note: This was originally wrongly committed together with an outliner tooltip
fix, re-committing separately now. See bd7060a87f.
2018-01-26 08:45:27 -02:00
Dalai Felinto
de079abfbd Outliner tooltips: Small refactor, future proof change
In the future we may have siblings to collections (like overrides) that are not
collections. This change make sure tooltips will keep working.

Note: This was originally wrongly committed together with a Collada fix,
re-committing separately now. See bd7060a87f.
2018-01-26 08:45:20 -02:00
Dalai Felinto
13238ee991 Revert "Fix crash on Collada exporter"
This reverts commit bd7060a87f.

I mixed two commits together (a fixup for outliner tooltips and a collada fix).
Re-committing them individually.
2018-01-26 08:43:17 -02:00
Dalai Felinto
bd7060a87f Fix crash on Collada exporter 2018-01-26 08:38:46 -02:00
Dalai Felinto
16a3ae580c Outliner: Tooltips for reorder operators
I really would prefer if we were to use the dropbox API for this.
That said, we now have some tooltips that work.

I'm using the new draw callback draw API for outliner tooltips.

Reviewers: mont29

Subscribers: venomgfx, mano-wii, Severin

Differential Revision: https://developer.blender.org/D3020
2018-01-26 08:22:28 -02:00
009ce8f3f4 Fix harmlness RNA warning in image texture node drawing. 2018-01-26 08:41:20 +01:00
c4a4d20d3d Fix part of T53080: all material previews re-rendering after undo.
This reverts commit dc2617130b, which disabled
writing of previews for undo. While this uses some memory, re-rendering all
previews is very expensive, especially if for example you have lots of materials
using high-res image textures.
2018-01-26 08:41:19 +01:00
848f0c5b5b Code cleanup: simpler and faster detection of BVH refit. 2018-01-26 08:41:19 +01:00
22afe88882 Fix navmesh creation w/ multiple objects
D2976 by @dertom
2018-01-26 13:10:02 +11:00
19b1b45d71 make_quickie: replace os.system w/ subprocess.call 2018-01-26 12:53:42 +11:00
9b96dd0f61 icon update: replace os.system w/ subprocess.check_call 2018-01-26 12:46:10 +11:00
0f14c72c29 project_info: replace os.system w/ subprocess.check_call 2018-01-26 12:38:07 +11:00
7980265e7e Tests: replace os.system w/ subprocess.call
Saves on process creation and avoids
being tripped up by command line parsing.

Based on D2967 by @ldo with edits.
2018-01-26 12:23:15 +11:00
65d40b3eeb Docs: invoke_search_popup uses bl_property
Also add code example in docs.
2018-01-26 11:52:01 +11:00
Dalai Felinto
5b67f7a959 Outliner: Implement Add (Ctrl) when moving objects inside collection
Note there is no "text" explaining to users what is going on.
I will address this shortly in an upcoming commit.
2018-01-25 19:26:11 -02:00
Dalai Felinto
7e885e1e10 Layer: Update outdated code comment 2018-01-25 17:50:25 -02:00
Dalai Felinto
748adb37e5 Merge remote-tracking branch 'origin/master' into blender2.8 2018-01-25 11:31:54 -02:00
da4c3f30d9 Cycles: rename displacement methods, default to displace, tweak panel layout.
Differential Revision: https://developer.blender.org/D3019
2018-01-25 14:25:21 +01:00
176c0c96c2 Fix T53874: OpenGL render problem with OpenEXR in 2.8 with float buffers. 2018-01-25 14:25:17 +01:00
Dalai Felinto
e057d7b9eb No need to tag depsgraph id when dropping objects from the outliner
As done by c42fc19a8a - this was needed originally because notifiers were
not working so I had to force tagging.

And for the records, I should have used DEG_TAG_BASE_FLAGS_UPDATE instead of 0.
2018-01-25 11:14:13 -02:00
Dalai Felinto
6743308e59 Fix Eevee error message
That said, this should be informed to the user, not printed in the console.
2018-01-25 10:59:41 -02:00
Dalai Felinto
43b0e61408 Fix missing broken notifiers
We can't have more than one NOTE_SUBTYPE in the same notifier.
Instead of calling both subtypes the code end up not calling either.
2018-01-25 10:10:58 -02:00
Dalai Felinto
c42fc19a8a Fix crash when drag&drop invisible object from outliner to viewport
This is not the issue actually mentioned there. However it is the most serious
one.

Now if the object being dragged was not in a collection linked in the viewlayer
or invisible, we add it to the active collection (or create one if necessary).

This is related to T50967, which is now fully fixed.
2018-01-25 10:00:05 -02:00
Dalai Felinto
10f92f299e Merge remote-tracking branch 'origin/master' into blender2.8 2018-01-25 09:55:59 -02:00
Dalai Felinto
8e341633e9 Fix T50967: When you move an icon from the outliner area object doesn't show up
We can't have more than one NOTE_SUBTYPE in the same notifier.

This is a partial revert of: cd4d5dcb46. In particular to the part concerning
"Also fixed a missing notifier of the object instancing operator".

Not only this was mixed with the original reason for the commit for no reason,
but it actually introduced a bug. Bad, bad developers ;)

Note: Although this commit is not needed for master, blender2.8 requires it for
the forementioned bug report.
2018-01-25 09:52:24 -02:00
5836293990 Merge branch 'master' into blender2.8 2018-01-25 22:20:27 +11:00
2d46ea52cd WM: comments on wmTooltipState struct 2018-01-25 21:52:40 +11:00
7d66925c73 WM: NULL check for recent tooltip change
Caused crash dragging boolean buttons.
2018-01-25 21:52:40 +11:00
fd4d7fbf13 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/library_remap.c
2018-01-25 10:15:31 +01:00
566eb60d81 Fix T53363: Blender won't update mesh's usercount when deleting object datablocks in Editmode.
Only do special handling of ob->data pointer in case we are remapping to
a valid (non-NULL) other obdata. Otherwise, handle it as any other
'remapping to NULL' case.

Hopefully not breaking anything else...
2018-01-25 10:11:12 +01:00
38dafd5f44 Merge branch 'master' into blender2.8 2018-01-25 16:32:43 +11:00
693b41eb17 UI: change tool-tips to be stored in the screen
Move timer and tip out of button code,
now the only requests a tooltip,
passing a creation callback to run.

Needed for manipulators in 2.8,
also helps de-duplicate logic - since we never want
multiple tool-tips showing at once.
2018-01-25 16:22:21 +11:00
032129ef35 Merge branch 'master' into blender2.8 2018-01-25 10:31:37 +11:00
9b32248894 Cleanup: correct ATTR_NONNULL use 2018-01-25 10:21:31 +11:00
9560c57e0b Fix T53874: more cases of OpenGL render to OpenEXR not working after recent changes. 2018-01-24 15:56:09 +01:00
bbc562fc69 Fix T53593: sculpt brush rake spacing bug after recent bugfix. 2018-01-24 15:56:09 +01:00
ca088a7b12 Fix T53115: Memleak with instanced groups and Cycles
The issue was caused by Cycles allocating ID property in a temporary object
which gets overwritten and thrown away every so often.

Now dependency graph will try to reliably check whether ID properties from
a temp object are to be freed.
2018-01-24 15:46:34 +01:00
9f713ec962 Depsgraph: Cleanup, line wrap 2018-01-24 15:34:33 +01:00
9c493ca378 Depsgraph: Add missing synchronize code to scene
The issue here is that we can not duplicate the whole datablock since we
use view layer pointers in depsgraph callbacks.

Maybe this whole chunk of code belongs to somewhere else, or maybe we
can find a smart solution to avoid need of CoW pointers passed to the
evaluation functions.

This fixes lack of viewport update when toggling collection enabled flag.
2018-01-24 15:04:46 +01:00
56a336196d Add utility function to reset ID property value to a given one
This is similar to idproperty_reset() defined in layer.c, but it does not
re-alloc property itself.

We should replace idproperty_reset() with IDP_Reset() now.
2018-01-24 15:04:46 +01:00
90768c9b68 Manipulator: icon highlight could be darker
Use color and highlight from theme.
2018-01-25 00:47:01 +11:00
992ac8f942 Fix for fix w/ GPU_batch_wire_from_poly_2d_encoded
Was missing first edge
2018-01-25 00:47:01 +11:00
c0ddbf39c4 Fix T53646: Blender 2.8 multiple crashes in auto UVs generation
Make sure scene and view_layer set for depsgraph before running editors
update. This is required since tagging might happen before we created depsgraph.
2018-01-24 14:00:49 +01:00
a47a7f2a7b Manipulator: add show_drag option for 2d buttons
Needed so 3d navigation buttons can show show drag cursor
only for buttons with modal operators.
2018-01-24 23:29:17 +11:00
d8b5b4b7b1 Fix bug in view navigation icons
Own error in GPU_batch_wire_from_poly_2d_encoded
Wasn't correctly filling in the VBO with edges.
2018-01-24 22:58:02 +11:00
6a65fc3456 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/modifiers/intern/MOD_wireframe.c
2018-01-24 12:14:59 +01:00
752fc35fa1 Depsgraph: Fix crash entering edit mode with CoW enabled
The issue was caused by some incompatibility of new API which expects ID block
to be specified explicitly, while old code is tagging object's data using
object's ID with OB_RECALC_DATA flag.

We need to switch all areas to give proper ID and everything, but for until
then we'd better stop crashing.
2018-01-24 11:46:54 +01:00
e68771fa87 Cleanup: MOD_wireframe: remove useless isDisabled callback. 2018-01-24 11:22:35 +01:00
a55a4818d6 Fix (unreported) missing feature in ccgdm pbvh generator.
Compared to usual cddm one, ccgdm one was not applying the
ob->derivedDeform deformation to the pbvh generated from the
original mesh geometry, when possible.
2018-01-24 11:22:35 +01:00
ad046efa79 Fix T53551: Weight paint crash when subsurf modifier is not first (master not 2.79).
We can only support painting from subsurf DM in a limited subset of
cases, others (like multiple subsurf, or topology-modyfying ones,
break mapping to original geometry).

This is not the most ideal fix (ideally, we should always be able to get
a mapping to original geometry from any point in modifiers stack...).
2018-01-24 11:22:35 +01:00
9112cceb5e BKE's modifier_isEnabled: add check on NULL Scene pointer.
We do not always have that one available, and even without the
isDisabled callback this func is helpful.

Note that this is a bot stupid, only modifier actually needing a valid
Scene pointer here is subsurf... :|
2018-01-24 11:22:35 +01:00
3e20ac8df3 Fix T53874: OpenGL render to OpenEXR not working after recent changes.
Multilayer EXR also failed already in 2.79 for Sequencer and OpenGL rendering.
Now we revert to single layer OpenEXR in that case.
2018-01-24 11:07:06 +01:00
fe18d9ba11 Depsgraph: Fix evaluaiton order with nested animation and copy on write
It is possible to have animation (or driver) to modify nested datablock, such
as shape key value for example (where animation is on Mesh level, but shape key
is it's own datablock). To deal with such cases we need to create relation
from nested datablock CoW to animaiton/driver operation.
2018-01-24 11:00:37 +01:00
bf8f7304e0 Fix T53878: Cycles bug rendering multiple render layers with different passes.
This was caused by recent pass refactoring from f78e963.
2018-01-24 10:57:32 +01:00
eb7d251cd7 Fix Cycles GLSL bump not matching final render after recent changes. 2018-01-24 10:57:32 +01:00
68284785e5 Cleanup: typo 2018-01-24 18:23:53 +11:00
b9dbd5e85e Manipulators: disable 3D widgets w/ animation
Workaround for T53078.
2018-01-24 18:23:49 +11:00
0ff968eaf5 Fix Cycles inserting displacement node when there is a custom node setup instead. 2018-01-24 07:15:22 +01:00
1686baa7f2 Fix "GPUTexture: texture alloc failed. Not enough Video Memory." in area resizing
`gpu_texture_try_alloc` invalidates zero-sized textures.
The message in the console is not correct in this case (because it is not due to lack of memory).
2018-01-23 22:50:05 -02:00
7389bfdeb0 Merge branch 'master' into blender2.8 2018-01-24 11:45:34 +11:00
bd5696f857 CMake: store icon names
Without this, adding/removing icons wouldn't force cmake to re-run
making builds fail.

This is the same issue with globbing source code.
2018-01-24 11:32:58 +11:00
Dalai Felinto
e6064b412a Fix object mode/edit mode panels not visible in collections
This was broken since e8c15e0ed1. When object_mode moved from
workspace to window.
2018-01-23 16:05:30 -02:00
Dalai Felinto
6249c59609 Greasepencil icons
Note this comes from the greasepencil-object branch, and are merged to help
preventing future merge conflicts.

Also, I renamed the icons for consistency sake. So when this is merged in 2.8
other areas of the code will need to change.

Icons by Matias Mendiola
2018-01-23 12:01:21 -02:00
Dalai Felinto
173f90c700 Revert "Grease-Pencil: Icons"
This reverts commits:

* f0ef360386 Grease-Pencil: Icons from the grease pencil branch
* 13bf4b3804 Grease-Pencil: Fixup for icons
* fb8c382fa1 Grease Pencil dat files fix
2018-01-23 12:01:21 -02:00
41945fcfe4 Cleanup: some ED_view3d functions used uppercase D 2018-01-23 23:37:55 +11:00
41cc2ae626 Merge branch 'master' into blender2.8 2018-01-23 13:19:32 +01:00
4a3ddd8a7a Fix Cycles assert when resizing rendererd viewport. 2018-01-23 13:07:25 +01:00
b129ea843a Cycles: change material output displacement to vector.
Previously only scalar displacement along the normal was supported,
now displacement can go in any direction. For backwards compatibility,
a Displacement node will be automatically inserted in existing files.

This will make it possible to support vector displacement maps in the
future. It's already possible to use them to some extent, but requires
a manual shader node setup. For tangent space maps the right tangent
may also not be available yet, depends on the map.

Differential Revision: https://developer.blender.org/D3015
2018-01-23 12:49:35 +01:00
4a5ee1a5a2 Cycles: add Displacement node.
This converts object space height to world space displacement, to be
linked to the new vector displacement material output.

Differential Revision: https://developer.blender.org/D3015
2018-01-23 11:12:26 +01:00
2838cf0dfe Fix T53854: branched path tracing correlation bug with transparency in split kernel. 2018-01-23 11:11:48 +01:00
4ebcdff873 Merge branch 'master' into blender2.8 2018-01-23 20:04:54 +11:00
9466f8f531 Cleanup: use doxygen groups for view3d_edit.c 2018-01-23 19:48:49 +11:00
f6dc7a7cf3 Cleanup: code comment for view3d_viewmatrix_set 2018-01-23 17:36:51 +11:00
41e930ac66 Cleanup: CMake whitespace 2018-01-23 17:25:09 +11:00
8181e4c812 Manipulator: limit UI for locked views 2018-01-23 17:11:13 +11:00
e679f472ed Cleanup: avoid passing bContext to cameracontrol 2018-01-23 15:19:53 +11:00
3a712632f5 Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/editors/screen/screen_ops.c
2018-01-23 01:00:16 -02:00
1c98fbf982 Merge branch 'master' into blender2.8 2018-01-23 12:18:46 +11:00
1443235aa4 Cleanup: sync w/ blender2.8 branch
Also make some args const
2018-01-23 12:14:26 +11:00
85ca39ec4b Fix screen split refresh issues
`Ctrl` (enable snapping) ans `TAB` (Switching direction) didn't refresh.
2018-01-22 23:07:36 -02:00
fc1fd2704a Merge branch 'master' into blender2.8 2018-01-23 11:45:39 +11:00
367e611179 Merge branch 'master' into blender2.8 2018-01-23 11:24:44 +11:00
bf7e406766 Cycles: Fix optimal BVH selection. 2018-01-22 14:52:09 -07:00
Dalai Felinto
fb8c382fa1 Grease Pencil dat files fix
The ones I previously commited were done with Inkspace 0.92.2
But apparently this renders some parts of the icons transparent.

For example, the tip of the new grease pencil pencil icon.
2018-01-22 15:33:20 -02:00
Dalai Felinto
13bf4b3804 Grease-Pencil: Fixup for icons
I tried to cleanup the .svg but I overdid it a bit
2018-01-22 15:12:12 -02:00
Dalai Felinto
f0ef360386 Grease-Pencil: Icons from the grease pencil branch 2018-01-22 14:37:50 -02:00
2f79d1c058 Cycles: Replace use_qbvh boolean flag with an enum-based property
This was we can introduce other types of BVH, for example, wider ones, without
causing too much mess around boolean flags.

Thoughs:

- Ideally device info should probably return bitflag of what BVH types it
  supports.

  It is possible to implement based on simple logic in device/ and mesh.cpp,
  rest of the changes will stay the same.

- Not happy with workarounds in util_debug and duplicated enum in kernel.
  Maybe enbum should be stores in kernel, but then it's kind of weird to include
  kernel types from utils. Soudns some cyclkic dependency.

Reviewers: brecht, maxim_d33

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D3011
2018-01-22 17:19:20 +01:00
Dalai Felinto
0a622c6dd6 Collections/Layer cleanup: Remove placeholder for de/select objects
No need for placeholders bloating the source code. They can come back once
we decide to implement them.
2018-01-22 12:43:24 -02:00
Dalai Felinto
7628961391 Collections/Layer cleanup: Remove all reference to filter objects
This was not implemented yet. So it's a bit pointless to have all this
placeholder code around without any functionality coming out of it.
2018-01-22 12:43:19 -02:00
Dalai Felinto
8e5f433554 Collections/Layer cleanup: Remove TODO_LAYER_OVERRIDE from most places
This was originally a good idea. However we will need to pay special attention
to this when doing the dynamic overrides anyways. The placeholders won't be
enough to spare us that job.

That said I left the ones on layer.c because we are actually calling these
BKE_override_*_add() functions from doversion, yet they don't do anything.
2018-01-22 12:43:09 -02:00
Philippe Schmid
48fb7e9635 T53831: Fixed vertical line alignment & expand Collection and Scene buttons position.
This was fixed in master with commit 9d873fc3de. However, this fix never made it to 2.8.
(The following merge (a96008f3aa) did not import the fixes.)

Note: This fix is ment to fix the alignment problem.
I don't know if other parts of the code not merged are interesting or not.

But if they are, they should be tackled separately.

Reviewers: dfelinto

Subscribers: venomgfx, dfelinto, raa, Severin

Differential Revision: https://developer.blender.org/D3014
2018-01-22 12:08:30 -02:00
Dalai Felinto
0f69026b1c Fix windows building (log10)
Error: math_base_inline.c(402): error C2668: 'log10' : ambiguous call to
overloaded function
2018-01-22 11:37:19 -02:00
51da664fa1 Fix broken merge in fb45821, was missing changes from cc64872. 2018-01-22 14:28:43 +01:00
8a2d09eb9f Fix T53854: branched path tracing correlation bug with transparency.
This was broken in d750d18.
2018-01-22 14:02:58 +01:00
b06bd20a6b Cycles: Cleanup, remove unused argument 2018-01-22 10:59:14 +01:00
fb4582134a Fix T53850: Lock to Cursor breaks 3D manipulators 2018-01-22 20:14:12 +11:00
f7c812e199 Merge branch 'master' into blender2.8 2018-01-22 14:14:33 +11:00
c723e91ee1 WM: add mouse-move after smooth-view
When hot-spots moved under the pointer,
clicking wouldn't activate the correct item.
2018-01-22 14:09:17 +11:00
ebbed57bef Manipulator: draw all rules while dragging 2018-01-22 13:52:45 +11:00
759aaad0f3 Cleanup: commends
Avoid copy-pasting same comments.
2018-01-22 11:32:03 +11:00
d629f2a8a3 Cleanup: reuse camera frame arrays
Use GWN_vertbuf_raw_step in a loop for less verbose vbo creation.
2018-01-22 11:28:34 +11:00
809dc17254 Merge branch 'master' into blender2.8 2018-01-22 10:42:42 +11:00
9211a4acf8 Fix linking error when compiling without clay engine 2018-01-22 00:19:38 +01:00
13715adc09 DRW: Object Mode: Fix bad camera display in camera view
This fix T53485 : Ortho cameras display frame when in camera view
2018-01-22 00:14:28 +01:00
56fc812d1e Fix manual lookups (data is now lowercase) 2018-01-22 10:00:40 +11:00
d9c962a367 Fix T53843: Error opening online manual 2018-01-22 10:00:40 +11:00
a841e65b85 Cleanup: unused var 2018-01-22 10:00:40 +11:00
777e1d358a Eevee: Probes: Add support for intensity tweak.
This works for grid and cubemaps.

The intensity is baked into the map itself. Thus you need to refresh/rebake the probe to see the changes.
2018-01-21 23:16:59 +01:00
73a1bf1a80 Eevee: Fix grid lighting disappearing when adding a new cubemap probe. 2018-01-21 23:16:59 +01:00
bdfd9a11e8 Clay: Performance: Disable AO codepath if not necessary.
This optimisation only works if no material in the scene require the AO pass.
For this either set the AO distance to 0 or both Cavity and Edges factors to 0.

This double the performance of scenes with very high triangle count.
2018-01-21 23:16:59 +01:00
6700ee9855 DRW: Make the lamp widgets lines stippled. 2018-01-21 23:16:59 +01:00
b2c81c5d43 DRW: Remove unused material uniforms.
This might have some consequences but in my testing I did not found any.
2018-01-21 23:16:59 +01:00
e82616aea6 Eevee: SSR: Optimize the AO out when not enabled. 2018-01-21 23:16:59 +01:00
a507c251b2 Eevee: Put all constant uniforms in a global UBO.
This is an optimization / cleanup commit.

The use of a global ubo remove lots of uniform lookups and only transfert data when needed.

Lots of renaming for more consistent codestyle.
2018-01-21 23:16:59 +01:00
790025c01e Merge branch 'master' into blender2.8
# Conflicts:
#	intern/cycles/blender/blender_mesh.cpp
#	source/blender/editors/screen/screen_ops.c
#	source/blender/editors/space_view3d/drawobject.c
2018-01-21 18:45:47 -02:00
8d671f6f65 Update description of the screen_draw functions 2018-01-21 18:22:39 -02:00
46267fe7bf WM: Fix snapping on split area without preview
In addition to removing unnecessary variables and `tag_redraw` whenever the factor changes;
2018-01-21 18:18:38 -02:00
cc64872b88 Fix T49159: missing Cycles tangents for adaptive subdivision. 2018-01-21 15:43:59 +01:00
e767d21b74 Cleanup: BLI_kdopbvh avoid negative array access
It's harder to reason about array access with negative indices.
2018-01-21 20:17:29 +11:00
a7dc5e12ac Cleanup: style 2018-01-21 11:41:52 +11:00
e53447c137 Fix old files with changed node socket type not loading correctly.
This would lead to sock.default_value pointing to the wrong data type,
possibly causing crashes. Unfortunately, this bug will still exist for
older Blender versions that try to load newer files, which makes
changing the type of a node socket problematic.
2018-01-20 22:42:59 +01:00
99efebd2dd Merge branch 'master' into blender2.8 2018-01-21 01:47:49 +11:00
dd35048602 Cleanup: doxy groups for screen_ops.c 2018-01-21 01:41:58 +11:00
a177d64213 Merge branch 'master' into blender2.8 2018-01-21 00:55:08 +11:00
949e56dff1 Fix screen split preview refresh issues
Switching direction didn't refresh, also cursors were flipped.
2018-01-21 00:41:48 +11:00
da53eb3748 Manipulator: tweak shape drawing
Draw triangles over wire for a more subtle outline.
2018-01-20 19:41:41 +11:00
a3716f5945 GPU_batch: Add GPU_batch_wire_from_poly_2d_encoded
Draws wire around polygon shapes:
better visibility w/ any background color.
2018-01-20 18:45:27 +11:00
Dalai Felinto
e969ac6413 Fix collections names no longer unique when moved around
We were not checking for uniqueness after moving. And in some cases the new
siblings of our collection may have conflicting names.
2018-01-19 18:44:11 -02:00
Dalai Felinto
4dfccf8b7f Collections: Fix for auto-named children when parent name is MAX_NAME
Reported via IRC by Vuk Gardašević (lijenstina).
2018-01-19 17:24:35 -02:00
Dalai Felinto
244fb3ebe0 Merge remote-tracking branch 'origin/master' into blender2.8 2018-01-19 17:06:32 -02:00
Dalai Felinto
431d5772bb Fixup for integer digits commit 2018-01-19 17:04:19 -02:00
Dalai Felinto
4d0bb7de64 Merge remote-tracking branch 'origin/master' into blender2.8 2018-01-19 17:01:48 -02:00
Dalai Felinto
075def8fbd Util function to determine number of digits from an integer 2018-01-19 16:54:07 -02:00
Dalai Felinto
efe1af3d11 Outliner: Remove User Preferences
This was introduced to the outliner when we had no User Preference
window back in 2.5x. Right now it makes no sense to keep this around.

But how about addon user preferences:
* They belong in the user preference window under the addon.

How about the user preferences themselves:
* You find them in the user preference window.

And templates?
* Why are they here in the first place?

After talking to Pablo Vazquez (who in turn poked Sergey Sharybin) we found
it reasonable to get rid of this. If it turns out that we were wrong we
revert this.

As for leaving this exposed as a debug option (as suggested on IRC) I would say
no, please. This end up polluting the code and never cleaned up in the end.
(this was specific talking about templates).

Technical note: I left the functions in outliner still hanging around.
While I used UNUSED_FUNCTION for one of them, for the other one I had to use:
`#if 0` because the function was calling itself, which would fail to build if
I used UNUSED_FUNCTION.
2018-01-19 16:06:14 -02:00
fa91b43e8c Cycles: Make it more proper check on vectorization flags from DebugFlags
Mimics to checks in system_cpu_support() checks.
2018-01-19 15:48:42 +01:00
Dalai Felinto
d9858d5897 Merge remote-tracking branch 'origin/master' into blender2.8 2018-01-19 12:46:23 -02:00
Dalai Felinto
edf053ff63 Outliner Python UI cleanup: remove KEYMAPS
This was removed since 2013 (ef765b3606). It should have been removed back
then from the UI file too.
2018-01-19 12:45:57 -02:00
Dalai Felinto
7866870a9a Outliner: Fix unparenting poll (when drag'n'droping an object) 2018-01-19 12:28:16 -02:00
ccec1e7667 Cycles: Cleanup, stop using debug flags in system utilities
Debug flags are to be controlling render behavior, nothing to do with low level
system utilities.

it was simple to hack, but logically is wrong. Lets do things where they are
supposed to be done!
2018-01-19 15:22:32 +01:00
54632dc830 Cycles: Remove util_debug include from kernel code
Not sure why it was in there, all the debug flags stuff is to be handled outside
of kernel.
2018-01-19 15:21:34 +01:00
8e1dd7ed81 Cycles: Remove unneeded include statements
Also try to move them from headers to implementation files as much as possible.
2018-01-19 15:19:45 +01:00
Dalai Felinto
db9f0527e8 Outliner: Change All Scenes to Scenes and make it focus on compositing
We have different ways of explore the scene objects, namely View Layer and
Collections. This change let us focus on compositing elements only such as:

* View Layers
** Collections
** Render Passes
* Freestyle
* Grease Pencil?

Not included in this commit is an option to handle filtering of
collections passes, ... Not sure if we would like, though.
Since they are all properly nested under a "Collections" / "Passes"
parent.
2018-01-19 12:13:40 -02:00
Dalai Felinto
37913cf532 Outliner Filtering System + Cleanup
User notes:

The outliner so far was a great system to handle the object oriented workflow
we had in Blender prior to 2.8. However with the introduction of collections
the bloated ammount of data we were exposed at a given time was eventually
getting on the way of fully utilizing the outliner to manage collections and
their objects.

We hope that with this filtering system the user can put together the outliner
with whichever options he or she seem fit for a given task.

Features:
* Collection filter: In case users are only focused on objects.
* Object filter: Allow users to focus on collections only.
* (Object) content filter: Modifiers, mesh, contrainst, materials, ...
* (Object) children filter: Hide object children [1].
* Object State (visible, active, selected).
* Compact header: hide search options under a search toggle.
* Preserve scrolling position before/after filtering [2].

[1] - Note we still need to be able to tell if a children of an object is in a
      collection, or if the parent object is the only one in the collection.
      This in fact was one of the first motivations for this patch. But it is to
      be addressed separately now that we can at least hide children away.

[2] - We look at the top-most collection in the outliner, and try to find it again
      after the filtering and make sure it is in the same position as before.
      This works nice now. But to work REALLY, REALLY nice we need to also store
      the previous filter options to be sure the element we try to keep on top
      was valid for both old and new filters. I would rather do this later though
      since this smell a lot like feature creeping ;)

Remove no longer needed display options:
 * Current Scene (replaced by View Layer/Collections)
 * Visible (replaced by filter)
 * Selected (same)
 * Active (same)
 * Same Type (same-ish)

How about All Scenes? I have a patch that will come next to replace the current
behaviour and focus only on compositing. So basically stop showing the objects
and show only view layers, their passes and collections, besides freestyle.

Also, while at this I'm also reorganizing the menu to keep View Layer and
Collections on top.

Developer notes:

* Unlike the per-object filtering, for collections we need to filter at tree
creation time, to prevent duplication of objects in the outliner.

Acknowledgements:

Thanks Pablo Vazquez for helping testing, thinking some design questions
together and pushing this to its final polished state as you see here.

Thanks Sergey Sharybin and Julian Eisel for code review. Julian couldn't do a
final review pass after I addressed his concerns. So blame is on me for any
issue I may be introducing here. Sergey was the author of the "preserve
scrolling position" idea. I'm happy with how it is working, thank you.

Reviewers: sergey, Severin, venomgfx
Subscribers: lichtwerk, duarteframos

Differential Revision: https://developer.blender.org/D2992
2018-01-19 12:13:10 -02:00
76f374052c Depsgraph: Fix freeing of evaluated mesh
Was accessing wrong pointer to get original version of the mesh.
2018-01-19 14:20:22 +01:00
25739ada0b Correct view3d_draw_bgpic_test declaration
Was extern, which got out of sync, move into header.
2018-01-19 23:11:57 +11:00
08fe885d06 Merge branch 'master' into blender2.8 2018-01-19 21:47:57 +11:00
889321e22b Cleanup: reaname LINKLIST_FOREACH -> LISTBASE
LinkList's are a different API, no need to confuse things.
2018-01-19 21:39:18 +11:00
0fe41009f0 Fix T53830: Cycles OpenCL debug assert on macOS,
This was probably harmless besides some unnecessary memory usage due to
aligning allocations too much.
2018-01-19 11:35:07 +01:00
e46c49ff3d Fix T53788: Camera animation not working
Both object level and camera datablock properties animation did not work with
copy on write enabled.

The root of the issue is going to the fact, that all interface elements are
referencing original datablock. For example, View3D has pointer to camera it's
using, and all areas which does access v3d->camera should in fact query for
the evaluated version of that camera, within the current context.

Annoying part of this change is that we now need to pass depsgraph in lots
of places. Which is rather annoying.

Alternative would be to cache evaluated camera in viewport itself, but then
it makes it annoying to keep things in sync.

Not sure if there is nicer solution here.

Reviewers: dfelinto, campbellbarton, mont29

Subscribers: dragoneex

Differential Revision: https://developer.blender.org/D3007
2018-01-19 11:12:22 +01:00
5a61c1de82 Fix T53786: Proportional size from redo ignored
Changing PET size while transforming stores the size in the
tool settings, but changing in the redo panel didn't.
2018-01-19 21:09:16 +11:00
0cddc7e300 WM: operator flag to check repeat/redo execution 2018-01-19 21:07:43 +11:00
9cac97fb3c Fix sculpt error freeing NULL vertex buffer
Relates to T53806 which needs further investigation
2018-01-19 19:36:36 +11:00
5477452194 Merge branch 'master' into blender2.8 2018-01-19 18:03:43 +11:00
53e062da94 Cleanup: sync w/ blender2.8 branch
Split screen_draw.c from screen_edit.c (avoid conflicts syncing).
2018-01-19 17:57:37 +11:00
4444ea42f2 Merge branch 'master' into blender2.8 2018-01-19 17:37:01 +11:00
c850320b35 Merge branch 'master' into blender2.8 2018-01-19 17:21:15 +11:00
ebf01d44ee WM: window draw callbacks and split preview snap
This moves window overlay from hard coded flags into drawing callbacks.

It also supports snapping (holding Ctrl).
2018-01-19 17:15:45 +11:00
7a24e0d175 Cleanup: typos 2018-01-19 15:34:54 +11:00
abb3a86e10 Fix T53833: Particle Info node and Displacement Crash
The displacement shared was running before particle data was copied to the
device causing bad memory access when the particle info node was used. Fix
is simply to move particle update before mesh update so the data is
available to displacement shaders.

(Altho this fixes the crash the particle info node is still mostly useless
with displacement for now...)
2018-01-18 22:40:48 -05:00
368414efac Fix T53823: Particle weight brush crash
Entering particle edit mode w/ the weight brush enabled crashed
on non-hair particle systems.
2018-01-19 12:25:09 +11:00
2b9fb723ed Fix T53832: Particle weight paint crash
Drawing hair weights read before the hair array start.
This code could be improved since it currently copy-pastes,
from do_particle_interpolation, but this would need larger changes.

For now just correct existing logic.
2018-01-19 12:14:53 +11:00
4d3d002b65 Eevee: Fix translucency light powers. 2018-01-18 22:43:05 +01:00
59989fd4e0 Eevee: Volumetrics: Update/fix the lamp power convertion.
Include a better fit for area lights.
2018-01-18 21:52:36 +01:00
03e432bcdb Eevee: Implement Sun area lighting and few fixes/opti.
Sun is treated as a unit distant disk like in cycles.

Opti: Since computing the diffuse contribution via LTC is the same as not using the Linear Transformation, we can bypass most of the LTC code.
This replaces the sphere analytical diffuse computation as it gives a more pleasing result very close to cycles' AND cheaper.

Lights power have been retweaked to be coherent with cycles (except sun lamp with large radius where cycles has a non-uniform light distribution).
2018-01-18 21:52:36 +01:00
0cec092eca Eevee: Optimize rectangle area light.
Use the latest LTC optimisation techniques. That said, the final output is a bit more biased (and a bit further away from cycles).
2018-01-18 21:52:36 +01:00
220f1ad67e Eevee: Use inversesqrt() when possible. 2018-01-18 21:52:36 +01:00
8ed0161aa7 Eevee: Implement new LTC algorithm for Sphere Lights.
This is an improvement on the old spining quad method that was giving artifacts when the reflection ray was nearly aligned with the sphere center.
This might be a bit heavier but it's worth it.
2018-01-18 21:52:36 +01:00
Dalai Felinto
97e2b0c594 Outliner: Follow up on "Alphabetical sorting"
Technicall this works for collections modes too (View Layer and Collections) even
if only for objects. So it should be in the menu as well.
2018-01-18 18:23:19 -02:00
Dalai Felinto
60eb897fa5 Outliner: Alphabetical sorting - Fixup on "Get rid of Search Menu"
Issue introduced on 51bcf7bd5f.

Alphabetical sorting is not related to search, so it shouldn't have been
touched by the Search Menu changes.
2018-01-18 18:15:00 -02:00
Dalai Felinto
dc296542d4 Outliner: Fix parenting clear poll 2018-01-18 18:02:32 -02:00
Dalai Felinto
f1cfe67594 Outliner: Use (temporary) icons for collections
We need new icons for collections.

Yet we are using them in a few places, so we may as well be consistent and use
it everywhere.
2018-01-18 17:30:37 -02:00
Dalai Felinto
74f872df3a Outliner: Rename "Active View Layer" > "View Layer"
The original name came from a cheap conversion of the "active layer" option
to "active render layer" and then "active view layer".
2018-01-18 14:17:07 -02:00
Dalai Felinto
33ddd926b7 Outliner: View Layer: add option to add a new collection to the current view layer
This operator not only links a collection, but it creates a new one and then it
links it. Although the preferrable method for users to handle their collections
is when viewing the "Collections", let's explore this workflow for now.

Suggested by Pablo Vazquez, thank you.
2018-01-18 13:56:55 -02:00
Dalai Felinto
51bcf7bd5f Outliner: Get rid of Search Menu
Use inline options instead. This will be collapsable once we merge the upcoming
filter sytem.
2018-01-18 13:20:10 -02:00
Dalai Felinto
9398db07cc Outliner: Keep header operator-free and edit menu cleanup
Headers should not have operators as much as possible. The exception here is
for datablocks mode when you want to see the active keyset.

Edit menus on the other hand should be clearly distinct from the RMB context
menus. Edit menu options should be only the ones that apply to the entire
outliner, regardless of the selected element.

Context (rmb) menus should be related to the element you RMB on to invoke the
menu. I'm also taking this opportunity to start bringing the context menus
to Python. There is little reason not to, and it helps editing them (In this
case I'm doing it only for the Scene Collection one).
2018-01-18 13:05:45 -02:00
539e170d79 Depsgraph: Fix crahs when selecting objects
Was wasy to reproduce by hitting A-key.

Missing part of the recent orig_id pointer commit.
2018-01-18 14:14:53 +01:00
42a562496b Fix memory leak in recent curve refactor
5b25605761fb7
2018-01-18 20:54:59 +11:00
7b3e441bcf Improved docstring of mathutils.Matrix.lerp() 2018-01-18 09:58:14 +01:00
9811150952 Improve docstring for mathutils.Matrix.decompose() 2018-01-18 09:38:01 +01:00
001789d733 Fix T53808: VSE doesn't show scene strip markers 2018-01-18 14:49:09 +11:00
e8452cf0bc Merge branch 'master' into blender2.8 2018-01-18 14:11:38 +11:00
6880a549ba Fix weight particle brush versioning 2018-01-18 14:02:26 +11:00
9b04a47070 Cleanup: label scene flags more clearly
Also correct typo in enum name
2018-01-18 13:51:49 +11:00
2be8598fe7 Fix T53811: "bmesh.ops.split" crash 2018-01-18 12:36:25 +11:00
7ffe838473 WM: improved area resize snapping
Instead of 10px steps, snap to mid-point & adjacent edges.

Not yet implemented for split preview.
2018-01-18 11:33:51 +11:00
27dff3fbc1 Merge branch 'master' into blender2.8 2018-01-18 01:01:17 +01:00
e6df02861e Fix buffer overflow vulnerability in curve, font, particles code.
Solves these security issues from T52924:
CVE-2017-12102
CVE-2017-12103
CVE-2017-12104

While the specific overflow issue may be fixed, loading the repro .blend
files may still crash because they are incomplete and corrupt. The way
they crash may be impossible to exploit, but this is difficult to prove.

Differential Revision: https://developer.blender.org/D3002
2018-01-18 00:54:07 +01:00
e04d7c49dc Fix buffer overflow vulnerabilities in mesh code.
Solves these security issues from T52924:
CVE-2017-12081
CVE-2017-12082
CVE-2017-12086
CVE-2017-12099
CVE-2017-12100
CVE-2017-12101
CVE-2017-12105

While the specific overflow issue may be fixed, loading the repro .blend
files may still crash because they are incomplete and corrupt. The way
they crash may be impossible to exploit, but this is difficult to prove.

Differential Revision: https://developer.blender.org/D3002
2018-01-18 00:54:07 +01:00
e0f2c7aff4 Fix Linux/GCC compiler warning in recent fixes. 2018-01-18 00:54:07 +01:00
235f578a0d Loop Cut: Allow mouse placement w/ numeric input
D2973 by @cyaoeu
2018-01-18 10:55:53 +11:00
07aed404cf Fix buffer overflow vulernability in thumbnail file reading.
Fixes CVE-2017-2908 from T52924.

Differential Revision: https://developer.blender.org/D3001
2018-01-17 20:25:42 +01:00
d30cc1ea0b Fix buffer overflows in TIFF, PNG, IRIS, DPX, HDR and AVI loading.
Solves these security issues from T52924:
CVE-2017-2899
CVE-2017-2900
CVE-2017-2901
CVE-2017-2902
CVE-2017-2903
CVE-2017-2904
CVE-2017-2905
CVE-2017-2906
CVE-2017-2907
CVE-2017-2918

Differential Revision: https://developer.blender.org/D2999
2018-01-17 19:59:47 +01:00
a6700362c7 Memory: add MEM_malloc_arrayN() function to protect against overflow.
Differential Revision: https://developer.blender.org/D3002
2018-01-17 19:59:47 +01:00
8400b4b566 Merge branch 'master' into blender2.8 2018-01-17 18:03:08 +01:00
46204f843b Depsgraph: Fix for fake dependency cycle being created for shape key drivers
One thing i'm not fully happy with is all this is_same_* functions. Need to
get rid of this by probably adding explicit entry/init/whatever nodes and
maybe making node criteria aware of whether key will be used as "from" or
as "to" node.
2018-01-17 18:02:51 +01:00
10e6da1f2d Merge branch 'master' into blender2.8 2018-01-17 17:47:38 +01:00
5d4ffb42a3 Delete Invalid Drivers: more lenient poll function
This function is faster and also allows for deletion of invalid drivers in
nested data blocks (for example in shape keys). Thanks @sergey!
2018-01-17 17:14:39 +01:00
a8fc44299b external_libs: Add openjpeg to the mavc lib folders for cycles standalone. 2018-01-17 07:45:05 -07:00
8e35a9e4c7 Eevee: Perf: Update noises (in utilTex) via GPU drawing.
This leads to a ~3ms improvement of CPU time during drawing.
This prevent the rendering from being stalled waiting for the texture data to be transfered.
2018-01-17 14:02:48 +01:00
54e10dbd17 DRW: Add DRW_framebuffer_create() function.
This is because certain part of the engine may require a blank framebuffer to bind textures to.
This is the case when using only array textures, unsupported by DRW_framebuffer_init().
2018-01-17 13:55:49 +01:00
c6101b09eb Merge branch 'master' into blender2.8 2018-01-17 12:38:52 +01:00
0aaae43748 Simplified GRAPH_OT_driver_delete_invalid after feedback @aligorith
By adding the ANIMFILTER_NODUPLIS flag to the filter it'll only be
processing each F-Curve once, which means we can remove while iterating.

This also solves a potential issue when a datablock has a driver and is
shared among multiple objects.
2018-01-17 12:38:14 +01:00
333d4f3447 Depsgraph: Use more const qualifiers 2018-01-17 12:27:46 +01:00
971a44fe08 Merge branch 'master' into blender2.8 2018-01-17 12:21:05 +01:00
c38ebf93e3 Added "Delete Invalid Drivers" operator
This operator is available in the graph editor in the Drivers mode, and
allows quick cleanup of drivers marked as 'invalid'.
2018-01-17 12:12:37 +01:00
ca5987c8a5 Cleanup: replace BLI_dynstr w/ BLI_string_joinN
Use in place of recently reverted 'DRW_shader_create_lib'
2018-01-17 21:42:14 +11:00
f314d9ce47 Depsgrapph: Fix/workaround for missing hair
The issue was happening because dependency graph did not inform particle
settings as modified. This is a regression caused by tagging and flushing
mechanism refactor.

The real fix would be to make particle settings to use ID level recalc flags
rather than own flags, which will also simplify relations around particle system,
and particle settings evaluation.

Reported by Mai in IRC.
2018-01-17 11:23:16 +01:00
10ce5af2dd Revert "Fix use-after free in DRW_shader_create_with_lib"
Caused an error entering edit-mode.

d60f26f37a & 2659500835
2018-01-17 20:39:42 +11:00
2094bbd033 Fix assert in mesh batch conversion 2018-01-17 19:54:13 +11:00
dfea9f43db Merge branch 'master' into blender2.8 2018-01-17 19:29:50 +11:00
8d064c5bc4 Fix use-after free in DRW_shader_create_with_lib
Limit scope to avoid future accidents
2018-01-17 19:28:15 +11:00
7935a394b7 Correct simple deform versioning from D2989 2018-01-17 19:17:49 +11:00
c02d428147 Eevee: Update lightprobes when deleting or linking a new world datablock 2018-01-17 00:23:31 +01:00
a19e3bdad8 Fix T53810: Crash removing a scene used in render
Header drawing accesses the scene too.
2018-01-17 10:03:22 +11:00
d7acabdef5 Eevee: SSS: Fix OpenGL error when enabling TRANSLUCENCY but not SSSS.
This was causing this error:
"Different sampler types for same sample texture unit in fragment shader"
2018-01-17 00:01:17 +01:00
2659500835 DRW: Codestyle refactor: Use macro to create shader libs.
This clears up the code from many DynStr usage. Easier to read.
2018-01-16 23:40:15 +01:00
96138daa2b Eevee: SSR: Fix artifacts at object/background limits.
This should have a very small perf impact but it's needed.
2018-01-16 22:18:35 +01:00
213e34a6c3 Eevee: Fix Hashed Alpha.
Now hashed alpha materials are stable when moving the camera/not using TAA.
It also converge to a noise free image when using TAA. No more numerical imprecision.

There still can be situations with multiple overlapping transparent surfaces that can lead to residual noise.
2018-01-16 19:40:17 +01:00
9fd28c7769 Eevee: AO: Removes samples and denoise options.
This comes with a lot of code simplification that leads to a small performance improvement.
2018-01-16 18:22:25 +01:00
c372113489 Eevee: Add macro to sample noise in utilTex.
Avoid future coding error.
2018-01-16 18:22:25 +01:00
5f569378d2 Eevee: SSR: Derive the brdf bias from the trace quality.
Also change the range of the trace quality so that the trace actually covers the screen most of the time.
2018-01-16 18:22:25 +01:00
9afeba330f Eevee: Fix SSRefraction noise. 2018-01-16 18:22:24 +01:00
9365e966b4 Eevee: SSR: Enhance the halfres raytrace.
This make the halfres raytrace actually converge to an antialiased image by jittering the source pixel.
2018-01-16 18:22:24 +01:00
2221cdb517 Eevee: SSR: Optimise Texture fetches and solve noise issue.
There was some remaining issue caused by neighbor re-use. Randomizing them every _prime_number_ of iterations fixes this.
2018-01-16 18:22:24 +01:00
3cb2b2956b Eevee: SSR: Remove ray count and use integer texture for hit coord.
Using GL_RG16I texture for the hit coordinates increase tremendously the precision of the hit.
The sign of the integer is used to 2 flags (has_hit and is_planar).
We do not store the depth and retrieve it from the depth buffer (increasing bandwith by +8bit/px).
The PDF is stored into another GL_R16F texture.

We remove the raycount for simplicity and to reduce compilation time (less branching in refraction shader).
2018-01-16 18:22:24 +01:00
84c91be0a4 Eevee: Fix noise correlation in the blue noise update. 2018-01-16 18:22:24 +01:00
39af6c27f5 DRW: Change framebuffer texture creation.
Instead of creating non temp textures only at framebuffer creation, we create them and bind them if their pointer is NULL.

This should simplify the framebuffers creation code.
2018-01-16 18:22:24 +01:00
9d1ae07d4f Cleanup: Avoid ifdefs in multiple places
Define a helper macro. Makes code read easier.
2018-01-16 17:14:57 +01:00
d9eb17b18e Cleanup: Remove deprecated enum flags
Those are not used anymore.
2018-01-16 17:11:47 +01:00
bf9460e3cf Cleanup: Get rid of legacy extra recalc flags
Those are not used by new dependency graph and are not needed for properly
created rigs with new granular nodes.
2018-01-16 17:11:47 +01:00
55f97d1dd9 Static override: cleanup: name consistency. 2018-01-16 17:11:03 +01:00
3cd8264505 Static override: enhance 'make override' operator.
Now when you make an override of a linked armature, code will
automatically also override objects using that armature (deformed by, or
children of), trying to replicate make_proxy results.

Also some initial code to replicate 'make_proxy' in case of instantiated
linked groups, but that is not working yet (and will also require some
work in RNA part of group's objects collection anyway).
2018-01-16 17:11:03 +01:00
72ec6dbb0b Static overrides API: add functions to create overrides from several datablocks at once.
This simplifies remapping task, since you don't have to ensure your
overrides are created in the correct dependency order.

Uses famous LIB_TAG_DOIT to mark IDs to be overridden.
2018-01-16 17:11:03 +01:00
436eea2d93 Merge branch 'master' into blender2.8 2018-01-16 16:40:05 +01:00
b55111f8f6 Cleanup: Naming of depsgraph 2018-01-16 16:38:39 +01:00
4e0673927a Alembic: don't explicitly pass NULL 2018-01-16 16:28:10 +01:00
6db0fd65ab T53711: Alembic don´t import vertex colors correctly
An index stored in Alembic wasn't used. Often this index is a no-op
(i.e. index[n] = n), in which case the result was fine. However, when it
isn't, it caused issues.
2018-01-16 16:03:21 +01:00
c810df35b2 Draw manager: Cleanup, use full name for depsgraph variable 2018-01-16 15:58:39 +01:00
1ed06a1167 Draw manager: Make depsgraph a part of draw state
Makes it more explicit and avoids hash loookup when depsgraph is needed.
2018-01-16 15:42:03 +01:00
eea3506019 Draw manager: Make update context aware of what depsgraph causes update 2018-01-16 15:38:44 +01:00
1e0283828f Depsgraph: pass depsgraph to editors update context struct
This way callbacks will know which depsgraph is being changed, and where
evaluated data is coming from.
2018-01-16 15:37:52 +01:00
263f614932 Add dedicated pointer to an original ID datablock
Before we were re-using newid pointer inside of ID structure where we were
storing pointer to an original datablock.

It seems there is no way we can avoid requirement of having pointer to an
original datablock, so let's stop obusing system which was only designed to
be a runtime only thingie. Will be more safe this way, without need to worry
about using any API which modifies newid.
2018-01-16 15:09:48 +01:00
d4ff1a1f2c Merge branch 'master' into blender2.8 2018-01-16 14:52:43 +01:00
0bdb1eab82 Sculpting: Fix uninitialized color being left for smooth meshes with hidden mask 2018-01-16 14:46:48 +01:00
7934e7ab83 Sculpting: Fix for "Hide Mask" does not work with multires 2018-01-16 14:31:52 +01:00
379a752ee7 Manipulator: fix arrow offset in perspective view
Use 3D calculations instead of projecting into 2D space.
2018-01-16 23:38:27 +11:00
7df1983bf9 Fix compilation error 2018-01-16 12:48:33 +01:00
cfe6b83134 Merge branch 'master' into blender2.8 2018-01-16 12:07:43 +01:00
67e4b1d3e9 Fix missing node tree updates when unconnected node affects output via driver
Fixes T53794: Can't control color ramp node color values with drivers
2018-01-16 12:06:22 +01:00
0b500ba147 Depsgraph: Fix fake cyclic dependencies for node tree drivers
There was a fake cyclic dependency happening when node of node tree is driving
another node of the same tree.

This is related to T53794, but more fixes is needed here.
2018-01-16 11:54:32 +01:00
45b5de9cb3 Depsgraph: Better relations name 2018-01-16 11:43:05 +01:00
1d763b5395 Depsgraph: Check for ID match when checking if operations corresponds to the same bone 2018-01-16 11:41:50 +01:00
b974d0da4d Depsgraph: Cleanup, indentation 2018-01-16 11:40:02 +01:00
b667020310 Depsgraph: Cleanup, brace placement\ 2018-01-16 11:38:44 +01:00
03223a5e7d readfile: ensure blend header follows the spec 2018-01-16 20:02:32 +11:00
2346e0850f Ruler Manipulator: dragging out of the view removes
Not ideal, but means we don't need to override Delete key.
2018-01-16 18:14:11 +11:00
fd80b83e8e Manipulator: Support tweak removing the manipulator 2018-01-16 18:03:15 +11:00
873a87c7e8 Merge branch 'master' into blender2.8 2018-01-16 14:56:03 +11:00
e428ea3e00 Cleanup: indentation 2018-01-16 11:40:43 +11:00
6f45dea6ee UI: support canceling color ramp drag
D2997 by @oktomus
2018-01-16 11:16:50 +11:00
Dalai Felinto
1e9bc60777 Fix collection visibility evaluation
Collection       A [disabled]
 -> Collection   B
   -> Collection C
     -> object

Object should be invisible, but it is not. Reported by Antonio Vazquez.

Bug introduced on: 1f5106de61
2018-01-15 20:19:12 -02:00
Dalai Felinto
59fcfaf5c3 Fix crash in outliner when moving objects around
How to reproduce it:
* Change Outliner from Active View Layer to Collections
* Create a new collection under Master Collection (Collection 2)
* Move all three objects from Collection 1 to Collection 2
* Move all three objects from Collection 2 to Collection 1
2018-01-15 19:08:45 -02:00
Dalai Felinto
ae12424298 Outliner/Collections: Fix objects disappearing when moving to collections
Bug introduced on fb4cd136a7 (multi-object drag-and-drop).

How to reproduce the bug:
* Create a new collection
* Move the Cube to the new collection
* Move the Camera to the new collection (Cube disappears)
* Move the Lamp to the new collection (Camera disappears)

Explanation of the bug:
The moved object was still selected, so we were trying to add the object to the
collection were the object was already inserted (which would fail silently) and
then remove it.
2018-01-15 18:27:50 -02:00
b810e9ffc4 Fix: Mesh Edit Mode Shader: Correct artifacts that appeared on edges of edit mode with some AMD GPUs
In case the problem appeared with the `AMD Radeon HD 7570M`
2018-01-15 16:29:41 -02:00
7183d15d97 Fix unreported: Eevee Principled Shader: Crash because Intel does not like dead code
The reason for the crash is still a bit confusing, but on Windows with Intel HD Graphics 4000 it always happens when you enable `Use Nodes` or when you try to connect the Pricipled Shader node to the output without the `Subsurface Scattering` and `Subsurface Translucency` options enabled.
2018-01-15 13:49:50 -02:00
f5e2d42092 GPU Texture: Add GL_RG16I format. 2018-01-15 15:39:03 +01:00
5e6c86cb1f GPU_batch_from_poly_2d_encoded: skip winding check
Ensure all polygons have the same winding instead.
2018-01-16 00:59:52 +11:00
7ba07b7e64 GPU_batch_from_poly_2d_encoded: optional rctf arg
Also use compiler attributes
2018-01-16 00:16:54 +11:00
5cb43b0f20 Cleanup: update comments 2018-01-16 00:16:54 +11:00
ec3248437d Merge branch 'master' into blender2.8 2018-01-15 13:55:52 +01:00
Karl Semich
75e2ae72c7 Allow for multi-gigapixel renders
This patch fixes a 32-bit overflow that occurs on 64-bit systems due to a numeric literal being treated as 32-bit.

This patch allows for the generation of images that occupy more than 4GB of RAM, which previously caused a crash.

Reviewers: sergey

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D2975
2018-01-15 12:57:12 +01:00
2c2203d82a Cycles: CLeanup, remove unused function argument 2018-01-15 11:45:16 +01:00
4d8b78b0a9 Sculpting: Sdd an option to hide mask in viewport
Brushes themselves are still affected by the mask, but the viewport is not
showing the mask. This way it's easier to see details while sculpting.

Studio request by Julien Kaspar
2018-01-15 11:43:59 +01:00
6cb06501c3 GPU buffers: Use bitflag to whether we want to show diffuse color
Those fine-tuning bits will be extended soon, so makes sense to start using
some more verbose flag names when calling functions.
2018-01-15 11:43:59 +01:00
72cb7e2726 Manipulator: vector icons for 3D view navigation
Use different icons for perspective/ortho state
(previous icon was place-holder).
2018-01-15 20:56:31 +11:00
6acfef6ef1 Manipulator: support for buttons as vector shapes 2018-01-15 20:40:57 +11:00
bfada6cc4a GPU_batch: Add utility to create 2D shapes
Shapes are represented by compact byte array,
encoded by 'make_shape_2d_from_blend.py' in the tools repo.
2018-01-15 20:38:06 +11:00
ae6cc4a21d GPU_batch_presets: move static vars into struct
Also use GWN raw stepping API to fill in data.
2018-01-15 16:55:40 +11:00
b1ac7571a8 Cleanup: split GPU_batch_presets into own file
Mixing other batch code in this file easily shadowed existing variables.
Keep presets separate (we may have more, 2D & 3D presets)
2018-01-15 16:24:02 +11:00
7c1286b2b7 Manipulator: add free callback 2018-01-15 16:06:56 +11:00
129196dc32 Merge branch 'master' into blender2.8 2018-01-15 15:59:59 +11:00
ec52e64a5d RNA: Add RNA_property_string_set_bytes
This is needed to set values that contain zero bytes
(where the length isn't fixed).
2018-01-15 15:59:10 +11:00
82a94d0f84 Cleanup: correct names 2018-01-14 17:54:27 +11:00
58be6d282d Merge branch 'master' into blender2.8 2018-01-14 17:29:38 +11:00
02a01b3505 Cleanup: BLI_ghash
Improve hashsizes comment too.
2018-01-14 17:28:15 +11:00
8d3efb2b90 Fix T53772: Presets don't support colons 2018-01-14 14:31:39 +11:00
e7bf77df3a Merge branch 'blender2.8' of git.blender.org:blender into blender2.8 2018-01-13 01:13:37 -02:00
cdc31c3e6e Merge branch 'master' into blender2.8 2018-01-13 02:05:49 +01:00
40dbf2fc00 Fix T53771: missing view pixels when rendering multiview + FSAA.
This never worked, it's not due to recent refactoring.
2018-01-12 23:57:45 +01:00
5bd9b12dc4 Cycles: adaptive subdivision support for panoramic cameras.
Adds the code to get screen size of a point in world space, which is
used for subdividing geometry to the correct level. The approximate
method of treating the point as if it were directly in front of the
camera is used, as panoramic projections can become very distorted
near the edges of an image. This should be fine for most uses.

There is also no support yet for offscreen dicing scale, though
panorama cameras are often used for rendering 360° renders anyway.

Fixes T49254.

Differential Revision: https://developer.blender.org/D2468
2018-01-12 23:57:45 +01:00
b603792fec Code refactor: adjust camera update for easier code sharing with kernel. 2018-01-12 23:57:45 +01:00
5cf032678f Code cleanup: remove test code to disable motion blur, no longer useful. 2018-01-12 23:57:14 +01:00
5a293de925 Draw Manager: Edit Mode Shader: Remove #ifdef GPU_INTEL
The problem with memory alignment on Intel GPUs does not happen anymore after the last shader changes.
2018-01-12 15:09:13 -02:00
49d51a1e62 Eevee: Fix motion blur alpha being > 1.0 2018-01-12 15:57:41 +01:00
2bbc287af1 Eevee: Fix Motion blur not working in OGL render.
Thanks to @sergey for the patch.

Also include some sexy line breaks.
2018-01-12 15:57:41 +01:00
9c76ec615a Fix T53759: Cycles / 2.8: Light position doesnt update in viewport render 2018-01-12 15:00:58 +01:00
Dalai Felinto
d931f6f785 Outliner: Harmless cleanup
There is even a chance the compilers handles this itself, but we should try to
use the internal storage as much as possible (and save 0.000001s in the process)
2018-01-12 09:07:16 -02:00
a33a5880f7 Fix bmesh.utils.face_join arg parsing 2018-01-12 14:51:15 +11:00
93d30d62e6 User Prefs: app-template option to hide the cursor 2018-01-12 12:45:56 +11:00
ff4c9d69ee User Prefs: add new flag for app-template options
For experimental options, outside the scope of typical preferences.

While templates are developed we might want to make changes
to behavior which aren't fully compatible with typical work-flows.

Instead of mixing these options in with current preferences
expose separately (we could even force disable them when templates
aren't int use)
2018-01-12 12:45:56 +11:00
322f0223d0 Cycles: option to make background visible through glass transparent.
This can be enabled in the Film panel, with an option to control the
transmisison roughness below which glass becomes transparent.

Differential Revision: https://developer.blender.org/D2904
2018-01-12 01:34:28 +01:00
cce280dd67 Cycles: add offscreen dicing scale and dicing camera.
The offscreen dicing scale helps to significantly reduce memory usage,
by reducing the dicing rate for objects the further they are outside of
the camera view.

The dicing camera can be specified now, to keep the geometry fixed and
avoid crawling artifacts in animation. It is also useful for debugging,
to see the tesselation from a different camera location.

Differential Revision: https://developer.blender.org/D2891
2018-01-12 01:34:07 +01:00
Dalai Felinto
de176b75b2 Fix T53764: vertical line glitch for collections with objects and collections
The code for vertical line was assuming that we necessarily neeeded vertical
lines for all the elements. Which is not true since we are not drawing
vertical and horizontal lines for collections.

Patch made in contribution with Philippe Schmid (@Quetzal).
2018-01-11 19:58:50 -02:00
2dbcc17897 Fix Cycles bevel normal baking having some random incorrect pixels.
The bevel and SSS code could result in NaNs in some cases, tweak the
formulas so this can't happen.
2018-01-11 22:30:31 +01:00
6b3d85fa51 Build: auto detection of libraries built by "make deps" on Linux.
Use the libraries if they exist in ../lib/linux_x86_64 or similar, so
that you can run "make deps && make full" to get a full static build.
Note that install_deps.sh is still the only officially supported way to
build Blender dependencies on Linux, but this may be useful to some.

Differential Revision: https://developer.blender.org/D2980
2018-01-11 22:30:31 +01:00
79b0bce890 Edit Mode Overlay Shaders: remove loose comment left by last commit 2018-01-11 18:28:11 -02:00
6a37f49211 Fix error weird sliding vertices appearing in edit mode with some Intel GPUs
Appear when zooming
2018-01-11 18:07:41 -02:00
8bff6f319a Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/multires.c
2018-01-11 20:19:18 +01:00
6104596587 Cleanup commented out OMP command. 2018-01-11 20:17:29 +01:00
6695e390c6 Nuke OMP from multires.c: forgot that one in previous commit.
Gives same kind of speedup too, 8.7ms with old OMP code, 2.7ms with new
one, with same level-4 multires monkey head.
2018-01-11 20:14:16 +01:00
90cd856ac3 Nuke OMP usage in multires.c.
New code is over three times quicker than old one here (e.g. Suzanne
subdiv level 4, 250k tris, threaded part is now 1.4ms instead of 4.5ms
with OMP).
2018-01-11 19:39:24 +01:00
da97b6930b DRW: Fix T53583 Armature instances not drawing.
Was due to the fact that the instances don't have a "static" obmat that can be referenced to use as a uniform.
Solution : precompute the full matrix for each bone and pass it as instance data. (theses are copied into a buffer and can be discarded right away)

Note: this could be optimized further and make only one drawcall (shgroup) to draw all bone instance of one type (vs. one call per armature).
2018-01-11 19:35:56 +01:00
Dalai Felinto
31782609f4 Fix T53340: Outliner collections collapsing when UNDO
This is not the original reported issue, but it is a second issye mentioned
that, the only one reminding.
2018-01-11 16:03:08 -02:00
6c4bc79134 Fix T51576: Blender crash when change to edit mode with some Intel GPUs
Differential Revision: D2995
2018-01-11 15:58:20 -02:00
713852affb Preparation step for nuking OMP from multires code.
Remove the critical OMP sections used to protect mem allocation.

First one can be done in a separate loop before main, parallelized one.

Second one only affect 'private' data, so we only need to ensure
guardedalloc thread safety is enabled.

This is committed as separated step to ease troubleshooting in case
bisecting becomes necesary.
2018-01-11 17:56:18 +01:00
c253fe5e87 Cleanup typo in comment. 2018-01-11 17:55:58 +01:00
5ef2be5f59 Eevee: DoF: Fix most color artifacts in render.
Use full 32bit floats buffers. This increase render time but also color fidelity.
2018-01-11 16:50:55 +01:00
494e4c0977 Eevee: Fix Depth of Field.
It was using a wrong blending function.
2018-01-11 16:50:55 +01:00
0142264508 Eevee: Lamps: Optimize lamps CPU/Memory usage.
Tests on my system with ~1200 objects with 128 shadow casting lamps (current max) show a significant perf improvment (cache timing : 22ms -> 9ms)
With a baseline with no shadow casting light at 6ms this give a reduction of the overhead from 16ms to 3ms.

This remove pretty much all allocations during the cache phase. Leading to a big improvement for scene with a large number of lights & shadowcasters.
The lamps storage has been replace by a union to remove the need to free/allocate everyframe (also reducing memory fragmentation).

We replaced the linked list system used to track shadow casters by a huge bitflag.
We gather the lights shadows bounds as well as the shadow casters AABB during the cache populate phase and put them in big arrays cache friendly.

Then in the cache finish phase, it's easier to iterate over the lamps shadow SphereBounds and test for intersection.

We use a double buffer system for the shadow casters arrays to detect deleted shadow casters.
Unfortunatly, it seems that deleting an object trigger an update for all other objects (thus tagging most shadow casting lamps to update), defeating the purpose of this tracking.
This needs further investigation.
2018-01-11 16:50:54 +01:00
Dalai Felinto
a08f687b91 Fix poll and name of collection link/unlink operators
Reported via IRC by Pablo Vazquez (venomgfx).
2018-01-11 12:45:00 -02:00
656b9a46b3 Merge branch 'master' into blender2.8 2018-01-11 15:14:30 +01:00
38d480fb54 Subsurf: Allow partial threading over geometry arrays
This helps avoiding threading overhead when having lots of system threads..
2018-01-11 15:06:56 +01:00
374c4f168d Mesh evaluate: Tweak threadability criteria
Gives measurable speedup on layout scenes from Spring.

Actual value for chunk size is a subject for more scientific research.
2018-01-11 15:04:13 +01:00
cdcdae663a Mesh deform: Tweak threadability criteria
Allow threading using subset of all available threads. Makes it faster to
evaluate lower resolution mesh but with complex deform groups and such.
2018-01-11 14:51:30 +01:00
c276fef413 Subsurf: Make copyFinalLoopArray() threaded
Gives about 40% speedup of object which has simple-ish deformation applied
on top of subdivided mesh.

This might easily happen with single character animation.
2018-01-11 14:49:32 +01:00
1255f572c7 Depsgraph: Make eval initialization more friendly for threading
Helps in cases of not very complex scenes and lots of system threads available.

A bit hard to measure change on it's own, it works best with the upcoming
changes and gives measurable improvements.
2018-01-11 14:48:49 +01:00
498ffef7b0 Subsurf: Use regular mutex instead of RW one
Mutex is now local to particular CCGDM, and guarding edge hash which is only
used by a single function only. There is no need to acquire read lock after
edge hash was created.
2018-01-11 14:38:58 +01:00
c36f4a7f7f Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenkernel/intern/blender.c
	source/blender/makesdna/DNA_ID.h
2018-01-11 14:35:36 +01:00
b415ed55a7 Fix critical issue with our DNA ID tags (two totally different tags having same value).
Nice typo from rBc4046e9082f6, tssk. ;)
2018-01-11 14:26:44 +01:00
cc63c8511c Fix static override (very stupid mistakes in code!) 2018-01-11 12:29:09 +01:00
de91f2389d Further fixes to new RNA props diff code.
Unfortunately, we cannot perform set/unset checks on 'resolved'
properties (i.e. from actual IDProperties pointers, and not virtual RNA
placeholders)... IDProps in RNA are rather challenging topic. :|

This should fully fix T53715: 2.8: Removing keymap items no longer works
2018-01-11 09:41:44 +01:00
0edda8e4ce Fix T53311: transform edge/normal orientation
When the edge is aligned with it's own normals,
transform orientation wasn't aligned with the edge.
2018-01-11 19:25:27 +11:00
6dd164a188 Fix T53755: Cycles OpenCL lamp shaders have incorrect normal. 2018-01-11 08:48:32 +01:00
717090f40e UI: option not to show screen splitting widgets
Request for simplified Blender template,
this may be extended to limit access to other UI changes
that could be pressed by accident.
2018-01-11 16:10:46 +11:00
9c91c75ea6 Merge branch 'master' into blender2.8 2018-01-11 13:24:41 +11:00
9d62e6e782 UI: don't draw outline when it's not calculated
Outline drawing was running even when there were no verts to draw.
Causes an assert in 2.8.
2018-01-11 13:23:55 +11:00
Stefan Werner
25b794a39d Cycles: support animated object scale in motion blur.
This was disabled previously due to CUDA compiler bugs, see T32900.

Differential Revision: https://developer.blender.org/D2937
2018-01-11 02:58:29 +01:00
ac2ebf9c54 Fix T53455: Object disappear w/ TrackTo constraint
Regression caused by own commit 16fbb47c88,
this is really an edge case though since calling normalize twice fixes.
2018-01-11 10:57:30 +11:00
d0cc5d8948 Fix T53752: Draw curve fails w/ stylus 2018-01-11 10:23:52 +11:00
6112cde3f9 Merge branch 'master' into blender2.8 2018-01-11 10:19:00 +11:00
f330005266 Cleanup: BKE naming conventions for datablock add/localize
Conventions were already followed nearly everywhere.
2018-01-11 10:01:01 +11:00
c27cab268b Fix Windows compiler warning using WITH_CYCLES_NATIVE_ONLY. 2018-01-11 00:00:48 +01:00
d0892a6648 Fix issue with moving CUDA memory to host and multiple devices.
This is not expected to fix all issues. Also adds some more details
to error reporting to investigate failures.
2018-01-11 00:00:48 +01:00
0f4b46cee6 Fix T53692: OpenCL multi GPU rendering not using all GPUs.
Ensure each OpenCL device has a unique ID even if the hardware ID is not
unique for some reason.
2018-01-11 00:00:48 +01:00
Julian Eisel
3f16810150 Cleanup: Naming, avoid passing bContext to low-level function, etc 2018-01-10 23:02:10 +01:00
Julian Eisel
748e95ad50 Fix crash when deleting collections
With factory settings, steps to reproduce were:
* Select "Collection 1" (in "RenderLayer")
* Delete
It might crash at this point, although maybe this crash is ASAN only.

However, this was also doing some weird things that I've corrected now. It
called outliner_build_tree in an operator callback. This should only be
called in the main redraw function or so, not in regular handlers.
Instead, we manually cleanup the tree to keep it valid.
2018-01-10 22:45:44 +01:00
76bdd40bfd Subsurf: Loop array should not be called mv
mv is a mesh vertex, not loop.
2018-01-10 14:58:49 +01:00
fca202566f Subsurf: Remove increment of unused variable 2018-01-10 14:58:09 +01:00
181124ad13 Fix compilation error
Seems of new padding were added in 2.8 branch.
2018-01-10 14:15:13 +01:00
5d38c14116 Merge branch 'master' into blender2.8 2018-01-10 13:22:03 +01:00
2737837b09 Fix wrong data type used for undo memory limit 2018-01-10 13:20:36 +01:00
f21f18b572 Task scheduler: Use const qualifier in callbacks for parallel range 2018-01-10 12:53:59 +01:00
5614193745 Task scheduler: Use restrict pointer qualifier
Those pointers are never to be aliased, so let's be explicit about this and hope
compiler does save some CPU ticks.
2018-01-10 12:49:51 +01:00
518c65460e Task scheduler: Use more const qualifiers 2018-01-10 12:27:43 +01:00
f68b2fd233 RNA: Increase memory limit settings to their possible max on platform
This is quite common to have 64GB memory now, and even 128. There is no reason
to add any artificial caps on the cache and undo memory here. We can not protect
against using too much memory in one cases and allow use of full computer
potential in others.

Now 32 bit will use 2GB max (as it used to be), but 64bit will use whatever
number of megabytes fits into integer.

Reviewers: campbellbarton, mont29

Subscribers: sebastian_k

Differential Revision: https://developer.blender.org/D2972
2018-01-10 11:09:10 +01:00
f0610563ee math utils: Add size_t version of min and max functions 2018-01-10 11:06:44 +01:00
f59303bead Fix color for manipulator drawing
Was drawing black after the first draw call.
For now set the shader before each draw call,
noted as TODO to investigate a nicer way to handle.
2018-01-10 20:50:14 +11:00
2b56faebe5 Merge branch 'master' into blender2.8 2018-01-10 19:58:05 +11:00
18f53d8822 Cleanup: comment block alignment 2018-01-10 19:57:02 +11:00
bc02c5de49 Alternate fix for brush user count
This reverts change to BKE_brush_add,
callers now remove the extra user.

Note this isn't very convenient for callers but
is consistent with other ID types.

In the future we will probably remove this and have new
ID's created with zero users.
2018-01-10 19:34:34 +11:00
3f837341c8 Correction to brush user commit
RNA API was compensating for the extra user.
2018-01-10 18:31:54 +11:00
98d89cef6b Fix background_job template
Update attribute and use empty file operator
2018-01-10 17:50:41 +11:00
6e6b79de35 Fix brush user count
New brushes had 2 users on adding.
Caused assert removing them after.
2018-01-10 17:45:34 +11:00
5ff33ecdf0 Merge branch 'master' into blender2.8 2018-01-10 14:01:09 +11:00
5c3dc01f54 Draw Manager: Edit Mode: Curve: uniforms were not being setted 2018-01-10 00:40:02 -02:00
7d865bc4ab Fix T53748: uniform globalsBlock was not being added was not being added to the shaders of the curves handles 2018-01-10 00:08:51 -02:00
cacba951ea Correct typos 2018-01-10 12:43:29 +11:00
fdd3d969a6 Fix T53491: Absolute tablet motion detection fails
When using a tablet, detecting absolute motion only worked
when activating a tool with the tablet.

Pressing Enter to run a tool for e.g. would use relative motion.

Now store is_motion_absolute in the event,
set for new events based on the most recent motion events.
2018-01-10 12:41:45 +11:00
9aada45e52 fix t53701 minimal changes to get it working right 2018-01-10 01:51:04 +01:00
3c6e19b30b Curve/Surface Display: UV support 2018-01-10 10:11:32 +11:00
0f6ed7d111 Fix (unreported) potential crash.
RNA_pointer_as_string could return NULL instead of a valid string in some cases.
2018-01-09 19:51:50 +01:00
a0655ed487 Eevee: Fix AO in planar reflections. 2018-01-09 19:01:24 +01:00
8aaf7bc438 Eevee: Fix Planar probe refresh. 2018-01-09 18:59:13 +01:00
5fe87a0a8c Task scheduler: Use single thread branch when range fits into single chunk 2018-01-09 18:10:47 +01:00
4a3b303bb0 Task scheduler: Fix wrong tasks calculation when chunk size is too big 2018-01-09 18:07:34 +01:00
9135530f79 Eevee: Support for dupli lamps without shadows. 2018-01-09 18:01:56 +01:00
9f94f17ea4 Eevee: Fix crash with volumetrics. 2018-01-09 17:29:56 +01:00
6deb908a5c Merge branch 'master' into blender2.8 2018-01-09 16:15:33 +01:00
932d448ae0 Task scheduler: Use const qualifiers in parallel range 2018-01-09 16:09:33 +01:00
8cffb0a141 Task scheduler: Avoid over-allocation of tasks for parallel ranges
This seems to only cause extra rthreading overhead on systems with 10s of
threads, without actually solving anything.
2018-01-09 16:09:33 +01:00
c4e42d70a4 Task scheduler: Add minimum number of iterations per thread in parallel range
The idea is to support following: allow doing parallel for on a small range,
each iteration of which takes lots of compute power, but limit such range to
a subset of threads.

For example, on a machine with 44 threads we can occupy 4 threads to handle
range of 64 elements, 16 elements per thread, where each block of 16 elements
is very complex to compute.

The idea should be to use this setting instead of global use_threading flag,
which is only based on size of array. Proper use of the new flag will improve
threadability.

This commit only contains internal task scheduler changes, this setting is not
used yet by any areas.
2018-01-09 16:09:33 +01:00
3144f0573a Task scheduler: Simplify parallel range function
Basically, split it up and avoid extra abstraction level.
2018-01-09 16:09:33 +01:00
4c4a7e84c6 Task scheduler: Use single parallel range function with more flexible function
Now all the fine-tuning is happening using parallel range settings structure,
which avoid passing long lists of arguments, allows extend fine-tuning further,
avoid having lots of various functions which basically does the same thing.
2018-01-09 16:09:33 +01:00
d2708b0f73 Task scheduler: Get rid of extended version of parallel range callback
Wrap all arguments into TLS type of argument. Avoids some branching and also
makes it easier to extend things in the future.
2018-01-09 16:09:33 +01:00
1cab3be7a7 Significant step toward supporting IDProperties in new RNA diff code.
Still not fully working, more work TODO (IDProps are rather tedious to
handle in RNA... :/ ).

Partial fix of T53715: 2.8: Removing keymap items no longer works.
Some shortcuts can now be edited/deleted again, but some remain
mysteriously frozen!
2018-01-09 15:54:33 +01:00
2ee5e05107 DRWInstanceData: Bump the max data size. 2018-01-09 15:37:28 +01:00
35ac496dbd Gawain: Fix codestyle. 2018-01-09 15:37:00 +01:00
2bb08f0ad2 DRW & GPUViewport: Cleanup unused code. 2018-01-09 14:54:11 +01:00
377915b081 DRW: Make use of DRWInstanceData.
This modify the selection code quite a bit but it's for the better.
When using selection we use the same batching / instancing process but we draw each element at a time using a an offset to the first element we want to draw and by drawing only one element.
This result much less memory allocation and better draw time.
2018-01-09 14:54:11 +01:00
aa0097ad5e DRW: Add instance data memory manager.
This is a special memory manager that keeps memory blocks ready to send as vbo data.
Since we loose which memory block was used each DRWShadingGroup we need to redistribute them in the same order/size to avoid to realloc each frame.
This is why DRWInstanceDatas are sorted in a list for each different data size.
2018-01-09 14:54:11 +01:00
2237ee3ed7 Gawain: VBO: Add possibility to use external datablock.
Adds the possibility to specify the data buffer directly and precise ownership.
By not passing ownership to gawain the memory block can be reused.
2018-01-09 14:54:11 +01:00
b300fa4923 Gawain: Modify batch draw function to work with ranges.
This enables to draw the same vbo but only with a selected range. (useful for selection with instancing/batching)
2018-01-09 14:54:11 +01:00
f5d64b59f5 Fix T53691: Motion Tracking Object Solver Constraint doesn't work as Bone Constraint 2018-01-09 14:27:19 +01:00
bf8137994d Depsgraph: Move special handling of tracking constraints to a dedicated function 2018-01-09 14:11:23 +01:00
d32878b425 Depsgraph: Perform early check on constraint info NULL 2018-01-09 13:09:59 +01:00
83e84b2c2c Merge branch 'master' into blender2.8 2018-01-09 12:52:13 +01:00
ce0fcf1378 Correct error in last commit (versioning) 2018-01-09 15:17:00 +11:00
6554207841 Add deform axis for Simple Deform modifier
D2989 by @dmarra w/ own edits
2018-01-09 15:09:55 +11:00
375d27f230 Curve Edit Mode: Use curve handle theme colors 2018-01-09 13:30:30 +11:00
850f73638c install_deps: Fix OCIO always re-cloning its whole git repository. 2018-01-08 16:34:34 +01:00
c8a989d644 No groping in Blender's Tracker!
This a small cleanup of something which I think is just a typo anyway.

With all the recent talks of harrassment and groping, I think we better avoid
that within our source code! :)

Reviewers: sergey

Reviewed By: sergey

Tags: #motion_tracking

Differential Revision: https://developer.blender.org/D2979
2018-01-08 14:12:15 +01:00
3ee2ed3049 Fix T53612: Blender crashes on CleanTracks with 'DELETE_SEGMENTS' and a disabled marker
Simple fix, which is totally safe for 2.79a!
2018-01-08 14:10:50 +01:00
c26da06ae6 Merge branch 'master' into blender2.8 2018-01-08 09:39:32 +01:00
96e507d989 Fix T53509: Datablock ID Properties attached to bpy.types.Material are not loaded.
Stupid mistake in material reading code, thanks to Simon Wendsche (@BYOB) for the investigation and fix!

To be backported to 2.79a.
2018-01-08 09:37:56 +01:00
a7b4f98e73 Fix T53713: User remap failed w/ texface images 2018-01-08 16:58:58 +11:00
87607254d6 (Nodes) Display image name if any in the Image and Texture Image node title 2018-01-07 22:29:25 +01:00
add580beee Fix T47212: Luminance Key not working with HDR and out-of-gamut ranges.
Differential Revision: https://developer.blender.org/D2981
2018-01-06 16:41:39 +01:00
0e59f2b256 Fix T47212: incorrect luma coefficients for Luminance Key node.
Differential Revision: https://developer.blender.org/D2982
2018-01-06 16:41:33 +01:00
c6abf41f71 Fix T53650: remove hard limits on force field size and max distance.
Differential Revision: https://developer.blender.org/D2987
2018-01-06 16:15:13 +01:00
Dalai Felinto
84d4476eb1 Outliner: Rename "Master Collection Tree" to "Collections"
This is part of T53495.
2018-01-05 19:17:38 -02:00
Dalai Felinto
fb4cd136a7 Outliner: Support multiple-objects drag'n'drop into collections
We now can drag multiple objects at once in the outliner. You we restricted to
working within a single outliner. Be sure to drag from the objects name, not
from its icon (otherwise it will try to parent it).

We don't use the same drag'n'drop system as IDs here. Which although I dislike
allowed for this solution to be local, and not dependent on the entire
drag'n'drop system of Blender.

This is a feature Andy Goralczyk has requested a long time ago.
Kudos for him for his request.
2018-01-05 18:23:55 -02:00
Dalai Felinto
9d134a22c2 Cleanup: DNA comment regarding ID for collections in outliner 2018-01-05 17:32:22 -02:00
Dalai Felinto
a768aa6ec8 Fix drag and drop in outliner for scene collections
This technically reverts 176698b2eb.

Drag and drop for scene collections requires id for its poll function. However
we were passing the collection as id pointer for outliner_add_element
(which is ok since the function doesn't require a real ID).

I couldn't reproduce the original issue tackled by the forementioned commit so
I'm going ahead and bringing drag and drop back for scene collections.

Note: We already pass the ID for view layer collections as well since we brought
collections into groups.
2018-01-05 13:58:49 -02:00
Dalai Felinto
c5e01edeca Outliner: Fix for restriction columns
This is a partial revert of 1f5106de61.

First and firemost, for groups I was checking the wrong flag
(soops->flag & SO_GROUPS) instead of (soops->outlinevis == SO_GROUPS).

Second, the columns were entirely broken for things like Orphan Data.

Third, I tried to have different columns for different `outlinevis`, but we have
bones with only visible and select, modifiers with visible and render, render
passes with enable and another value ... I would rather stay away from this mess
at the moment, and stick to the more obvious bug fix.

Finally, there is a bug (not addressed here) where the whole line is selected,
regardless of the restriction column area. It should be fixed separately.
2018-01-05 11:42:10 -02:00
d73f74793e Eevee: Make Ogl render sampling more correct
Result is less noisy ogl renders.

What this patch does:
- the draw loops gets accumulated into the output buffer.
- disable TXAA persmat jittering in ogl render since ogl render already does that.
- make noise texture update correct accross all draw loops. Previously it was reset between each FSAA samples.
2018-01-05 10:25:28 +01:00
9a00d57371 DRW: Add viewport argument to DRW_draw_render_loop_offscreen
This way we can have persistent data accross different calls.
2018-01-05 10:25:28 +01:00
6eb89027c3 Fix T53696: Compositor HSV limits changed 2018-01-05 20:13:17 +11:00
9be32ac5fe Fix manipulator crash when modal operator doesn't run 2018-01-05 14:53:10 +11:00
Dalai Felinto
a9e3ac906e Merge remote-tracking branch 'origin/master' into blender2.8 2018-01-04 15:57:48 -02:00
Dalai Felinto
95d83b9b23 Fix leak when rendering OpenGL animations
We were duplicating rectf twice :/

Patch by Clément Foucault.
2018-01-04 15:56:43 -02:00
0becc8a7dd Fix T52953: Crash removing material 2018-01-04 21:35:09 +11:00
205978a489 Eevee: Fix AO applied twice on glossy shader when using OGL render
Seems to be a compiler bug. This is really strange.
I just rephrased the whole thing and it appears to work.
2018-01-04 10:43:54 +01:00
4df11e3c70 Eevee: SSR: Fix ssr nor working in ogl render. 2018-01-04 10:43:54 +01:00
5ab2fc65c6 DRW: Fix boolean uniform lenght.
Boolean uniform needs to be 4bytes long for opengl.
Use "int" for every bool you want to pass as a uniform.
2018-01-04 10:43:54 +01:00
b4ad0151c3 Eevee: Fix issues with alpha blending
- Hashed Alpha materials were outputing their alpha values even if the final pixel has no blending and thus no transparency.
- Opacity was not clamped when using "add closure" nodes.
2018-01-04 10:43:54 +01:00
bbf810f969 DRW: Fix incorrect blending functions. 2018-01-04 10:43:54 +01:00
2b678db3fe Eevee: Make the background black when rendering without sky.
This prevent some bad blending when using transparent materials.
2018-01-04 10:43:54 +01:00
cbe9098bf9 OGL Render: Use float buffer instead of byte buffer.
We need to remove all transform to display during rendering for this to work. The float rect is then color managed when displayed.

This makes all interface colors wrongly displayed because they should be color managed when rendering.
2018-01-04 10:43:54 +01:00
c79216d77d GPU_offscreen: Add option for high bit depth.
This way we can render in HDR and read the real pixel values.
2018-01-04 10:43:54 +01:00
6b2989ae75 DRW: Fix small changes to transparent background.
Fix changes introduced e3ef782af5

Eevee is in charge of rendering so it should be its task to have it's buffer initialized
2018-01-04 10:43:54 +01:00
5a6a819b5d Merge branch 'master' into blender2.8 2018-01-04 10:36:50 +01:00
727aab5af4 Fix uninitialized stack use in rna diff override 2018-01-04 16:15:31 +11:00
457dc8d12c Fix T53586: Surfaces collapse when joined 2018-01-04 16:01:27 +11:00
9b65560934 Fix T53637: Keymap from app-template ignored
Addon's were also ignored
2018-01-04 14:19:00 +11:00
7fc1f42aae tests: limit public API in view_layer_common 2018-01-04 11:57:45 +11:00
ea55af2163 tests: replace boiler-plate with util function
This crept back in somehow!
2018-01-04 11:28:46 +11:00
Dalai Felinto
e1cbac715a Fix FOREACH_SCENE_COLLECTION/FOREACH_SCENE_OBJECT for nested collections
This fixes any function that relied on these iterators such as:
* Outliner Same Type
* Metaballs
* scene.objects

We were not considering the collections when there was collections nested
to the collections nested to the master collection.

It includes a unittest.
2018-01-03 19:33:00 -02:00
Dalai Felinto
10f0635d32 Outliner/Collections: Remove selected objects operator
This is part of T53495.
2018-01-03 18:27:42 -02:00
Dalai Felinto
eaf559d52a Outliner/Collections: Add selected objects operator
This is part of T53495.
2018-01-03 18:27:06 -02:00
Dalai Felinto
d9b4d6ee5a Outliner: Right mouse menu for collections editing 2018-01-03 12:28:01 -02:00
8a72c3baef Static assert for correct strings from context mode enum.
Adding new context modes requires adding a string in CTX_data_mode_string,
but there is no error when omitting this other than panels using
incorrect contexts. The static assert should help detect simple
missing strings at least to avoid confusing errors.
2018-01-03 13:15:33 +00:00
f20bb6c63f Merge branch 'master' into blender2.8 2018-01-04 00:09:10 +11:00
25418be97e build deps: llvm new website download locations 2018-01-03 14:52:25 +02:00
be40389165 Merge branch 'master' into blender2.8 2018-01-03 23:44:47 +11:00
Dalai Felinto
ffb2c40176 New API function to call an existing menu
Thanks Campbell Barton for the help and review.
This is for Blender 2.8, so we are not using this function yet.
2018-01-03 10:17:59 -02:00
e981a7de31 Missing from last commit 2018-01-03 22:01:40 +11:00
2f8c2572ed Fix T53632: Objects outside scene shown in popup
Only show objects in current scene when not pinned.

This commit adds a filter argument to id-template
since we may want to filter by other criteria.
2018-01-03 21:54:02 +11:00
cbc7aa80d4 Fix T53678: Smart Project UV margin ignores units 2018-01-03 16:10:41 +11:00
060fdb49d6 Fix an error on last commit
`count` here is multiplied by 4.
2018-01-02 23:44:01 -02:00
2a57a46441 Fix crash when you change the curve resolution in Edit Mode of the Blender Render engine
Same problem as previous commit, but now in `drawobject.c`.
Also added a comment to the equivalent line in `draw_cache_imp_curve.c`.
2018-01-02 23:31:28 -02:00
6c46dff50d Curve Edit Mode: Fix crash when the U-resolution of the curve is changed
`normal_len` did not follow the value of the loop that is executed to add the vertices, being different from the vbo size
2018-01-02 23:09:51 -02:00
b3c4e30a7c Fix: MSVC2013 compile problems with the "inline" keyword 2018-01-03 12:59:10 +13:00
c621832d3d Cycles: CUDA support for rendering scenes that don't fit on GPU.
In that case it can now fall back to CPU memory, at the cost of reduced
performance. For scenes that fit in GPU memory, this commit should not
cause any noticeable slowdowns.

We don't use all physical system RAM, since that can cause OS instability.
We leave at least half of system RAM or 4GB to other software, whichever
is smaller.

For image textures in host memory, performance was maybe 20-30% slower
in our tests (although this is highly hardware and scene dependent). Once
other type of data doesn't fit on the GPU, performance can be e.g. 10x
slower, and at that point it's probably better to just render on the CPU.

Differential Revision: https://developer.blender.org/D2056
2018-01-02 23:50:18 +01:00
6699454fb6 Cycles: make CUDA code a bit more robust to host/device alloc failures.
Fixes a few corner cases found while stress testing host mapped memory.
2018-01-02 23:46:19 +01:00
Dalai Felinto
07de8eff77 Layers/Collections: Fix crash when deleting collection
If the collection to be deleted has a nested collection that is directly linked
to a view layer, we were getting a crash.
2018-01-02 18:19:26 -02:00
Dalai Felinto
8300b5e539 Layers: Fix operator_context unittest
This was broken since 70cdc8412c when we changed the requirement for context
scene collection to be part of context view layer.
2018-01-02 17:42:23 -02:00
Dalai Felinto
f3566235ca Layers: Fix collection_rename unittest
This was broken since c9cb5dc3da when we supported same name for
non-sibling collections.
2018-01-02 16:59:30 -02:00
Dalai Felinto
a9fe94245b Outliner: Master Collection always expanded
This is part of T53495.

This makes sure the master collection is always expanded and you don't even get
the expand/collapse icons for it.

This is only for the Collecions (currently Master Collection Tree) option, not
for active view layer.
2018-01-02 14:40:33 -02:00
Dalai Felinto
e1238bcced Outliner: Always show the master collection on top of the tree
This reverts commit 0d0d68d39d with extra changes.

This is part of T53495.
2018-01-02 13:10:45 -02:00
Dalai Felinto
e8c737d7c2 Outliner/Collections: Don't link a collection after creation 2018-01-02 13:10:45 -02:00
e84966ac42 nstall_deps: llvm downloads new website location
Patch by Lucas Walter (@lucasw), thanks.

Reviewers: mont29

Reviewed By: mont29

Subscribers: mont29

Differential Revision: https://developer.blender.org/D2983
2018-01-02 15:23:45 +01:00
e59cf13b8c fix T53230: avoid Nullpointer problems in Collada Exporter 2018-01-01 15:02:26 +01:00
ac934efc5e Build: fix make deps TBB on Linux, older versions don't support GCC 7. 2017-12-30 00:07:33 +01:00
6a225a283e Build: fix make deps OpenSubdiv build on Linux. 2017-12-29 22:53:32 +01:00
Dalai Felinto
bbbdb27d65 Outliner/Collection: Interface for Master Collection Tree
This is part of T53495.

This adds an Edit menu and remove the buttons.
2017-12-29 13:38:28 -02:00
Dalai Felinto
4d08ef822c Outliner/Collection: Operator to delete selected collections
This is part of T53495.

This operator is actually using existing code. The only new thing about it is
that it has a shortcut.

It will be exposed in the UI soon together with the nested collection operator.
2017-12-29 13:37:27 -02:00
Dalai Felinto
8252a414d8 Outliner/Collection: Operator to create (nested) collections
This is part of T53495.

This operator is intended for the outliner when viewing Collections (at the moment, Master Collection Tree).
It has a shortcut "C", and will be added to a menu shortly.
2017-12-29 13:36:55 -02:00
Dalai Felinto
a6c69ca57f Fix T53513: Particle size showing in multiple places
Technically this was introduced in 01b547f993 when
exposing size and randomness for particles.

This "fixes" makes sure particle size and size randomness is always in the
Render panel when it affects the particle system (i.e., always unless using
advanced hair or hair that is not rendering groups/objects).
2017-12-29 13:17:55 -02:00
Dalai Felinto
f2a24afe8c Fix T53647: Outliner crashes when active object is deleted
Based on patch by Philipp Oeser (lichtwerk).
2017-12-29 09:55:13 -02:00
08b063a19f Fix T53639: text sequence strips no stamped into render.
Differential Revision: https://developer.blender.org/D2977
2017-12-29 00:25:29 +01:00
7a6967cbe6 Fix mistake in previous fix for T53600, shows we really need a smarter solution. 2017-12-29 00:07:49 +01:00
17f1ce4d4f Fix T53630: Effect strips not displaying Input data.
Fix T52977: Parent bone name disappeared in the UI in pose mode.

Regression caused by own rBc57636f060018. So instead of changing widget
type, just flag it as disabled.

Note that core of the issue is elsewhere though - there is absolutely no
reasons to have a search widget for pointers we cannot change nor
search! But fixing this is not really top priority, one of the many
glitches of our UI code, so think we can live with current code.

To be backported to 2.79a.
2017-12-28 17:57:18 +01:00
Dalai Felinto
2b7f36300e RNA cleanup: Argument names + tooltip for scene_collection.collections.remove() 2017-12-28 12:53:54 -02:00
Dalai Felinto
70cdc8412c Context: Fix scene_collection
We now allow for scene collection that is not currently linked to view layer.
2017-12-28 12:24:13 -02:00
Dalai Felinto
dfd7b0d07a RNA: scene_collection.collections.new() name optional
We already have a fallback naming system when no naming is given, we should use that.
2017-12-28 12:23:37 -02:00
Dalai Felinto
8620dd7adf Cleanup after collection rename commit
Related to c9cb5dc3da.
2017-12-28 09:23:35 -02:00
Dalai Felinto
c9cb5dc3da Collections: Allow collections from different "parents" to have the same name
This allows users to have "Support", "Rig", "Characters" collections nested to
different collections without having to resort to "House.Rig", "House.Characters"
or "Rig.001", "Characters.003" :/

This is part of T53495.
2017-12-27 19:45:37 -02:00
Julian Eisel
7dee0bbf06 Fix missing redraws when changing active view-layer or its name
Also removed unnecessary `struct` keywords.
2017-12-27 17:08:00 +01:00
Dalai Felinto
110373de6a Fix T53638: View layer renaming crashes 2/2
This fixes renaming the view layer via Python.

This bug was introduced originally in 3a95bdfc65. Although I suspect it was
around for longer, since this commit didn't touch this part of the code.

But basically we need the id of the RNA property to be the one that owns
the data (view layer).
2017-12-27 13:39:28 -02:00
Dalai Felinto
b517dc9b2d Fix T53638: View layer renaming crashes 1/2
This fixes renaming via the interface.

This bug was introduced originally in 9515737b55. We need the id of the RNA
property to be the one that owns the data (view layer).

So it can't be the window's id, but the scene one instead.
2017-12-27 13:37:38 -02:00
Dalai Felinto
bd80ace2da Depsgraph: Fix copy-on-write assert when freeing Freestyle config
We were bumping user count when duplicating viewlayer and its freestyleconfig
depending on the flag, however when freeing we were always decreasing user
count.

This fixes this and get rid of the assert when running:
`--factory-startup --enable-copy-on-write`

And closing Blender.
2017-12-26 13:31:48 -02:00
948515c21a Fix T53600: Cycles shader mixing issue with principled BSDF and zero weights.
SVM nodes need to read all data to get the right offset for the following node.
This is quite weak, a more generic solution would be good in the future.
2017-12-25 23:59:20 +01:00
e8e92dffed Fix T53607: Cycles normal map baking problem when there is no bump. 2017-12-25 23:05:45 +01:00
7e4568a939 Cleanup - Various style/typo fixes 2017-12-23 23:54:05 +13:00
Dalai Felinto
fe1e2c2f89 Collections: deletea collection move objects to master collection if users=0
The mental model is that a scene collection is a small wrap on top of the master
collection, so all objects are in the master collection at all times.

When we remove a collection there is no reason to remove an object. So if the
object was not linked to any other collection, we add link it to the master one.
2017-12-22 19:18:21 -02:00
d130c66db4 Fix scalability issue in threaded code of Mesh normals computation.
We tried to do as much as possible in a single threaded callback, which
lead to using some nasty tricks like fake atomic-based spinlocks to
perform some operations (like float addition, which has no atomic
intrinsics).

While OK with 'standard' low number of working threads (8-16), because
collision were rather rare and implied memory barrier not *that* much
overhead, this performed poorly with more powerful systems reaching the
100 of threads and beyond (like workstations or render farm hardware).

There, both memory barrier overhead and more frequent collisions would
have significant impact on performances.

This was addressed by splitting further the process, we now have three
loops, one over polys, loops and vertices, and we added an intermediate
storage for weighted loop normals. This allows to avoid completely any
atomic operation in body of threaded loops, which should fix scalability
issues. This costs us slightly higher temp memory usage (something like
50Mb per million of polygons on average), but looks like acceptable
tradeoff.

Further more, tests showed that we could gain an additional ~7% of speed
in computing normals of heavy meshes, by also parallelizing the last two
loops (might be 1 or 2% on overall mesh update at best...).

Note that further tweaking in this code should be possible once Sergey
adds the 'minimum batch size' option to threaded foreach API, since very
light loops like the one on loops (mere v3 addition) require much bigger
batches than heavier code (like the one on polys) to keep optimal
performances.
2017-12-22 22:12:23 +01:00
Julian Eisel
8ed1c61642 Correction to previous commit: Pass MakePrimitiveData to make_prim_finish 2017-12-22 18:53:26 +01:00
Julian Eisel
10390ca057 Cleanup: Encapsulate primitive creation data into struct, remove unused argument
Should make it easier to add new and modify existing parameters.
2017-12-22 18:27:25 +01:00
Julian Eisel
430070938c Fix manipulators not updating when changing workspace view-layer
There are more issues when changing view-layer (esp. with edit-mode).
2017-12-22 17:04:00 +01:00
6efd58dd3e Task scheduler: Clarify why do we need an atomic add of 0 2017-12-22 16:37:25 +01:00
Dalai Felinto
c08dac000f Collection: Name collection based on parent's name
So they are:

House
 -> House 1
 -> House 2
 -> ...

The exception is when the parent collection is the master collection. In this case we get:

Master Collection
 -> Collection 1
 -> Collection 2
 -> ...

This is part of "T53495: View layer and collection editing - Design Task"
2017-12-22 11:41:09 -02:00
870840e8b7 Subsurf: Avoid possible use of partially initialized edge hash 2017-12-22 12:51:00 +01:00
df0ecd73af Subsurf: Avoid global lock for loops and orig index layers
This is a bit annoying to have per-DM locking, but it's way better (as in, up to
4 times better) for playback speed when having lots of subsurf objects,
2017-12-22 12:50:57 +01:00
50f1c9a8af Task scheduler: Start with suspended pool to avoid threading overhead on push
The idea is to avoid any threading overhead when we start pushing tasks in a
loop. Similarly to how we do it from the new dependency graph. Gives couple of
percent of speedup here, but also improves scalability.
2017-12-22 12:25:11 +01:00
Dalai Felinto
fec3be6b54 T53610: Crash opening file with linked particles
I could done a subversion bump, but I found a safe way to avoid it.
It leads a bit of an ugly code, but once we bump the subversion
next time we can clean it up easily.
2017-12-21 23:25:27 -02:00
d2ea9c2063 Fix typo in previous commit 2017-12-21 17:19:07 +01:00
a7efdc14a1 Merge branch 'master' into blender2.8 2017-12-21 17:17:27 +01:00
c66983c5c8 Depsgraph: Sort and clam number of statistics entries
Makes log easier to read.
2017-12-21 17:16:18 +01:00
Dalai Felinto
b89f2276e5 Implement duplicator viewport/render visibility options
This allows a duplicator (as known as dupli parent) to be in a visible
collection so its duplicated objects are visible, however while being
invisible for the final render.

An object that is a particle emitter is also considered a duplicator.

Many thanks for the reviewers for the extense feedback.

Reviewers: sergey, campbellbarton

Differential Revision: https://developer.blender.org/D2966
2017-12-21 13:43:24 -02:00
103dd66057 Merge branch 'master' into blender2.8 2017-12-21 16:36:02 +01:00
885bb5b137 Depsgraph: Bring timing statistics to the new dependency graph
This statistics is only collected when debug_value is different from 0.

Stored in depsgraph node itself, so we can always have access to average data
and other stats which requires persistent storage. This way we also don't waste
time trying to find stats from a separately stored hash map.
2017-12-21 16:33:22 +01:00
d988eae6f9 Depsgraph: Make it more clear that we dump relations into graphviz
We might implement other things to dump into graphviz, so better to
start having explicit names.
2017-12-21 16:33:22 +01:00
b7121639e9 Depsgraph: Simplify some functions in evaluaiton 2017-12-21 16:33:22 +01:00
f0a5dc63ff Depsgraph: Simplify evaluation function 2017-12-21 16:33:22 +01:00
bf1dc39679 Fix T53567: Negative pixel values causing artifacts with denoising
Now negative color values are clamped to zero before the actual denoising.
2017-12-21 14:24:23 +01:00
b38c083259 Merge branch 'master' into blender2.8 2017-12-21 12:17:48 +01:00
41b29c69c0 Depsgraph: Fix mistake in previous commit 2017-12-21 12:16:12 +01:00
00062e08ee Merge branch 'master' into blender2.8 2017-12-21 12:00:06 +01:00
6e47680077 Depsgraph: Remove confusing declaration of node method
it is only to be implemented for operation node.
2017-12-21 11:58:48 +01:00
681a102800 Depsgraph: Remove one of temporary tags in the node
No real reason to have that, better to free up space for something much more
awesome!
2017-12-21 11:47:34 +01:00
5df4950073 Depsgraph: Cleanup, move implementation away from header 2017-12-21 11:35:10 +01:00
9f0d067c2e Merge branch 'master' into blender2.8 2017-12-21 11:17:34 +01:00
f6b2fbb029 Depsgraph: Remove evaluation priority completely 2017-12-21 11:15:21 +01:00
f906f5cc58 Depsgraph: Remove eval priority from debugger
This needs to be redone anyway, to correspond to possibly new priorities
calculated for evaluaiton.
2017-12-21 11:14:39 +01:00
0ed3a72012 Depsgraph: Remove unused component context functions 2017-12-21 10:37:00 +01:00
Dalai Felinto
e3ef782af5 Fix for T53599: OpenGL render with transparent background
I had to make Eevee draw its scene in the scene pass (before it was doing it
in the background pass). This is not ideal since reference images require
a separation between scene and background.

But it's the best way to solve it now. Clay is working fine.
2017-12-20 16:05:47 -02:00
93b2871cf5 Depsgraph: Remove node class stored in both type info and node
This is something deliver form node type, there is no reason to try cache it
anywhere, especially since it's not used in any performance critical code.

Lighter weight dependency graph is what we want.
2017-12-20 17:54:52 +01:00
5650fe77e4 Cycles: Cleanup, indentation 2017-12-20 17:42:50 +01:00
03a589125f Merge branch 'master' into blender2.8 2017-12-20 16:46:28 +01:00
e5b92cd63e Depsgraph: Remove unused incldues 2017-12-20 16:45:10 +01:00
9eb46fc22b Fix compilaiton error in debug mode
The structure was just calloc-ed, no need to check for anything. It's all zeroes!
2017-12-20 16:41:51 +01:00
a52452c043 Merge branch 'master' into blender2.8 2017-12-20 16:40:49 +01:00
3474db4b37 Depsgraph: Move ID node to own file 2017-12-20 16:35:48 +01:00
f87c157f22 Depsgraph: Move time source node to own file 2017-12-20 16:29:13 +01:00
b2ef042793 Depsgraph: Print some statistics about transitive reduction 2017-12-20 16:19:40 +01:00
f2aacfc943 Depsgraph: Make transitive reduction to work 2017-12-20 16:16:28 +01:00
5b1404f066 Depsgraph: Add utility function to unlink relation from graph 2017-12-20 16:15:55 +01:00
1e236deab3 Depsgraph: Remove unused priority calculator
While it sounds useful, in practice it was rather causing
extra overhead and was slowing things down.
2017-12-20 15:53:39 +01:00
65128d296c Depsgraph: Remove remaining parts of old removed debugger 2017-12-20 15:50:22 +01:00
b1a036861d Fix T53572: Alembic imports UV maps incorrectly
Since in Alembic the loop order seems to be reversed when exporting and
importing, and this was the only place where it was not, I was thinking
to match this to the convention of reversing the loop order as well.

Reviewers: sybren, kevindietrich

Tags: #alembic

Differential Revision: https://developer.blender.org/D2968
2017-12-20 10:55:02 +01:00
94a3ee56c7 Fix MSVSC2017 error
The last compiler version needs this include
2017-12-20 10:23:12 +01:00
d0ac5d3810 Cleanup: remove unnecessary tooltip line limit
Also add TODO for possible future changes.
2017-12-20 17:20:33 +11:00
f6766c31cf Manipulator: clear tooltip for click actions too 2017-12-20 17:13:54 +11:00
5b364dd780 Manipulator: tooltip support
Currently operators and properties are used.
2017-12-20 16:40:53 +11:00
3143b2f942 Merge branch 'master' into blender2.8 2017-12-20 15:06:22 +11:00
51f0c3fadf UI: move tooltip API to public header 2017-12-20 14:58:06 +11:00
Julian Eisel
b0d61ea770 Fix crash in RNA when accessing empty property_tags list
E.g. running `bpy.context.active_object.cycles.bl_rna.property` in the
console would crash.

Thanks @lijenstina for reporting!
2017-12-19 20:56:14 +01:00
Dalai Felinto
b3bcbc9e85 Fix T53442: Outliner refresh issues when adding new collection
Notifier is getting through, yet tree wasn't rebuilding until
we force redraw by resizing the outliner.

Thanks to Danrae Pray (@spockTheGray) for looking at this issue.
2017-12-19 14:33:27 -02:00
433c74d9f7 bpy_extras: add missing colorband keymap to keyconfig_utils.py
fixes failing ctest script_load_keymap
2017-12-19 08:04:17 -07:00
7e8525663c Font objects: Support proper auto-space
Annoyingly, need to convert vfont to nurbs, do minmax and toss nurbs away.
This is likely to be fine, since this function is not intended to be used
a lot, and this is the only way to get more meaningful result.

However, it's not very clear what to do with font on curve.

This fixes rendering of font object with auto texture space in Cycles
introduced in c34f3c7.

It is probably possible to introduce new mode to vfont_to_curve which
will do boundbox without extra allocations, but that's more like an
optimization.

Reviewers: campbellbarton, mano-wii

Reviewed By: campbellbarton

Subscribers: zeauro

Differential Revision: https://developer.blender.org/D2971
2017-12-19 15:55:56 +01:00
ab1af38c74 Cycles: Fix crash opening user preferences after adding extra GPU
We can not store pointers to elements of collection property in the
case we modify that collection. This is like storing pointers to
elements of array before calling realloc().
2017-12-19 15:51:28 +01:00
Dalai Felinto
672c9a9a6d Fix T53583: Crash when instancing a group with an armature
There is still a crash that you get because the draw manager needs to
handle duplis differently.

But the initial assert caused by this particular file is now fixed.
2017-12-19 10:46:37 -02:00
2bbfce631d Merge branch 'master' into blender2.8 2017-12-19 13:42:01 +01:00
b6b9351371 Tracking: Add missing animation path fix after renaming tracks 2017-12-19 13:39:37 +01:00
e1921ed871 Tracking: Add utility function to get RNA path prefix for given track
Some code could be de-duplicated with the full path case, but that's
for another rainy day i guess.
2017-12-19 13:09:39 +01:00
9fa021cdaf Tracking: Disable animation of auto-keyframe option 2017-12-19 12:59:52 +01:00
61c218fe7d Tracking: Add missing animation fix when deleting plane track 2017-12-19 12:58:42 +01:00
883e342bdb Tracking: Fix possible numerical overflow 2017-12-19 12:52:20 +01:00
28970b6ed2 Fix T53523: Keyframes for Marker weight stay, even if the track itself is deleted
Was using wrong prefix for the RNA path fix.
2017-12-19 12:51:45 +01:00
92197c24f0 Tracking: Use new RNA path utility functions 2017-12-19 12:48:53 +01:00
cf90b11d68 Tracking: Add utility function to get RNA path for given track 2017-12-19 12:45:23 +01:00
f62de28972 Depsgraph: Fix nexted node trees being tagged with wrong flag 2017-12-19 12:37:57 +01:00
43dcf804bd Tracking: Remove duplicated functions 2017-12-19 12:22:34 +01:00
1818aa3b24 Tracking: Add plane tracks equivalents to previous commit 2017-12-19 12:18:52 +01:00
e598e55edd Tracking: Add utility function to get tracks list for given track 2017-12-19 12:14:26 +01:00
adaeb14b3e Tracking: Add utility function to find tracking object from a given track 2017-12-19 12:13:57 +01:00
71c93624e2 Cleanup: Don't use camel case for variable names 2017-12-19 11:53:11 +01:00
6cbdde1ba1 Fix T53400: DEG tagging is freeing Irradiance Grid when selecting objects
Ignore selection related recalc in Eevee ID update callback.
2017-12-19 11:46:53 +01:00
4045a51a11 Depsgraph: Rework tagging and flushing routines
The goal is: have id->recalc flags set to components which got changed.
To make it possible for render engines to check on a more granular basis
what changed in the object. For example, is it a transform which changed
or is it just some ID property changed which has nothing to do with rendering.

The tricky part is: we don't want duplicated logic in tagging and flushing.
In order to avoid this duplication, we store ID recalc flag in the component
node type information. That type information could easily be accessed by both
tagging and flushing routines.

Remaining part of the changes are related on changing the way how tagging
works. The new idea here is to have utility function which maps update tag to
a component. This way we can easily set ID recalc flags right away. Without
any duplication of ID recalc flags set in multiple flag handler functions.

With all this being said, there should be no user measurable difference for
now, it's a gigantic basement for some upcoming work and fixes.
2017-12-19 11:37:22 +01:00
e4849ad3a6 Depsgraph: Preliminary work to make components to ID recalc flags 2017-12-19 11:37:14 +01:00
3500274d9c Add more granular ID recalc bits
Only bits for now, unused. Just to keep upcoming patches smaller.
2017-12-19 11:36:58 +01:00
0ebf69287a Merge branch 'master' into blender2.8 2017-12-19 10:05:04 +01:00
c34f3c777f Fix T53559: Auto texture space for text and font is wrong in Cycles
The issue actually goes a bit deeper, converting curve to mesh will
change texture space just because font and bezier curves are using CV
to calculate texture space.

So now when those objects are converted to mesh, we disable auto
texture space and copy evaluated space over.
2017-12-19 10:01:00 +01:00
a130c82f0a Cycles tests: Enable texture space tests 2017-12-19 09:54:23 +01:00
9d69b3d48b Merge branch 'master' into blender2.8 2017-12-19 19:42:11 +11:00
77c62c7793 UI: split out button checks from tooltip creation
Allows to make tooltips from other kinds of data.
2017-12-19 19:34:16 +11:00
e288afe110 Merge branch 'master' into blender2.8 2017-12-19 08:57:34 +01:00
a0fa404deb Fix T53547 for real now
Original fix was assuming that particle init operation is updated on every
frame, which is wrong behavior and that was fixed in previous commit to the
original bugfix.
2017-12-19 08:56:11 +01:00
891a3762ce Manipulator: ui-scale support for navigate widget 2017-12-19 17:14:52 +11:00
01850f0928 Manipulator: 3D view navigation improvements
- Highlight's were too intense/distracting
  use more subtle alpha (consistent with the rest of our UI).
- Don't fill center cube (only draw edges).
- Draw widget while interacting since this is helpful in some cases.

Thanks to @jbakker for suggestions.

Also change axis hotspots so the nearest is always selected
for quicker axis picking (relies on dragging any axis to orbit).
2017-12-19 15:28:01 +11:00
f03660bb84 Correct axis mapping logic 2017-12-19 14:36:22 +11:00
cfd1b48492 Merge branch 'master' into blender2.8 2017-12-19 14:15:19 +11:00
e418c858ab 3D View: use shortest angle between quaternions
Gave incorrect smoothview speed changing between some axis and
axis locking.
2017-12-19 14:05:54 +11:00
7a58ff928c Math Lib: signed versions of quaternion angle
There was no simple way to get the shortest quaternion angle.
2017-12-19 14:03:29 +11:00
5df597171b Manipulator: Support click only manipulator's
Makes the 3D view navigation widget easier to use: dragging anywhere
in the rotation region now rotates without having to avoid the XYZ axis
hotspots which only activate on a single click.

Logic for drag detection is complicated by manipulators reliance
on keeping the modal operator running.
Currently this is wrapped in an ifdef,
we may want to implement it differently later.
2017-12-19 12:49:02 +11:00
12bc63a0fe Manipulaor: de-duplicate finish call 2017-12-19 12:46:36 +11:00
02abb17ae2 Forgotten on last commit 2017-12-18 23:24:12 -02:00
24ca903f6d Draw Manager: draw_cache_imp_displist, always return IndexBuf even when there is no index
This prevents possible errors with materials and a crash with low resolution metaball.
Also a small cleanup was done in the code.
2017-12-18 23:17:55 -02:00
bb30ce0f0b Fix T53474, bevel glitchy with big objects.
A comparison should have not just have been against an epsilon,
but relative to the edge length involved.
Thanks to mano-wii for patch on which this is based.
2017-12-18 12:24:42 -05:00
57f2cc918b Depsgraph: Cleanup, line length 2017-12-18 16:55:04 +01:00
e57fe5cd95 Depsgraph: Use named typedef for tag 2017-12-18 16:53:12 +01:00
94d34ae205 Depsgraph: Cleanup, typo in comment 2017-12-18 16:52:46 +01:00
90021402e2 Merge branch 'master' into blender2.8 2017-12-18 16:51:05 +01:00
443789d7c6 Depsgraph: Add facilities to store what ID recalc flag component corresponds to
The idea is to de-duplicate logic in DEG_id_tag_update() and flushing where we
need to translate depsgraph tag or component type to ID level recalc flag.

Currently unused, but is required for Blender 2.8.
2017-12-18 16:46:32 +01:00
9e424faec6 Add dedicated named constant for no ID recalc flag 2017-12-18 16:40:18 +01:00
fbfb35741c Merge branch 'master' into blender2.8 2017-12-18 16:36:23 +01:00
342226a670 Depsgraph: Synchronize flushing with 2.8 branch
Not only this helps merges form master to the branch, but also:

- Allows us to production-check changes as soon as possible.
- Avoids some unnecessary editors update about ID changes.
- Adds small optimization on queue size by always keeping one of the pointers
  outside of the queue.
2017-12-18 16:33:12 +01:00
c46a9d8117 Merge branch 'master' into blender2.8 2017-12-18 16:19:12 +01:00
344eff9c48 Depsgraph: Add query API to traverse all dependent IDs of the given ID 2017-12-18 16:15:47 +01:00
c5d9eb88e2 Depsgraph: Replace iteration over ghash with iteration over flat array 2017-12-18 16:14:50 +01:00
8fe556a337 Depsgraph: Introduce flat list of ID nodes
The idea is to allow iterating over ID nodes in exact order of their
construction, and in order which will not change dependent on memory
pointers or anything.
2017-12-18 16:10:22 +01:00
1fb43dcd5a Fix bad merge happened at some point 2017-12-18 16:04:06 +01:00
a41fe949d8 Fix T53398: Surface deform modifier says that convex polygons are concave for big faces
Dot-product for angle check need either to be divided by vectors magnitude or be
calculated for normalized vectors.
2017-12-18 15:16:22 +01:00
5566a88873 Static Override: better handling in ID template.
Now we stick to a single button, when data is directly linked, clicking
on it will make a local copy, while shift-clicking on it will make a
static override.

When data is a static override, icon is the DATA_OVERRIDE one, and clicking
on the button will make it a fully borring local data-block.
2017-12-18 12:29:08 +01:00
ec6e490bb8 Add override icon to such data-blocks in OUtliner. 2017-12-18 12:02:23 +01:00
4c9f303eba Add macros to check whether an ID is a static override or has a template for it. 2017-12-18 12:01:50 +01:00
98aa51ffa1 blender_icons_update script: run Blender in factory startup.
Can avoid some stupid issues with custom addons etc.
2017-12-18 10:47:02 +01:00
9052db809f Add basic 'override' icon.
This is just the 'linked' icon with top-down arrow instead of left-right
one, if any graphist feels more inspired... ;)

Note that this is 'new inkscape' version of the svg file, hope
everything is alright (it does change all icons whe re-exporting :/ ).
2017-12-18 10:44:20 +01:00
7ab8c90686 Serious cleanup/refactor/fixing of new RNA comparison code.
Code also handling auto-generation of static overrides.

Aside from some naming consistency cleanup, this commit:

* Is the first step addressing the 'operator' issue with static
overrides, by implementing a first version of the 'restore from
reference' behavior.

* Fixes several issues that were discovered on the way in enhanced
RNA comparision code, like the 'zero-length dynamic array' case, or some
infinite looping caused by some non-ID pointers (that for some
mysterious reasons did not show up previously...).

* Factorizes a bit said RNA comparison code (auto-static override
generation and comparison/check were essentially doing the same thing).
2017-12-18 10:13:43 +01:00
994648a674 RNA: add new property falg for pointers (and collection), 'NO_OWNERSHIP'.
This flag means that the pointer does not 'own' the data it references.
This is the case of nearly all ID RNA pointers (NodeTrees will probably
again be some nasty exception here :( ), but also several other cases.

That kind of information is mandatory for complex processing over whole
data-blocks done in RNA, like some static override tasks (advanced
comparison...).
2017-12-18 10:08:22 +01:00
076616898b Fix T53577: Rake sculpt/paint wrong on first step 2017-12-18 14:35:15 +11:00
c2ad5e805a Fix triangles indexbuf of Curve Displists was being discarded incorrectly
They were discarded when shaded surfaces were requested thus bringing glitches to the outline of the selected Displists Objects
2017-12-16 22:22:21 -02:00
3713de163e Fix triangles of the Displists were being drawn in the opposite direction 2017-12-16 21:58:16 -02:00
342a322a93 CMake: bump minimum version to 3.5 2017-12-17 01:04:05 +11:00
45434c75a0 Manipulator: change cursor for navigation axis
Wasn't easy to see
2017-12-16 19:28:39 +11:00
625d72ed48 Manipulator: draw 2d manipulators over view border
Needed so passepartout doesn't cover 2d manipulators.
2017-12-16 19:05:27 +11:00
d855fc4dad App Template: use manipulator flag
So templates can enable manipulators.
Also remove invalid enum set.
2017-12-16 18:36:49 +11:00
468ac90317 Manipulator: view3d navigation buttons
Added for Blender101 template.
Disabled by default, enable as a preference.

Exposes rotate, pan, zoom, persp-ortho & camera toggle.
2017-12-16 04:21:30 +11:00
c2cc42742d Manipulator: support single press button actions
While not the main purpose of manipulators, it's handy to be able
to use operators without modal callbacks sometimes.
2017-12-16 04:08:37 +11:00
68ffb2a267 Merge branch 'master' into blender2.8 2017-12-15 17:55:23 +01:00
50ef25d73f Depsgraph: Cleanup, remove unused function 2017-12-15 17:47:15 +01:00
da570fcbb4 Depsgraph: Cleanup, make naming more understandable 2017-12-15 17:46:30 +01:00
3d72b94196 Depsgraph: Use array instead of set for node factory
Avoids extra time spent on hashing and such.

Old comment is kind of weird, because types we can totally make a sequent
integer values.
2017-12-15 17:43:07 +01:00
4ce38abfcd Depsgraph: Add named constant with number of node types 2017-12-15 17:39:01 +01:00
68a7f5e594 Depsgraph: Don't use negative enum value
Not sure why it sohuld be negative, we shouldn't be using any explicit value
comparison.
2017-12-15 17:38:12 +01:00
Julian Eisel
5cb70a89e1 Fix failing assert when reading workspace list from workspaces.blend 2017-12-15 17:26:23 +01:00
114013de0d Merge branch 'master' into blender2.8 2017-12-15 17:24:28 +01:00
c795309c03 Depsgraph Cleanup, spelling 2017-12-15 17:23:57 +01:00
6609be0520 Depsgraph: Simplify logic around special case for node tree update 2017-12-15 17:23:57 +01:00
1797923f32 Depsgraph: Cleanup, extra whitespace 2017-12-15 17:23:57 +01:00
76a1046478 Depsgraph: Cleanup, use names for particle system tag flags 2017-12-15 17:23:57 +01:00
f88ce5bf27 Depsgraph: Remove special exception logic from ID node tagging
This is something what we should be limiting as much as possible, it is
enough already to have special mapping cases in depsgreaph_depsgraph_tag.
2017-12-15 17:23:57 +01:00
5e28b71457 math utils: Add utilities to scan bit and clear it 2017-12-15 16:54:28 +01:00
de9e5a0926 Math utils: Go away form naive code for highest_order_bit_uint 2017-12-15 16:54:28 +01:00
412de222f8 Math utils: Add bit scan operations 2017-12-15 16:54:28 +01:00
02ec0b53df Math utils: Make it more clear what the functions are returning 2017-12-15 16:54:28 +01:00
2aa0f8a41b Math utils: Cleanup, use _uint suffix for function which operates on uint 2017-12-15 16:54:28 +01:00
Julian Eisel
9515737b55 Fix missing refresh of editors when changing workspace view-layer
Needs to use new messaging system.
2017-12-15 16:09:12 +01:00
2b25d8ea30 Depsgraph: Fix assignment to wrong flags 2017-12-15 14:42:42 +01:00
ff0d3c520f Tracking: Cleanup, fix typo in variable name 2017-12-15 13:53:44 +01:00
6b62f1dcb9 Tracking: Pass all markers to autotrack at once
This solves delay before tracking actually starts.

The issue is reported by Sebastian over IRC, thanks!
2017-12-15 12:51:53 +01:00
4895bd6ace Libmv: Add C-API function to set all markers within AutoTrack structure 2017-12-15 12:51:17 +01:00
e50442418a Tracking: Cleanup, make autotrack context creation code more granular 2017-12-15 12:37:23 +01:00
4cc0f09881 Tracking: Cleanup, use more const qualifiers when appropriate 2017-12-15 12:23:53 +01:00
Dalai Felinto
0b5616aef1 Depsgraph: cleanup DEGOIterObjectData > DEGObjectIterData 2017-12-15 08:59:05 -02:00
Dalai Felinto
90b7917687 Depsgraph: Make DEG_OBJECT_ITER more granular
It is not nice to assume we always want visible or directly linked objects.
So we make it as granular as we can.
2017-12-15 08:59:04 -02:00
Dalai Felinto
3a47fb764c Depsgraph / Render / Collection: Tag groups for rendering
We need to tag groups before and after rendering, so the group collections
viewport and render visibility are taken into account.

Note: This is a workaround, that will be removed once the render engine have
its own depsgraph, instead of re-using the viewport depsgraph.
2017-12-15 08:59:04 -02:00
Dalai Felinto
1f5106de61 Group collection viewport/render options and remove collection visibility
Users can change the group collection visibility in the outliner
when looking at groups.

Regular collections on the other hand don't have any special visibility control,
if you need a collection to be invisible during render, either don't link it
into the view layer used for F12, or disable it.

This includes:
* Updated unittests - update your lib/tests/layers folder.
* Subversion bump - branches be aware of that.

Note:
Although we are using eval_ctx to determine the visibility of a group collection
when rendering, the depsgraph is still using the same depsgraph for the viewport
and the render engine, so at the moment the render visibility is ignored.

Following next is a workaround for this separately to tag the groups before and
after rendering to tackle that.
2017-12-15 08:56:48 -02:00
7402b8ec74 Draw manager: Cleanup, unused variable 2017-12-15 10:54:00 +01:00
f4140f2c81 Merge branch 'master' into blender2.8 2017-12-15 10:45:20 +01:00
Dalai Felinto
2ddee0ba5a Fix dupli-frames (and other duplis)
Even non-group dupli objects need to get the overrides from somewhere.
Getting them from dupli_parent.
2017-12-15 07:14:25 -02:00
c4046e9082 Move ID recalc flags into dedicated field in ID
Currently this is a no-visible-changes change, but the idea is to use this
dedicated flag to tell which exact components of ID changed, make it more
granular than just OBJECT and OBJECT_DATA. Allow setting this field based
on what components new dependency graph flushed on evaluation.
2017-12-15 09:43:18 +01:00
Dalai Felinto
569e29c49c Fix RNA crash for objects without collection properties
This would happen if you tried to access the collection property for an object
that has not being evaluated by the depsgraph.
2017-12-14 20:17:27 -02:00
100e9aa15f Draw Manager: Texture space support for Curve and Metaball objects 2017-12-14 17:53:27 -02:00
c027be3189 Fix broken collada from recent merge rBb83b6afe5572ae29b4ad105dd8001c3343e2205b.
Please make minimal checks on what you do when merging!
2017-12-14 20:25:26 +01:00
aa1054acf8 Draw Manager: Edit Curve Mode: Fix "Not freed memory blocks"
`e_data.overlay_vert_sh` was not being freed when quitting blender.
2017-12-14 15:16:09 -02:00
06def089d3 Draw Manager: Recalculate batch of Curves, Surfaces and Texts when a property is changed 2017-12-14 14:44:20 -02:00
6b794565aa Fix crash with DispLists without vertices
Wee must return VertBuffers even when its size is zero
2017-12-14 14:31:08 -02:00
400d59be9b DNA: Add dedicated recalc flag to ID
Currently unused, but this is where LIB_TAG_ID_RECALC* flags will go.

Also modified other DNA to make pointer property being followed by pointer.
Makes it easier to keep track of alignment and extend nested structures without
ruining anything.
2017-12-14 15:25:51 +01:00
14ac709455 Eevee: Support for objects of type Curve, Surface and Text 2017-12-14 12:22:55 -02:00
5b5de35604 Support for Batchs split by material for objects of type Curve, Surface, and Text
**ToDo:**
- add vertbuff for UV (what can be adapted from `dl_surf_to_renderdata`)
2017-12-14 12:21:38 -02:00
bb9d068ccc Depsgraph: Cleanup, use more explicit way to fill in a structure
The possible issue with just listing arguments is that it might not be clear
what particular value is used for. For example, is it a scene itself, or is
it a parent scene?

Not as if it's not very clear now, but better be explicit for the future,
and me reading code in 10 years.
2017-12-14 11:09:18 +01:00
b83b6afe55 Merge branch 'master' into blender2.8 2017-12-14 12:51:26 +11:00
99b7dc60be Fix missing update for particles w/ fluids
D2955 by @GonVas
2017-12-14 12:06:36 +11:00
1f95347882 Fix T53322: Collada export crash w/ shape keys
D2958 by @cmbasnett
2017-12-14 10:59:41 +11:00
Dalai Felinto
f59728b3ea Object selection: Fixing cases where old selection flag was used
Basically these operators (select grouped object hooks and object select mode/less)
were not working in 2.8.
2017-12-13 16:26:46 -02:00
Dalai Felinto
53ea46d36c Outliner: Fix selection drawing
Outliner was using the old selection flag to show selected objects.
So if you selected an object in the outliner it would keep "selected"
(drawn in yellow) even after you selected another object.
2017-12-13 16:26:46 -02:00
3a3587f4b2 Depsgraph: it is still possible to have non-object to use OB_RECALC_DATA tag
Those flags are to be redone...
2017-12-13 16:39:03 +01:00
09838ed24c Comment out and tag unused bit as unused 2017-12-13 16:34:13 +01:00
33c97351fb Depsgraph: Move data update tag to object->data itself 2017-12-13 16:32:08 +01:00
f97d036468 Depsgraph / Object update: Query data update flag from data itself 2017-12-13 16:27:05 +01:00
ac3d477481 RNA: Query is_updated flag from object data ID's rather than from object itself 2017-12-13 16:27:01 +01:00
84c5ccca74 Masks: Remove unused function
It was used by old dependency graph. New one does things differently.
2017-12-13 16:14:08 +01:00
405becec70 Comment out and tag unused bit as unused 2017-12-13 16:05:20 +01:00
92067f7cda Depsgraph / Du[plication: Remove workaround flag from ID
Animation does no longer tag IDs as updated, so flag is not
needed anymore.
2017-12-13 15:56:18 +01:00
118178d176 Depsgraph / Animation: Rmove direct ID tagging from animation code
New dependency graph is supposed to have relation from animation node to
the node which corresponds to a property which is modified by that curve.
This means it is up to dependency graph to flush recalc flags, and no
manual control is needed in the animation code.
2017-12-13 15:53:04 +01:00
ec3d25803e Merge branch 'master' into blender2.8 2017-12-13 15:07:42 +01:00
a621850224 Fix T53550: E hotkey not working after the color-band picker commit
Related to D2886, the color-band picker was lacking a poll function.
2017-12-13 07:00:16 -07:00
81f135677b Depsgraph: Cleanup, use less explicit checks of LIB_TAG_ID_RECALC_DATA
This is a part of ongoing work in Blender 2.8, where we need to replace

  `object->id.tag & LIB_TAG_ID_RECALC_DATA`

with

  `object->data->id.tag & LIB_TAG_ID_RECALC`

Should be no user measurable difference.
2017-12-13 14:43:32 +01:00
3d6cc77cbd Merge branch 'master' into blender2.8 2017-12-13 14:24:44 +01:00
Danrae Pray
32f85c8322 Fix T51461: Outliner: Problems removing multiple collections in sequence
We now select the LayerCollection at index 0 for the active ViewLayer after a
collection deletion operation.

Added some functions to query outliner tree data & get LayerCollection
by index using a similar approach as we do for SceneCollection indexing.

With warning and style cleanups by Dalai Felinto.

Reviewers: dfelinto

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2942
2017-12-13 10:01:16 -02:00
João Seixas
4838512e7d Fix T53404 - Python API documentation: UI Layout Emboss description wording
Changed the suggested word

Reviewers: #documentation, #python, sergey

Reviewed By: #documentation, sergey

Tags: #documentation, #python

Differential Revision: https://developer.blender.org/D2952
2017-12-13 12:56:38 +01:00
1b371d199e Depsgraph: Ensure dependency graph is allocated for evaluation context
This is something what we would need to ensure anyway, so doesn't seem
to make sense to NOT allocate depsgraph and then worry about this externally.

Steps to reproduce: add cube, change it's size in redo panel.

Found by Campbell during code review session.
2017-12-13 12:55:39 +01:00
ae80835d10 RNA override: Cleanup & small refactor.
Remove unused func from public API.

Make parameters & variables naming more consistent accross the code.

Move RNAproperty validation/'conversion' (for IDProps case) to upper
level in code, this will avoid some useless re-processing.
2017-12-13 12:46:25 +01:00
2ac33b47dc Fix T53547: Metaballs as dupli objects are not updated with the new Depsgraph
Follow relations from old dependency graph.
2017-12-13 10:50:28 +01:00
2c64615438 Fix T53552: Unneeded particle cache reset on frame change
There shouldn't be a time dependency to cache reset operation.
2017-12-13 10:47:59 +01:00
cd845ae509 T53471: Fix crash with blender_icons_update.py
Default DPI of new inkscape caused incorrect image size.
2017-12-13 16:55:51 +11:00
be54868ec3 Fix T53529: Rip crashes w/ wire edge 2017-12-13 16:14:37 +11:00
611752ce33 UI: color-band eyedropper now combines samples
Resulting color-band was too noisy (especially with photos),
use gauss filter to take surrounding samples into account.
2017-12-13 15:38:11 +11:00
52d33d6ab9 Merge branch 'master' into blender2.8 2017-12-12 18:00:36 +01:00
ef8bbc8cba Fix bplayer (c). 2017-12-12 14:23:19 +01:00
56f00db6c9 Correct error in recent merge 2017-12-12 23:19:41 +11:00
99069c8ae2 Revert "Node selection: Stop operator when mouse selection selected a node"
While re-route operator got fixed, node resize became broken.

This reverts commit 43f33ea300.
2017-12-12 10:34:38 +01:00
edd39f6da7 Merge branch 'master' into blender2.8 2017-12-12 16:13:06 +11:00
b3c147a04f Cleanup: split eyedropper into separate files
Each handles separate data-types and didn't share much logic,
better put each in it's own file.
2017-12-12 15:44:59 +11:00
41fc0a0624 Merge branch 'master' into blender2.8 2017-12-12 13:55:09 +11:00
58aa31a9ec Cleanup: minor edits to last commit 2017-12-12 13:37:21 +11:00
f7a1a1a700 UI: rewrite color-ramp re-sampling
Instead of picking evenly spaced pixels color-ramp simplification
now works by removing elements with the lowest cost.
2017-12-12 13:20:56 +11:00
7ae4c3a019 Add eyedropper to color-ramp widget
D2886 by @LazyDodo with edit's by @campbellbarton

The line drawn with the eyedropper is used to fill the color-ramp.
2017-12-12 13:11:38 +11:00
43f33ea300 Node selection: Stop operator when mouse selection selected a node
Previously, hitting Shift-LMB will first invoke selection operator, which
then later on is transformed to mouse tweak used for reroute operator.

This was causing problems extending selection with Shift-LMB when clicking
fast or from a tablet.
2017-12-11 17:38:47 +01:00
Dalai Felinto
1b2ac71f45 Fix workspace ui panel after workspace API change
This was broken since e8c15e0ed1. We can no longer get view_layer
from worspace, we should get it from window instead, now.
2017-12-11 13:18:14 -02:00
7719f7d27a Fix T53528: Empty thumbnails in filebrowser
Bug in recent refactor.
2017-12-11 15:47:52 +01:00
54f7bb4582 Fix for inset when accessed from spacebar search 2017-12-12 01:38:33 +11:00
14655418d1 Add 'Add static override' to outliner's menus. 2017-12-11 12:07:13 +01:00
75fbd60b06 Walk all the overriding chain to try to find a template.
When one creates a new local static override from another linked
data-block already overriding a third one etc., walk the whole
inheritance chain up to the original ancestor to try to find an
overriding template, instead of only checking the immediate reference...
2017-12-11 12:07:13 +01:00
48fe46943e Add a new button in ID template to generate an override, and new icon placeholder.
Note that due to mess with inkscape (see T53516), I cannot generate a new icon
currently. :(

Commit related to T53501.
2017-12-11 12:07:13 +01:00
6475f163ec Manipulator: make grab-cursor a manipulator flag
As with operators, allow manipulators to grab the cursor.
Previously this was enabled for all 3D manipulators.
2017-12-11 21:38:55 +11:00
1218b3fceb Cleanup: whitespace 2017-12-11 19:28:40 +11:00
4737b95b65 Merge branch 'master' into blender2.8 2017-12-11 19:24:37 +11:00
dd4e0cd3e3 DNA/RNA: add 'py_instance' for ID types
Avoid creating new Python instances
every time a scene, object, mesh .. etc are accessed.

Also resolves crashes T28724, T53530
although it's only valid for ID types, not modifiers vertices etc.

Back-ported from blender2.8 branch.
2017-12-11 18:37:54 +11:00
a2f2231014 Fix grab3d manipulator in a 2D group
Was taking scale into account twice.
2017-12-11 17:07:40 +11:00
53394c6018 PyAPI: Correct manipulator template 2017-12-11 16:01:07 +11:00
2e685136c4 WM: update splash size for templates 2017-12-11 12:53:28 +11:00
c568985118 MSVC: Fix compiling with some system languages
Report from @cyaoeu that compiling failed for Japanese system language.
2017-12-10 15:19:50 +11:00
Dalai Felinto
9454359a16 Workspace: Clarifying library remap workaround
WorkSpaceLayout->screen will be made public soon, but meanwhile this makes it
clear why we are not passing layout->screen to CALLBACK_INVOKE in this case.
2017-12-08 13:35:31 -02:00
392c23bdb9 Library remap: Fix issue remapping pointer of object coming from group[s base
We can not store pointer to an object ion temporary variable here, since then
pointer will not be updated in the base itself.

This fixes missing modifiers on objects coming from dupli-group.
2017-12-08 16:07:25 +01:00
34522017de Cleanup, indentation 2017-12-08 16:07:20 +01:00
36e09b5ada Depsgraph: Groups are now covered by dependency graph 2017-12-08 16:07:20 +01:00
7aa022b7a8 Depsgraph: We need to add ID node before getting CoW pointer
Need to split runtime get-cow-pointer with a builder one, and add some asserts
to catch mis-use.
2017-12-08 16:07:20 +01:00
f57317c6e7 Merge branch 'master' into blender2.8 2017-12-08 12:43:52 -02:00
e6838ecc26 Fix T53512: Vertices with index 0 were not being selected
Bug introduced on rB9f5bf197a0c3.
The offset for selection of vertices (`bm_vertoffs`) starts where the offset o edges ends (`bm_wireoffs`).
However, the `bm_wireoffs` depends on the offset of face selection (`bm_solidoffs`).

Before the commit that introduced the bug, the drawn of edges (in backbuff) was always computed along with the `bm_wireoffs`:
```
bm_wireoffs = bm_solidoffs + em->bm->totedge;
```

Now that the edges are not always drawn in backbuff, `bm_wireoffs` has to start from `bm_solidoffs`.
2017-12-08 12:42:00 -02:00
8817faa02d Cleanup, indentation 2017-12-08 15:05:38 +01:00
82c0a54168 Depsgraph: Use dedicated function for group evaluation
It is still based on generic collection evaluation, but the idea is to avoid
having view_layer pointer passed from group to it's evaluation function.

This is essential for copy-on-write, where we need to pass view_layer pointer
from a copied datablock, but that copy is not yet available at construction
time. Also, this is NOT the case where we want to expand datablock at a
construction time, just to keep our life easier.
2017-12-08 15:05:38 +01:00
Dalai Felinto
af47ae0702 Fix group duplication bug
View Layer was not duplicated between destination and source.

This would lead to a crash if you duplicated the group and assigned
the new group to any object.
2017-12-08 12:04:05 -02:00
Dalai Felinto
0d4ab09da7 Code cleanup
Thanks for Sergey Sharybin for spotting this.
2017-12-08 12:04:05 -02:00
6e85c59250 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/interface/interface_templates.c
2017-12-08 14:54:59 +01:00
f39a97fac5 Cleanup: moar busting of nasty C++ keywords-as-varnames. 2017-12-08 14:50:45 +01:00
087997f9eb Merge branch 'master' into blender2.8
Conflicts:
	source/blender/editors/interface/interface_templates.c
2017-12-08 14:39:17 +01:00
c7ee64b2d9 Cleanup: avoid using C++ keywords as variables, even in pure C code.
This tends to make some IDE unhappy (like QTCreator)...
2017-12-08 14:36:07 +01:00
d46305f741 Merge branch 'master' into blender2.8 2017-12-08 12:44:32 +01:00
2e8914549b Cycles: Fix difference in image Clip extension method between CPU and GPU
Our own implementation was behaving different comparing to OSL and GPU,
namely on the border pixels OSL and CUDA was doing interpolation with
black, but we were clamping coordinate.

This partially fixes issue reported in T53452.

Similar change should also be done for 3D interpolation perhaps, but this
is to be investigated separately.
2017-12-08 12:03:11 +01:00
0467ddc674 Eevee: Fix default shader SSR id. 2017-12-08 11:58:04 +01:00
9aaf75da3d Eevee: Fix SSR ans SSAO for intel GPU.
On my intel GPU there is some issue when rendering to depth only format.
This workaround the issue.
2017-12-08 11:58:04 +01:00
7f48923986 Eevee: Remove unecessary defines. 2017-12-08 11:58:04 +01:00
f31fb4a014 Cycles: Cleanup, split 2D interpolation function 2017-12-08 11:22:04 +01:00
82c779462d Merge branch 'master' into blender2.8 2017-12-08 12:59:51 +11:00
4a734325f7 bl_app_override: support empty UI layout items
Returning None from ui_ignore functions creates empty labels,
allows removing items without breaking layout in some cases.
2017-12-08 12:57:25 +11:00
Dalai Felinto
dc848e9a8b Merge remote-tracking branch 'origin/master' into blender2.8 2017-12-07 15:00:03 -02:00
Dalai Felinto
237df2f860 Fix Collada building
Bug introduced in cc811d1fd6.
2017-12-07 11:51:46 -02:00
00067afa10 Fix T53419: Masking "Add" menu is not present in Image editor, but shortcut is 2017-12-07 14:46:07 +01:00
70957565dd DPX/Cineon: Report orientation when running with --debug 2017-12-07 14:38:20 +01:00
1c0905be0f Merge branch 'master' into blender2.8 2017-12-08 00:21:54 +11:00
efdd8f12a0 CMake: GREATER_EQUAL is from v3.7, use GREATER 2017-12-08 00:20:48 +11:00
bfbcc5e581 Fix T53499: Cannot load DPX files
The issue was caused by unspecified color transfer. New behavior gives same
result as other viewers here, so likely is fine :)
2017-12-07 14:07:57 +01:00
9ea7d0bf44 DPX: Fix wrong flag being checked for debug 2017-12-07 14:04:27 +01:00
1c7cfa025c Merge branch 'master' into blender2.8 2017-12-07 23:53:03 +11:00
2e2e6e3bdb Cleanup: Use BKE_colorband prefix 2017-12-07 15:52:59 +11:00
cc811d1fd6 Cleanup: extract BKE_colorband from BKE_texture 2017-12-07 15:40:11 +11:00
6d31eb015c Array Modifier: option to offset UV's
D2912 by @Zuorion
2017-12-07 04:33:52 +11:00
Daniel Silva
2dfd795bd2 Proposed fix for T53263 -- Blender crashes when rendering with Stabilizer 2D node without movie selected
The program won't crash anymore, but a warning won't be displayed. Anyway, this gives the user the chance to save the project.

https://developer.blender.org/T53263

Reviewers: lukastoenne

Differential Revision: https://developer.blender.org/D2934
2017-12-06 14:54:51 +01:00
46f518e927 Merge branch 'master' into blender2.8 2017-12-06 14:06:49 +01:00
13e9291650 Library: Add flag top keep ID library pointer around
This only applies to ID being copied outside of bmain. Handy for cases when it
is important to check if the copy corresponds to a data block coming from
library.

Example of that is proxy evaluation with copy on write.

Thanks Bastien for review!
2017-12-06 13:00:08 +01:00
6c49b4154b Merge branch 'master' into blender2.8 2017-12-06 12:27:44 +01:00
3ae6a8512d Depsgraph: Cleanup, use less geenric data type 2017-12-06 12:26:10 +01:00
7e344a9531 Depsgraph: Proxy pose bones should be coming from CoW object
This should solve crash on files having proxies, but there will still be
assert failure because proxy_from is expected to come from library, which
is no longer truth for objects which got copied.
2017-12-06 12:13:10 +01:00
8cd4de7c25 Merge branch 'master' into blender2.8 2017-12-06 11:58:13 +01:00
b5be65dc0e Depsgraph: Forgot this in previous commit 2017-12-06 11:57:57 +01:00
e9bbc10578 Merge branch 'master' into blender2.8 2017-12-06 11:55:30 +01:00
5ad3cc4e03 Depsgraph: Ignore text datablocks from nodes
Those are not part of dependency graph, but still could be referenced from
the tree.
2017-12-06 11:54:52 +01:00
674e1d4194 Depsgraph: Owner ID must always be original ID
Missed that in the review.
2017-12-06 11:38:58 +01:00
5389ca1859 Merge branch 'master' into blender2.8 2017-12-06 10:38:34 +01:00
16b9e91bf1 Eevee: Fix sampling direction calculation.
It was causing problems with the visibility filtering on Intel GPU.
2017-12-06 10:47:44 +01:00
1027ddfa2d Depsgraph: Add missing bone properties to proxy rigs 2017-12-06 10:21:33 +01:00
99b9e23ce1 Depsgraph: Add missing NULL pointer check 2017-12-06 10:21:33 +01:00
4c5736a77f Depsgraph: Cleanup, remove unused function 2017-12-06 10:21:33 +01:00
1915c30a42 Depsgraph: Remove workaround of parameters animation in node tree 2017-12-06 10:21:33 +01:00
630ed82ff2 Depsgraph: Remove workaround of parameters animation in lamp 2017-12-06 10:21:33 +01:00
8acca0e9e1 Depsgraph: Remove workaround of parameters animation in camera
This is something what should be done by build_animation().
2017-12-06 10:21:33 +01:00
21ef8e7d29 Depsgraph: Remove workaround for animated geometry component 2017-12-06 10:21:33 +01:00
b552e03716 Depsgraph: Remove workaround for animated modifiers 2017-12-06 10:21:33 +01:00
f348b7924c Depsgraph: Leave armature animation relation to build_animation()
Needs some optimization trick to hook pose init function to animation
instead of a bone. This is how flush will work anyway.
2017-12-06 10:21:33 +01:00
cbb42fcd96 Depsgraph: Use default argument value for relations builder
Follows other function definitions.
2017-12-06 10:21:33 +01:00
18ca793ca0 Depsgraph: Cleanup, line wrapping 2017-12-06 10:21:33 +01:00
abc55bf84a Depsgraph: Use build_animation() to build relations to animated properties
Before that it was up to lots of other places to keep track on whether
something is to be dependent on time or not. Was annoying, and unreliable,
and fragile.

This commit avoids hacks in object builder. Other areas will be adopted
soon.
2017-12-06 10:21:33 +01:00
4a99cc5850 Depsgraph: Add ability to check whether relation exists before adding it
Currently not used, but this is aimed to be used when adding relations from
FCurve to property which is being animated.
2017-12-06 10:21:33 +01:00
8b3aa8ef45 Depsgraph: Cleanup, line wrapping 2017-12-06 10:21:33 +01:00
7de3c8ace7 Depsgraph: Move implementation part of relations header to own file 2017-12-06 10:21:33 +01:00
335343fe93 Fix T53408: Updating Cycles Nodes via Drivers in Material View
This is something what should be supported by the new dependency graph.

Fixed by making it so, build_animation() adds relation between Animation
component and whatever-is-being-animated. In fact, for now, only relations to
ID properties are added. Rest of the relations are kind of hacked in all over
the code and needs to be removed and verified with specific .blend files.
2017-12-06 10:21:33 +01:00
f1ad6b43b3 Depsgraph: Cleanup, split build_animation 2017-12-06 10:21:33 +01:00
9f9b666d9a Depsgraph: Correct fallback for the parameters calculation
We can't use a single component here, sine it might consist of multiple
operations. So, for example, having driver operation will confuse targets
of another driver.
2017-12-06 10:21:33 +01:00
b5a8d0acaf Depsgraph: Cleanup, split driver builder function 2017-12-06 10:21:33 +01:00
3e9cd53687 Depsgraph: Cleanup, deduplicate as much as possible in build_driver 2017-12-06 10:21:33 +01:00
8c4363e3b1 Depsgraph: Remove old comments which are likely outdated 2017-12-06 10:21:33 +01:00
8912e4faef Depsgraph: Replace last obvious part of driver builder with generic RNA code 2017-12-06 10:21:33 +01:00
b26992fe6e Depsgraph: Add criteria for RNA_Key 2017-12-06 10:21:33 +01:00
fe5e8593b7 Depsgraph: Remove confusing ID node criteria
it sometimes overrides all possible other criteria, even tho we might want to
be very specific about what component we are looking for here.
2017-12-06 10:21:33 +01:00
35364e2fb2 Depsgraph: Use generic function for shape key driver target
There was a second place for shape keys.
2017-12-06 10:21:33 +01:00
070c735b13 Depsgraph: Fix wrong relations built for drivers
When target was changed from bone to regular object, new dependency graph was
still trying to build relations as if driver was using bone.
2017-12-06 10:21:33 +01:00
f8fd8b0744 Depsgraph: Use generic function for shape key driver target 2017-12-06 10:21:33 +01:00
235a68d8f3 Depsgraph: Use generic function for modifiers driver target 2017-12-06 10:21:32 +01:00
7586266343 Depsgraph: Use existing utility function to get driver target node
Only done for pose bone for now, but the idea is to go case bu case in
build_driver and move all custom logic from there to find_node_from_pointer().
2017-12-06 10:21:32 +01:00
3795e37c62 Depsgraph: Cleanup, split build_driver function up 2017-12-06 10:21:32 +01:00
52e81de9f7 Depsgraph: Don't see reason to have special case for bone's RNA path 2017-12-06 10:21:32 +01:00
97e92d6f3e Depsgraph: SImplify chjecks in directly address bone 2017-12-06 10:21:32 +01:00
284f106c91 Depsgraph: begin use of RNAPathKey instead of re-implemented checks in driver variables 2017-12-06 10:21:32 +01:00
0cd2303e67 Depsgraph: Cleanup, don't use static qualifier inside of anonymous namespace 2017-12-06 10:21:32 +01:00
aed1320b24 Add utility function to compare PointerRNA with NULL
Thanks Campbell for review!
2017-12-06 10:21:32 +01:00
a68e10be5e Depsgraph: Correct RNA pointer criteria to deal with bone custom properties 2017-12-06 10:21:32 +01:00
7ca8af4cc8 Merge branch 'master' into blender2.8 2017-12-06 16:51:37 +11:00
e6404274a1 Fix T53441: Inset doesn't start at zero 2017-12-06 16:45:51 +11:00
9ab430e9cb Cleanup: line length 2017-12-06 16:42:34 +11:00
2480a190de CMake: remove git found message 2017-12-06 16:37:50 +11:00
2069102c56 Cycles: Fix constness for load_kernels in device_cpu.cpp 2017-12-06 00:00:18 +01:00
858b38f12c Merge branch 'master' into blender2.8 2017-12-05 22:38:13 +01:00
ee120d6293 Fix T53476: File Browser: Selection Issue with 'fill' option.
Fill-selection would only go upward in list of items to find an already
selected one and fill-select all items in-between. Now, in case upward
search fails, it will also intent to go downward, effectiviely allowing
to 'fill-select' from bottom to top.

Note that top-to-bottom keeps priority (i.e. if a top-to-bottom
fill-selection is possible, it will always happen, even if a
bottom-to-top one is also possible).
2017-12-05 22:34:49 +01:00
272973804e Merge branch 'master' into blender2.8 2017-12-05 19:04:34 +01:00
855799ecc1 Fix T53430: Cut at the strip end fails w/ endstill 2017-12-06 04:52:38 +11:00
a580565086 CMake: avoid checking each MSVC minor revision 2017-12-06 03:38:44 +11:00
a65695759c Fix MSVS2017 compiler version
After last update to Visual Studio 2017 15.5.0 the compiler version changed
2017-12-05 17:16:02 +01:00
3959ce0540 Types are to have explicit forward declaration 2017-12-05 16:54:39 +01:00
702c0a01b2 Cleanup: build warning 2017-12-06 02:25:10 +11:00
6734bb1faf Merge branch 'master' into blender2.8
# Conflicts:
#	source/blender/editors/mesh/editmesh_select.c
2017-12-05 11:19:47 -02:00
70c2d8a1a2 Fix T53469: Make sure that edges are drawn in the backbuff whenever you are looking for the nearest edge
Caused by rB9f5bf19
2017-12-05 11:13:53 -02:00
4f2dd5ad26 Fix for typo in previous commit 2017-12-06 01:14:20 +13:00
52dde11796 Simplify UI-names for B-Bone Ease In/Out settings
For more consistency with the other settings, and increased readability
when the UI is cramped (and it isn't possible to see the whole names).
2017-12-06 00:58:10 +13:00
5d96bc9c5a Version patching fixes for F-Curves (as required for fixes for T48988 and T52009)
* For the T48988 fix (i.e. separate Ease In/Out properties for Bendy Bones
  in Edit vs Pose modes), old animation data needed to be patched to use
  the new property names. This is needed to partially fix some of the
  issues in T53356 (though the Rigify code itself still needs to be patched).

* For the T52009 fix, old files needed to have the frame_start and frame_end
  properties on the FModifier (base-class) updated to match that of the
  FMod_Stepped type-specific class. This wasn't done in the earlier commit
  since it wasn't worth going through all animation data just for the sake
  of updating these relatively-rare settings, but since we're doing it anyway
  now, it makes sense to include this here.
2017-12-06 00:54:39 +13:00
deaeee8e4d Merge branch 'master' into blender2.8 2017-12-05 11:48:37 +01:00
6ebf244ace Added BKE_fcurves_main_cb(), a wrapper around BKE_animdata_main_cb to make it easier to apply fixes to all F-Curves in a file 2017-12-05 17:16:05 +13:00
41b4b8ded6 Cleanup/Style Tweaks to fit rest of code 2017-12-05 17:14:55 +13:00
7d50f16869 drawobject: use float instead of int in glLineWidth 2017-12-04 16:00:21 -02:00
1802d14394 Fix T53463: Rotation numerical input shows instable behaviour.
Inverting a number in radians when user is in degrees gives rather
unexpected results. ;)
2017-12-04 18:40:33 +01:00
3d473d1632 Edit Mesh Selection: Make sure that the line width is 1 pixel 2017-12-04 15:30:56 -02:00
f340f4a2f4 Eevee: CodeStyle: Separate Shader initialization. 2017-12-04 17:21:37 +01:00
5bd008f4dd Eevee: Irradiance Grid: Allocate needed resources instead of a static chunck.
This commit makes the irradiance pool and render target sizes depend on the number of irradiance sample in the whole ViewLayer.
2017-12-04 17:21:37 +01:00
c370fffc9b Resolve MSVC C2229
Code works as expected, but MSVC disallows
2017-12-05 03:05:15 +11:00
40822ae4e9 Depsgraph: Cleanup, indentation 2017-12-04 15:50:38 +01:00
bdc15061fc Better bevel profile at extreme values of profile.
Patch from Richard Erhardt, with some additions & modifications.
Changes bevel profile shape parameter so that can get arbitrarily
near square profile as parameter -> 1.
Adds code to make profile=0 case work, at least for cube corners,
so changed hard min of profile parameter to 0 from 0.15.
2017-12-04 09:36:14 -05:00
d37d6b5a4d Edit Mesh Selection: Fix wrong glPointSize position 2017-12-04 12:32:45 -02:00
3533e082a0 RNA: Use const qualifier for an utility function 2017-12-04 15:26:43 +01:00
aee3560cce Followup to previous merge conflict resolution 2017-12-04 15:26:17 +01:00
bd062f36c0 WM: disable property update messages for fcurves 2017-12-05 01:31:12 +11:00
3b3e612752 Merge branch 'master' into blender2.8 2017-12-04 15:15:23 +01:00
0f8228a890 Depsgraph: Add parameters nodes for bone custom properties
Currently shouldn't make any difference, but this is something what needs to be
done to sanitize drivers relations )with the idea to re-use some generic code
to get operations for driver variables.
2017-12-04 15:10:14 +01:00
9f5bf197a0 Edit Mesh Selection: Draw the backbuff of edge selection only when requested
And make sure the width is 1
2017-12-04 12:05:06 -02:00
d974d25497 Depsgraph: Cleanup, move RNA key constructor to it's file 2017-12-04 14:17:17 +01:00
d5e491c9a7 Depsgraph: Cleanup, don't use bracers in relations names
Those don't bring any information.
2017-12-04 14:17:17 +01:00
5f86d6e6eb Depsgraph: Cleanup, node from RNA pointer search 2017-12-04 14:17:17 +01:00
6b72d87def Depsgraph: Remove unused property based update tags
Those are unused, and not clear whether we will ever support this.

Seems to be better having more like "component" tags, would be less magic
involved to guess what exactly is to be tagged.
2017-12-04 14:17:17 +01:00
6a6aeaac7d Fix bplayer (c). 2017-12-04 14:14:42 +01:00
47fa3e7b27 Merge branch 'master' into blender2.8
Conflicts:
	source/blender/blenloader/BLO_readfile.h
	source/blender/blenloader/intern/readfile.c
	source/blender/windowmanager/intern/wm_files_link.c
2017-12-04 14:07:39 +01:00
0868a2b610 Cleanup: link/append: get rid of booleans in func parameters.
One or two are OK, but more make it rather unreadable, and future work
is likely to require more toggle specific behavior here. So switched to
bitflags, switching from short to int and using 16 upper bits for
'internal' ones defined in BLO_readfile.h, combined with 'public' ones
from user interaction, defined in DNA_space_types.h
2017-12-04 13:09:13 +01:00
Danrae Pray
a1df65c9dd Small cleanup from previous commit by Danrae Pray (@spockTheGray)
I (Dalai) messed up the git author from previous commit (68fdcf07a1).
So this is a follow up on that, properly credited.
2017-12-04 07:53:27 -02:00
Dalai Felinto
68fdcf07a1 Fix T53415: Outliner: Crash when deleting collections
Updated collection_delete_exec() so we don't try to delete elements as we search
the outliner tree anymore.

Now we search the whole tree first for the selected nodes that need to be
deleted and delete them afterward.

Reviewers: dfelinto

Tags: #bf_blender_2.8

Differential Revision: https://developer.blender.org/D2936
Differential Revision: https://developer.blender.org/D2940
2017-12-04 07:40:23 -02:00
7a8ac1b09b WM: message bus replacement for property notifiers
Use dynamically generated message publish/subscribe
so buttons and manipulators update properly.

This resolves common glitches where manipulators weren't updating
as well as the UI when add-ons exposed properties which
hard coded listeners weren't checking for.

Python can also publish/scribe changes via `bpy.msgbus`.

See D2917
2017-12-04 20:42:34 +11:00
5b6cfa705c Eevee: Irradiance Visibility: Initial Implementation
This augment the existing irradiance grid with a new visibility precomputation.
We store a small shadowmap for each grid sample so that light does not leak through walls and such.

The visibility parameter are similar to the one used by the Variance Shadow Map for point lights.

Technical details:

We store the visibility in the same texture (array) as the irradiance itself (in order to reduce the number of sampler).
But the irradiance and the visibility are not the same data so we must encode them in order to use the same texture format.
We use RGBA8 normalized texture and encode irradiance as RGBE (shared exponent).
Using RGBE encoding instead of R11_G11_B10 may lead to some lighting changes, but quality seems to be nearly the same in my test cases.
Using full RGBA16/32F maybe a future option but that will require much more memory and reduce the perf significantly.

Visibility moments (VSM) are encoded as 16bits fixed point precision using a special range. This seems to retain enough precision for the needs.
Also interpolation does not seems to be big problem (even though it's incorrect).
2017-12-04 10:10:27 +01:00
847f568bf5 Eevee: Irradiance Visibility: Add RNA / Engine properties 2017-12-04 10:10:27 +01:00
d439e87064 Eevee: Irradiance Grid: Fix problem with bounce update.
Before this patch, if one of the grid was updated (moved) only the subsequents evaluated grids had their level reset and had all their bounces recomputed.
2017-12-04 10:10:27 +01:00
eb605c2c2b Eevee: Irradiance Grid: Fix Multibounce baking.
The baking was only recording one bounce because the double buffer setup was buggy.
2017-12-04 10:10:27 +01:00
9dfbd98339 Cleanup: whitespace 2017-12-04 17:20:26 +11:00
1b2f8b2754 Merge branch 'master' into blender2.8 2017-12-04 16:51:07 +11:00
5c27523808 Cleanup: wrap long function args in seqeffects 2017-12-04 16:49:30 +11:00
d47d263b4b Cleanup: style 2017-12-04 16:37:31 +11:00
705d214349 Fix crash w/ template search & invalid property 2017-12-04 16:19:01 +11:00
09cade6ca4 Fix MSVC compilation, there is no 'Designated initializers' in C++!
Looks like gcc is at the very least missing a warning here!
2017-12-02 18:25:09 +01:00
e1eb1fbfca BLI_ghash: Description of GHash, GSet
Also some re-indenting.
2017-12-03 03:35:45 +11:00
9f12eb087f Cleanup: minor change to API use 2017-12-02 22:42:14 +11:00
c2d795ebf8 Cleanup: indentation 2017-12-02 22:35:09 +11:00
d64d8b5be5 Fix Cycles standalone crash when saving output, after recent refactoring. 2017-12-02 05:45:09 +01:00
0c37824bfa Draw Maganer: Cleanup: Remove unnecessary lines of code in draw_cache_impl_metaball.c 2017-12-01 18:25:46 -02:00
Dalai Felinto
aa0c9867b2 unittests: Update (fix) unittests after workspace API change
Tests were broken since e8c15e0ed1.

We now get view_layer from window, not workspace, since the same workspace can
have a different view_layer depending on the window scene.
2017-12-01 16:08:52 -02:00
Dalai Felinto
e9cf3fae8e Fixup for workspace view_layer fix
We do not assume subversion bump until we actually change the subversion.

For example, a branch may have bumped its subversion to 3, yet still require
the new doversion code introduced on 108c4bd502.
2017-12-01 15:28:29 -02:00
Julian Eisel
108c4bd502 Fix crash reading 2.8 files with workspace.view_layer set
Stupid error from e8c15e0ed1.

Also removed WorkSpace.view_layer usage and marked as deprecated.
2017-12-01 18:14:24 +01:00
d10578df46 Depsgraph: Call editors update after everything was flushed
This way we can inform editors about all edits at once. Currently this is not
used, but in the next commits we will inform editors about what exactly has
changed.
2017-12-01 17:59:47 +01:00
bbb86a85fc Cleanup: Proper silencing of unused vars( for now). 2017-12-01 17:58:15 +01:00
3d50722cf5 Fix warnings in release builds. 2017-12-01 17:42:13 +01:00
a5454e8711 Cleanup: forgot to rename RNA prop flag to override_static... 2017-12-01 17:42:13 +01:00
6365ddcab5 Depsgraph: Separate loop for ID node flags clear
This ends up in less number of memory writes, which should have positive effect
on performance.
2017-12-01 17:32:00 +01:00
Dalai Felinto
59e8b72881 Fix update of non-scene owned layer collections
We are using NC_SCENE | ND_LAYER_CONTENT for the shader, however this does not work for groups
unless we manually handle the notifiers.

Otherwise the group id is passed, and the listener never gets the notification since a scene id
is expected, or no id at all.
2017-12-01 14:15:54 -02:00
Dalai Felinto
f91e057786 Groups and collection: editing group collections
Allow users to edit either the object group active collection or view layer one

We can't support users selecting the group collections from the outliner group
because that would be imply having an active group for the scene or workspace.

But the way it is now allows to see and edit the collection values after the
group is instanced.
2017-12-01 14:15:54 -02:00
Dalai Felinto
aeaf87bbeb Groups and collection: create group from collection
You could still create groups as before, with Ctl + G. This will create a group
with a single visible collection.

However you can also create a group from an existing collection. Just go to
the menu you get in the outliner when clicking in a collection and pick
"Create Group".

Remember to instance the group afterwards, or link it into a new scene or file.

The group and the collection are not kept in sync afterwards. You need to manually
edit the group for further changes.
2017-12-01 14:15:54 -02:00
Dalai Felinto
be9e469ead Groups and collection: initial integration
Since we are ditching layers from Blender (2.8) we need a replacement to
control groups visibility. This commit introduces collections as the building
blocks for groups, allowing users to control visibility as well as overrides
for groups.

Features
========

* Groups now have collections
    This way you can change the visibility of a collection inside a group, and add
    overrides which are part of the group and are prioritized over other overrides.

* Outliner
    Groups can inspect their collections, change visibility, and add/remove members.

    To change an override of a group collection, you need to select an instance of
    the group, and then you can choose "group" in the collection properties editor
    to edit this group active collection instead of the view layer one.

* Dupli groups overrides
    We can now have multiple instances of the same group with an original "override"
    and different overrides depending on the collection the instanced object is part
    of.

Technical
=========

* Layers
    We use the same api for groups and scene as much as possible.

Reviewers: sergey (depsgraph), mont29 (read/write and user count)
Differential Revision: https://developer.blender.org/D2892
2017-12-01 14:15:54 -02:00
Julian Eisel
e8c15e0ed1 Workspaces: Store an active view-layer per scene
Instead of storing a single active view-layer in the workspace, one is
stored for each scene the workspace showed before.
With this, some things become possible:
* Multiple windows in the same workspace but showing different scenes.
* Toggling back and forth scene keeps same active view-layer for each scene.
* Activating workspace which didn't show current scene before, the current view-layer is kept.

A necessary evil for this is that accessing view-layer and object mode
from .py can't be done via workspace directly anymore. It has to be done
through the window, so RNA can use the correct scene.
So instead of `workspace.view_layer`, it's `window.view_layer` now (same
with mode) even though it's still workspace data.

Fixes T53432.
2017-12-01 16:15:30 +01:00
983b1a3478 Depsgraph: Cleanup, simplify evaluation flush function
Also avoid once queue push for cases when current operation has multiple
outgoing relations.
2017-12-01 16:05:17 +01:00
Dalai Felinto
a9101b332e Silence warning from object_relations.c 2017-12-01 12:39:55 -02:00
92ff0d562c Depsgraph: Remove legacy recalc flag from DNA 2017-12-01 12:26:32 +01:00
3b706723ac Depsgraph: Remove clear of legacy unused flag 2017-12-01 12:18:19 +01:00
a96e97a83f Depsgraph: Move away from setting old deprecated object recalc flags
Those shouldn't be used anywhere for real now.
2017-12-01 12:17:23 +01:00
9bbffd4e02 Depsgraph: Don't use legacy flags in versioning code
Wondering whether files from 2.37 are still working fine.
Don't have that version of Blender running here, so can't test :(
2017-12-01 12:16:29 +01:00
b2952023b6 Depsgraph: Use per-ID flags to see whether update is needed
This is actually functions which needs bigger reconsideration, but for now let's
try to keep them working as much as possible.
2017-12-01 12:11:38 +01:00
146f2e1d02 Depsgraph: Use new per-ID tags to see whether object in a group needs an update
This wouldn't be less precise than object level flag in theory, and we need to
move away from such a duplicating flags.
2017-12-01 12:09:26 +01:00
ecbdc3f1d4 Transform: Avoid attempt to bypass dependency graph update
It's not possible to bypass new depsgraph, but also flush to other CoW copies
might be needed here.
2017-12-01 12:07:41 +01:00
2ae709d282 Transform: Use new DEG query API to see what's being affected by a changing object
This avoids us from directly calling object update, and doing other type of
update flushing.

Prepares us to get rid of Object->recalc flags.
2017-12-01 11:40:50 +01:00
0591fb17e9 Depsgraph: Add query API to traverse all dependent IDs of the given ID 2017-12-01 11:40:50 +01:00
7270e8cc8f Depsgraph: Move iterator to own implementation file 2017-12-01 11:40:50 +01:00
59d3a17e3a Depsgraph: Cleanup, use enum value rather than a define 2017-12-01 11:40:50 +01:00
27a1bd445b Depsgraph: Cleanup, naming
It makes more sense to stick to DEG_iterator_object order in name, since we can
have functions to iterate over different entities and we want all of them to
have common prefix.
2017-12-01 11:40:50 +01:00
2838a7646b _gawain python module: Add methods "program_use_begin" and "program_use_end"
Required to updade uniforms
2017-12-01 04:25:47 -02:00
605ce90c54 RNA: Fix unreported: Some callbacks called when updating properties were incorrect 2017-11-30 16:53:15 -02:00
1d33843ea6 Removing OMP: legacy ccgsubsurf.
Performances gain is rather low this time, about 5% on average (in whole
affected functions).
2017-11-30 19:48:23 +01:00
Dalai Felinto
58c743f7cc Depsgraph: Add assert to make sure the view layer is part of the scene
Which is not in some cases since workspace is still partly implemented.
2017-11-30 13:44:34 -02:00
f3de312b83 Transform: Fix recent merge conflict resolution fiasco
Why is it called legacy when this is a legit flags which are still to be checked
at a runtime???
2017-11-30 16:36:24 +01:00
a989913dd4 Merge branch 'master' into blender2.8 2017-11-30 15:11:06 +01:00
c241d79dc8 Transform: Use single flag with more meaningful name to prevent snapping to a dependent object
The idea of this flag was to prevent snapping onto an object which depends on
currently modifying ones. Using single flag makes more sense here, and also
makes it possible to replace some ob->recalc based magic with depsgraph query
to set those flags.
2017-11-30 15:03:48 +01:00
47a4a7c8b7 Transform: Remove some legacy code about snapping in particle edit mode
It looks stupid to first force some flag being set and then have workaround
to ignore that flag in snapping code. Let's just not set the flag in the first
place.

The only useful situation where such snapping was usable is to move roots of
disconnected hair, which still works just fine. However, there might be some
other hidden corner case where this workaround was needed.
2017-11-30 14:52:34 +01:00
Dalai Felinto
79bbbf7e20 Fix memory leak when single_obdata_users() fails to copy datablock 2017-11-30 11:08:48 -02:00
Dalai Felinto
ba17d53e59 Fix lightprobe single user not working 2017-11-30 11:08:48 -02:00
edef559808 Depsgraph: Fix crash on playback of animated objects when CoW is enabled
We should keep base_flags after CoW object datablock was updated. Not entirely
happy with current solution, but it fixes crash and allows us to run tests
again.

More proper solution would be to make CoW operation a per-component thingie,
which will only update corresponding parts.
2017-11-30 13:42:56 +01:00
Dalai Felinto
33d2535189 Layer: Copy layer collection properties when doing a full copy of scene 2017-11-30 10:08:26 -02:00
69a7ece389 Depsgraph: Fix wrong remapping of compositor node tree when CoW is enabled 2017-11-30 12:36:37 +01:00
c601ef7d7d Depsgraph: Fix missing objects in viewport when CoW is enabled
Remapping of pointers did not work properly, since it had no pointers yet to
remap base->object to a CoW object.
2017-11-30 12:36:37 +01:00
1c5c3748b5 Depsgraph: Make sure we pass proper base to object builder 2017-11-30 12:36:37 +01:00
60d6cc8fae Depsgraph: Make a note about why is it OK to pass original base in relations builder 2017-11-30 12:36:37 +01:00
83cc73083f Depsgraph: Properly pass flags when COW is not used 2017-11-30 12:36:37 +01:00
d0ed6dff82 Depsgraph: Cleanup spelling 2017-11-30 12:36:37 +01:00
Dalai Felinto
2296b9776a Depsgraph: Tag all id_types on_visible_update
We need all id nodes to be evaluated at least once when opening a file.
This is particuarly required for the upcoming group collection patch.
2017-11-30 09:23:10 -02:00
ced2f3f30e Merge branch 'master' into blender2.8 2017-11-30 11:59:28 +01:00
059b878240 Depsgraph: More full explanation for previous commit 2017-11-30 11:57:21 +01:00
Dalai Felinto
4b9b9dbf93 Depsgraph: Fix DEG_id_type_tag comment 2017-11-30 08:53:11 -02:00
03a5eccc94 Merge branch 'master' into blender2.8 2017-11-30 18:30:41 +11:00
28d2148b09 Haiku OS Support
D2860 by @miqlas

Even though Haiku is a niche OS, only minor changes are needed.
2017-11-30 18:05:21 +11:00
fa3d50af95 Cycles: Improve denoising speed on GPUs with small tile sizes
Previously, the NLM kernels would be launched once per offset with one thread per pixel.
However, with the smaller tile sizes that are now feasible, there wasn't enough work to fully occupy GPUs which results in a significant slowdown.

Therefore, the kernels are now launched in a single call that handles all offsets at once.
This has two downsides: Memory accesses to accumulating buffers are now atomic, and more importantly, the temporary memory now has to be allocated for every shift at once, increasing the required memory.
On the other hand, of course, the smaller tiles significantly reduce the size of the memory.

The main bottleneck right now is the construction of the transformation - there is nothing to be parallelized there, one thread per pixel is the maximum.
I tried to parallelize the SVD implementation by storing the matrix in shared memory and launching one block per pixel, but that wasn't really going anywhere.

To make the new code somewhat readable, the handling of rectangular regions was cleaned up a bit and commented, it should be easier to understand what's going on now.
Also, some variables have been renamed to make the difference between buffer width and stride more apparent, in addition to some general style cleanup.
2017-11-30 07:37:08 +01:00
df7b9fa2ee Fix T53410: 3D Text always recalculated 2017-11-30 17:08:37 +11:00
099a99dbc9 Select similar for bones by group index
D2931 by @col-one
2017-11-30 14:42:18 +11:00
9f1048481c Fix T53420: Vertex Groups: The "-" button gets a hidden function
Guess 'remove all unlocked' is new-ish feature...

To be backported to 2.79a (I think).
2017-11-29 20:19:07 +01:00
José Luis Oliveira Cunha
5ec8a9ac27 Fix T53116: default texture coordinates for volume materials are blank.
Differential Revision: https://developer.blender.org/D2935
2017-11-29 19:21:51 +01:00
84d39ab97b Merge branch 'master' into blender2.8 2017-11-29 18:13:06 +01:00
e4b54f44c1 Cycles: add object level holdout property.
This works the same as the holdout shader and Z mask layer. Combined with
overrides in 2.8 this is intended to replace the Z mask layer bits.
2017-11-29 18:11:40 +01:00
Maxym Dmytrychenko
7e349f2745 Cycles: improve triangle intersection performance.
Reduces render time by about 1-2% in benchmark scenes.

Differential Revision: https://developer.blender.org/D2911
2017-11-29 18:11:40 +01:00
Maikon Araujo
4b4702ab8a Sequencer: add many more color blend modes, and a new color mix strip.
Differential Revision: https://developer.blender.org/D2872
2017-11-29 18:11:36 +01:00
4f7280da40 Fix paint float color blending bugs with alpha 1.0 and vivid light.
For some blend modes there would be no effect with factor 1.0, even if factor
0.999 would give a very different image. Now the result should have no
discontinuity.

Differential Revision: https://developer.blender.org/D2925
2017-11-29 18:01:36 +01:00
baaf81e13e Merge branch 'master' into blender2.8 2017-11-29 17:59:04 +01:00
5b5939c6e6 Depsgraph: Cleanup, use explicit NULL pointer checks 2017-11-29 17:55:28 +01:00
1879 changed files with 94442 additions and 91767 deletions

View File

@@ -195,7 +195,7 @@ endif()
# Options
# First platform specific non-cached vars
if(UNIX AND NOT APPLE)
if(UNIX AND NOT (APPLE OR HAIKU))
set(WITH_X11 ON)
endif()
@@ -253,6 +253,8 @@ option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" _init_OPEN
option(WITH_OPENVDB "Enable features relying on OpenVDB" OFF)
option(WITH_OPENVDB_BLOSC "Enable blosc compression for OpenVDB, only enable if OpenVDB was built with blosc support" OFF)
option(WITH_OPENVDB_3_ABI_COMPATIBLE "Assume OpenVDB library has been compiled with version 3 ABI compatibility" OFF)
mark_as_advanced(WITH_OPENVDB_3_ABI_COMPATIBLE)
# GHOST Windowing Library Options
option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF)
@@ -312,7 +314,6 @@ endif()
# Modifiers
option(WITH_MOD_FLUID "Enable Elbeem Modifier (Fluid Simulation)" ON)
option(WITH_MOD_SMOKE "Enable Smoke Modifier (Smoke Simulation)" ON)
option(WITH_MOD_BOOLEAN "Enable Boolean Modifier" ON)
option(WITH_MOD_REMESH "Enable Remesh Modifier" ON)
# option(WITH_MOD_CLOTH_ELTOPO "Enable Experimental cloth solver" OFF) # this is now only available in a branch
# mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
@@ -415,16 +416,25 @@ option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
option(WITH_CYCLES_OSL "Build Cycles with OSL support" ${_init_CYCLES_OSL})
option(WITH_CYCLES_OPENSUBDIV "Build Cycles with OpenSubdiv support" ${_init_CYCLES_OPENSUBDIV})
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 CACHE STRING "CUDA architectures to build binaries for")
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 CACHE STRING "CUDA architectures to build binaries for")
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
unset(PLATFORM_DEFAULT)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
option(WITH_CYCLES_DEBUG "Build Cycles with extra debug capabilities" OFF)
option(WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF)
mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER)
mark_as_advanced(WITH_CYCLES_LOGGING)
mark_as_advanced(WITH_CYCLES_DEBUG)
mark_as_advanced(WITH_CYCLES_NATIVE_ONLY)
option(WITH_CYCLES_DEVICE_CUDA "Enable Cycles CUDA compute support" ON)
option(WITH_CYCLES_DEVICE_OPENCL "Enable Cycles OpenCL compute support" ON)
option(WITH_CYCLES_NETWORK "Enable Cycles compute over network support (EXPERIMENTAL and unfinished)" OFF)
mark_as_advanced(WITH_CYCLES_DEVICE_CUDA)
mark_as_advanced(WITH_CYCLES_DEVICE_OPENCL)
mark_as_advanced(WITH_CYCLES_NETWORK)
option(WITH_CUDA_DYNLOAD "Dynamically load CUDA libraries at runtime" ON)
mark_as_advanced(WITH_CUDA_DYNLOAD)
@@ -456,7 +466,8 @@ option(WITH_BOOST "Enable features depending on boost" ON)
# Unit testsing
option(WITH_GTESTS "Enable GTest unit testing" OFF)
option(WITH_OPENGL_TESTS "Enable OpenGL related unit testing (Experimental)" OFF)
option(WITH_OPENGL_RENDER_TESTS "Enable OpenGL render related unit testing (Experimental)" OFF)
option(WITH_OPENGL_DRAW_TESTS "Enable OpenGL UI drawing related unit testing (Experimental)" OFF)
# Documentation
@@ -531,6 +542,9 @@ if(WIN32)
set(WINDOWS_CODESIGN_PFX_PASSWORD CACHE STRING "password for pfx file used for codesigning.")
mark_as_advanced(WINDOWS_CODESIGN_PFX_PASSWORD)
option(WINDOWS_USE_VISUAL_STUDIO_FOLDERS "Organize the visual studio project according to source folders." ON)
mark_as_advanced(WINDOWS_USE_VISUAL_STUDIO_FOLDERS)
endif()
# avoid using again
@@ -634,9 +648,8 @@ if(NOT WITH_BOOST)
set_and_warn(WITH_INTERNATIONAL OFF)
set_and_warn(WITH_OPENVDB OFF)
set_and_warn(WITH_OPENCOLORIO OFF)
set_and_warn(WITH_MOD_BOOLEAN OFF)
elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR
WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_MOD_BOOLEAN)
WITH_OPENVDB OR WITH_OPENCOLORIO)
# Keep enabled
else()
# New dependency graph needs either Boost or C++11 for function bindings.
@@ -710,6 +723,15 @@ if(WITH_AUDASPACE)
endif()
endif()
# Auto-enable CUDA dynload if toolkit is not found.
if(NOT WITH_CUDA_DYNLOAD)
find_package(CUDA)
if (NOT CUDA_FOUND)
message("CUDA toolkit not found, using dynamic runtime loading of libraries instead")
set(WITH_CUDA_DYNLOAD ON)
endif()
endif()
#-----------------------------------------------------------------------------
# Check for valid directories
# ... a partial checkout may cause this.
@@ -729,7 +751,7 @@ if(WITH_INTERNATIONAL)
endif()
if(WITH_PYTHON)
# While we have this as an '#error' in bpy_util.h,
# While we have this as an '#error' in 'bpy_capi_utils.h',
# upgrading Python tends to cause confusion for users who build.
# Give the error message early to make this more obvious.
#
@@ -1221,7 +1243,7 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
if(WIN32)
set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/glog/src/windows)
else()
set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/glog/src)
set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/glog/include)
endif()
endif()
endif()
@@ -1358,6 +1380,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
# flags to undo strict flags
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0"))
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough)
@@ -1422,8 +1445,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
# disable numbered, false positives
set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556")
set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556")
set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
# most msvc warnings are C & C++
set(_WARNINGS
@@ -1441,6 +1464,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
"/wd4267" # conversion from 'size_t' to 'type', possible loss of data
"/wd4305" # truncation from 'type1' to 'type2'
"/wd4800" # forcing value to bool 'true' or 'false'
"/wd4828" # The file contains a character that is illegal
# errors:
"/we4013" # 'function' undefined; assuming extern returning int
"/we4133" # incompatible pointer types
@@ -1705,7 +1729,6 @@ if(FIRST_RUN)
endif()
info_cfg_text("Modifiers:")
info_cfg_option(WITH_MOD_BOOLEAN)
info_cfg_option(WITH_MOD_REMESH)
info_cfg_option(WITH_MOD_FLUID)
info_cfg_option(WITH_MOD_OCEANSIM)

View File

@@ -48,6 +48,11 @@ DEPS_SOURCE_DIR:=$(BLENDER_DIR)/build_files/build_environment
DEPS_BUILD_DIR:=$(BUILD_DIR)/deps
DEPS_INSTALL_DIR:=$(shell dirname "$(BLENDER_DIR)")/lib/$(OS_NCASE)
ifneq ($(OS_NCASE),darwin)
# Add processor type to directory name
DEPS_INSTALL_DIR:=$(DEPS_INSTALL_DIR)_$(shell uname -p)
endif
# Allow to use alternative binary (pypy3, etc)
ifndef PYTHON
PYTHON:=python3

View File

@@ -58,7 +58,6 @@ include(cmake/openexr.cmake)
include(cmake/freetype.cmake)
include(cmake/freeglut.cmake)
include(cmake/glew.cmake)
include(cmake/hdf5.cmake)
include(cmake/alembic.cmake)
include(cmake/glfw.cmake)
include(cmake/clew.cmake)

View File

@@ -53,17 +53,20 @@ if(WIN32)
if(BUILD_MODE STREQUAL Release)
set(BOOST_HARVEST_CMD ${BOOST_HARVEST_CMD} && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-1_60/ ${HARVEST_TARGET}/boost/include/)
endif()
set(BOOST_PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/boost/src/external_boost < ${PATCH_DIR}/boost.diff)
elseif(APPLE)
set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
set(BOOST_BUILD_COMMAND ./bjam)
set(BOOST_BUILD_OPTIONS toolset=clang cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} --disable-icu boost.locale.icu=off)
set(BOOST_HARVEST_CMD echo .)
set(BOOST_PATCH_COMMAND echo .)
else()
set(BOOST_HARVEST_CMD echo .)
set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
set(BOOST_BUILD_COMMAND ./bjam)
set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off)
set(BOOST_PATCH_COMMAND echo .)
endif()
set(BOOST_OPTIONS
@@ -96,6 +99,7 @@ ExternalProject_Add(external_boost
URL_HASH MD5=${BOOST_MD5}
PREFIX ${BUILD_DIR}/boost
UPDATE_COMMAND ""
PATCH_COMMAND ${BOOST_PATCH_COMMAND}
CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND}
BUILD_COMMAND ${BOOST_BUILD_COMMAND} ${BOOST_BUILD_OPTIONS} -j${MAKE_THREADS} architecture=x86 address-model=${BOOST_ADDRESS_MODEL} variant=${BOOST_BUILD_TYPE} link=static threading=multi ${BOOST_OPTIONS} --prefix=${LIBDIR}/boost install
BUILD_IN_SOURCE 1

View File

@@ -102,8 +102,6 @@ if(BUILD_MODE STREQUAL Release)
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/python/ ${HARVEST_TARGET}/python/ &&
# alembic
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/alembic ${HARVEST_TARGET}/alembic &&
# hdf5
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5 ${HARVEST_TARGET}/hdf5 &&
# BlendThumb
${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb64/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb64.dll &&
${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb32/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb.dll &&

View File

@@ -25,6 +25,7 @@ if(BUILD_MODE STREQUAL Release)
-DALSOFT_CONFIG=Off
-DALSOFT_HRTF_DEFS=Off
-DALSOFT_INSTALL=On
-DALSOFT_BACKEND_SNDIO=Off
)
if(UNIX)

View File

@@ -90,6 +90,7 @@ set(OPENIMAGEIO_EXTRA_ARGS
-DUSE_PYTHON=OFF
-DUSE_PYTHON3=OFF
-DUSE_OCIO=OFF
-DUSE_WEBP=${WITH_WEBP}
-DOIIO_BUILD_TOOLS=${OIIO_TOOLS}
-DOIIO_BUILD_TESTS=OFF
-DBUILD_TESTING=OFF

View File

@@ -49,6 +49,13 @@ if(MSVC)
CMAKE_ARGS ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg_msvc -DBUILD_SHARED_LIBS=Off -DBUILD_THIRDPARTY=OFF
INSTALL_DIR ${LIBDIR}/openjpeg_msvc
)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_openjpeg_msvc after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openjpeg_msvc/lib ${HARVEST_TARGET}/openjpeg/lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openjpeg_msvc/include ${HARVEST_TARGET}/openjpeg/include
DEPENDEES install
)
endif()
endif()
set(OPENJPEG_LIBRARY libopenjpeg${LIBEXT})

View File

@@ -43,7 +43,7 @@ if(WIN32)
set(OPENSUBDIV_EXTRA_ARGS
${OPENSUBDIV_EXTRA_ARGS}
-DNO_CUDA=${OPENSUBDIV_CUDA}
-DCLEW_INCLUDE_DIR=${LIBDIR}/clew/include/cl
-DCLEW_INCLUDE_DIR=${LIBDIR}/clew/include/CL
-DCLEW_LIBRARY=${LIBDIR}/clew/lib/clew${LIBEXT}
-DCUEW_INCLUDE_DIR=${LIBDIR}/cuew/include
-DCUEW_LIBRARY=${LIBDIR}/cuew/lib/cuew${LIBEXT}
@@ -54,6 +54,7 @@ else()
${OPENSUBDIV_EXTRA_ARGS}
-DNO_CUDA=ON
-DCUEW_INCLUDE_DIR=${LIBDIR}/cuew/include
-DCLEW_INCLUDE_DIR=${LIBDIR}/clew/include/CL
-DCLEW_LIBRARY=${LIBDIR}/clew/lib/static/${LIBPREFIX}clew${LIBEXT}
)
endif()

View File

@@ -27,7 +27,7 @@ else()
set(SNDFILE_OPTIONS --enable-static --disable-shared )
endif()
if(APPLE)
if(UNIX)
set(SNDFILE_PATCH_CMD ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/sndfile/src/external_sndfile < ${PATCH_DIR}/sndfile.diff)
else()
set(SNDFILE_PATCH_CMD)

View File

@@ -23,6 +23,14 @@ set(TBB_EXTRA_ARGS
-DTBB_BUILD_STATIC=On
)
if(TBB_VERSION MATCHES 2018)
set(TBB_VS_VERSION vs2013)
elseif(TBB_VERSION MATCHES 2017)
set(TBB_VS_VERSION vs2012)
else()
set(TBB_VS_VERSION vs2010)
endif()
# CMake script for TBB from https://github.com/wjakob/tbb/blob/master/CMakeLists.txt
ExternalProject_Add(external_tbb
URL ${TBB_URI}
@@ -30,7 +38,7 @@ ExternalProject_Add(external_tbb
URL_HASH MD5=${TBB_HASH}
PREFIX ${BUILD_DIR}/tbb
PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_tbb.txt ${BUILD_DIR}/tbb/src/external_tbb/CMakeLists.txt &&
${CMAKE_COMMAND} -E copy ${BUILD_DIR}/tbb/src/external_tbb/build/vs2010/version_string.ver ${BUILD_DIR}/tbb/src/external_tbb/src/tbb/version_string.ver
${CMAKE_COMMAND} -E copy ${BUILD_DIR}/tbb/src/external_tbb/build/${TBB_VS_VERSION}/version_string.ver ${BUILD_DIR}/tbb/src/external_tbb/src/tbb/version_string.ver
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tbb ${DEFAULT_CMAKE_FLAGS} ${TBB_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/tbb
)

View File

@@ -104,10 +104,10 @@ set(OPENCOLORIO_URI https://github.com/imageworks/OpenColorIO/archive/6de971097c
set(OPENCOLORIO_HASH c9de0fd98f26ce6f2e08d617ca68b8e4)
set(LLVM_VERSION 3.4.2)
set(LLVM_URI http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.gz)
set(LLVM_URI http://releases.llvm.org/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.gz)
set(LLVM_HASH a20669f75967440de949ac3b1bad439c)
set(CLANG_URI http://llvm.org/releases/${LLVM_VERSION}/cfe-${LLVM_VERSION}.src.tar.gz)
set(CLANG_URI http://releases.llvm.org/${LLVM_VERSION}/cfe-${LLVM_VERSION}.src.tar.gz)
set(CLANG_HASH 87945973b7c73038871c5f849a818588)
set(OPENIMAGEIO_VERSION 1.7.15)
@@ -137,9 +137,16 @@ set(PYTHON_SHORT_VERSION_NO_DOTS 36)
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_HASH 2c68846471994897278364fc18730dd9)
set(TBB_VERSION 44_20160128)
set(TBB_URI https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb${TBB_VERSION}oss_src_0.tgz)
set(TBB_HASH 9d8a4cdf43496f1b3f7c473a5248e5cc)
if(UNIX AND NOT APPLE)
# Needed to be compatible with GCC 7, other platforms can upgrade later
set(TBB_VERSION 2017_U7)
set(TBB_URI https://github.com/01org/tbb/archive/${TBB_VERSION}.tar.gz)
set(TBB_HASH 364f2a4b80e978f38a69cbf7c466b898)
else()
set(TBB_VERSION 44_20160128)
set(TBB_URI https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb${TBB_VERSION}oss_src_0.tgz)
set(TBB_HASH 9d8a4cdf43496f1b3f7c473a5248e5cc)
endif()
set(OPENVDB_VERSION 3.1.0)
set(OPENVDB_URI https://github.com/dreamworksanimation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz)

View File

@@ -753,8 +753,8 @@ OIIO_SOURCE=( "https://github.com/OpenImageIO/oiio/archive/Release-$OIIO_VERSION
OIIO_SOURCE_REPO=( "https://github.com/OpenImageIO/oiio.git" )
OIIO_SOURCE_REPO_UID="c9e67275a0b248ead96152f6d2221cc0c0f278a4"
LLVM_SOURCE=( "http://llvm.org/releases/$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.gz" )
LLVM_CLANG_SOURCE=( "http://llvm.org/releases/$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.gz" "http://llvm.org/releases/$LLVM_VERSION/cfe-$LLVM_VERSION.src.tar.gz" )
LLVM_SOURCE=( "http://releases.llvm.org/$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.gz" )
LLVM_CLANG_SOURCE=( "http://releases.llvm.org/$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.gz" "http://llvm.org/releases/$LLVM_VERSION/cfe-$LLVM_VERSION.src.tar.gz" )
OSL_USE_REPO=false
OSL_SOURCE=( "https://github.com/imageworks/OpenShadingLanguage/archive/Release-$OSL_VERSION.tar.gz" )
@@ -1254,7 +1254,11 @@ compile_Boost() {
#### Build OCIO ####
_init_ocio() {
_src=$SRC/OpenColorIO-$OCIO_VERSION
_git=false
if [ "$OCIO_USE_REPO" = true ]; then
_git=true
else
_git=false
fi
_inst=$INST/ocio-$OCIO_VERSION
_inst_shortcut=$INST/ocio
}
@@ -1646,7 +1650,6 @@ compile_OIIO() {
cmake_d="$cmake_d -D LINKSTATIC=OFF"
cmake_d="$cmake_d -D USE_SIMD=sse2"
cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION"
cmake_d="$cmake_d -D OPENEXR_VERSION=$OPENEXR_VERSION"
if [ "$_with_built_openexr" = true ]; then
@@ -1665,6 +1668,7 @@ compile_OIIO() {
cmake_d="$cmake_d -D BUILD_TESTING=OFF"
cmake_d="$cmake_d -D OIIO_BUILD_TESTS=OFF"
cmake_d="$cmake_d -D OIIO_BUILD_TOOLS=OFF"
cmake_d="$cmake_d -D TXT2MAN="
#cmake_d="$cmake_d -D CMAKE_EXPORT_COMPILE_COMMANDS=ON"
#cmake_d="$cmake_d -D CMAKE_VERBOSE_MAKEFILE=ON"

View File

@@ -0,0 +1,15 @@
--- a/boost/config/compiler/visualc.hpp 2015-12-08 11:55:19 -0700
+++ b/boost/config/compiler/visualc.hpp 2018-03-17 10:29:52 -0600
@@ -287,12 +287,3 @@
# define BOOST_COMPILER "Microsoft Visual C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION)
#endif
-//
-// last known and checked version is 19.00.23026 (VC++ 2015 RTM):
-#if (_MSC_VER > 1900)
-# if defined(BOOST_ASSERT_CONFIG)
-# error "Unknown compiler version - please run the configure tests and report the results"
-# else
-# pragma message("Unknown compiler version - please run the configure tests and report the results")
-# endif
-#endif

View File

@@ -21,9 +21,9 @@
# ILMBASE_FOUND - True if IlmBase was found.
# Other standarnd issue macros
include (FindPackageHandleStandardArgs)
include (FindPackageMessage)
include (SelectLibraryConfigurations)
include(FindPackageHandleStandardArgs)
include(FindPackageMessage)
include(SelectLibraryConfigurations)
if( ILMBASE_USE_STATIC_LIBS )
@@ -36,42 +36,42 @@ if( ILMBASE_USE_STATIC_LIBS )
endif()
# Macro to assemble a helper state variable
macro (SET_STATE_VAR varname)
set (tmp_ilmbaselibs ${ILMBASE_CUSTOM_LIBRARIES})
separate_arguments (tmp_ilmbaselibs)
set (tmp_lst
macro(SET_STATE_VAR varname)
set(tmp_ilmbaselibs ${ILMBASE_CUSTOM_LIBRARIES})
separate_arguments(tmp_ilmbaselibs)
set(tmp_lst
${ILMBASE_CUSTOM} | ${tmp_ilmbaselibs} |
${ILMBASE_HOME} | ${ILMBASE_VERSION} | ${ILMBASE_LIB_AREA}
)
set (${varname} "${tmp_lst}")
unset (tmp_ilmbaselibs)
unset (tmp_lst)
endmacro ()
set(${varname} "${tmp_lst}")
unset(tmp_ilmbaselibs)
unset(tmp_lst)
endmacro()
# To enforce that find_* functions do not use inadvertently existing versions
if (ILMBASE_CUSTOM)
set (ILMBASE_FIND_OPTIONS "NO_DEFAULT_PATH")
endif ()
if(ILMBASE_CUSTOM)
set(ILMBASE_FIND_OPTIONS "NO_DEFAULT_PATH")
endif()
# Macro to search for an include directory
macro (PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var)
string (TOUPPER ${prefix}_INCLUDE_DIR tmp_varname)
macro(PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var)
string(TOUPPER ${prefix}_INCLUDE_DIR tmp_varname)
find_path(${tmp_varname} ${includefile}
HINTS ${${libpath_var}}
PATH_SUFFIXES include
${ILMBASE_FIND_OPTIONS}
)
if (${tmp_varname})
mark_as_advanced (${tmp_varname})
endif ()
unset (tmp_varname)
endmacro ()
if(${tmp_varname})
mark_as_advanced(${tmp_varname})
endif()
unset(tmp_varname)
endmacro()
# Macro to search for the given library and adds the cached
# variable names to the specified list
macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
string (TOUPPER ${prefix}_${libname} tmp_prefix)
macro(PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
string(TOUPPER ${prefix}_${libname} tmp_prefix)
# Handle new library names for OpenEXR 2.1 build via cmake
string(REPLACE "." "_" _ILMBASE_VERSION ${ILMBASE_VERSION})
string(SUBSTRING ${_ILMBASE_VERSION} 0 3 _ILMBASE_VERSION )
@@ -89,86 +89,90 @@ macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
${ILMBASE_FIND_OPTIONS}
)
# Properly define ${tmp_prefix}_LIBRARY (cached) and ${tmp_prefix}_LIBRARIES
select_library_configurations (${tmp_prefix})
list (APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES)
select_library_configurations(${tmp_prefix})
list(APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES)
# Add to the list of variables which should be reset
list (APPEND ${cachelist_var}
list(APPEND ${cachelist_var}
${tmp_prefix}_LIBRARY
${tmp_prefix}_LIBRARY_RELEASE
${tmp_prefix}_LIBRARY_DEBUG)
mark_as_advanced (
mark_as_advanced(
${tmp_prefix}_LIBRARY
${tmp_prefix}_LIBRARY_RELEASE
${tmp_prefix}_LIBRARY_DEBUG)
unset (tmp_prefix)
endmacro ()
unset(tmp_prefix)
endmacro()
# Encode the current state of the external variables into a string
SET_STATE_VAR (ILMBASE_CURRENT_STATE)
SET_STATE_VAR(ILMBASE_CURRENT_STATE)
# If the state has changed, clear the cached variables
if (ILMBASE_CACHED_STATE AND
if(ILMBASE_CACHED_STATE AND
NOT ILMBASE_CACHED_STATE STREQUAL ILMBASE_CURRENT_STATE)
foreach (libvar ${ILMBASE_CACHED_VARS})
unset (${libvar} CACHE)
endforeach ()
endif ()
foreach(libvar ${ILMBASE_CACHED_VARS})
unset(${libvar} CACHE)
endforeach()
endif()
# Generic search paths
set (IlmBase_generic_include_paths
set(IlmBase_generic_include_paths
${ILMBASE_CUSTOM_INCLUDE_DIR}
/usr/include
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/include
/sw/include
/opt/local/include)
set (IlmBase_generic_library_paths
/opt/local/include
)
set(IlmBase_generic_library_paths
${ILMBASE_CUSTOM_LIB_DIR}
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/lib
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/sw/lib
/opt/local/lib)
/opt/local/lib
)
# Search paths for the IlmBase files
if (ILMBASE_HOME)
if (ILMBASE_VERSION)
set (IlmBase_include_paths
if(ILMBASE_HOME)
if(ILMBASE_VERSION)
set(IlmBase_include_paths
${ILMBASE_HOME}/ilmbase-${ILMBASE_VERSION}/include
${ILMBASE_HOME}/include/ilmbase-${ILMBASE_VERSION})
set (IlmBase_library_paths
${ILMBASE_HOME}/include/ilmbase-${ILMBASE_VERSION}
)
set(IlmBase_library_paths
${ILMBASE_HOME}/ilmbase-${ILMBASE_VERSION}/lib
${ILMBASE_HOME}/lib/ilmbase-${ILMBASE_VERSION})
${ILMBASE_HOME}/lib/ilmbase-${ILMBASE_VERSION}
)
endif()
list (APPEND IlmBase_include_paths ${ILMBASE_HOME}/include)
set (IlmBase_library_paths
list(APPEND IlmBase_include_paths ${ILMBASE_HOME}/include)
set(IlmBase_library_paths
${ILMBASE_HOME}/lib
${ILMBASE_HOME}/lib64
${ILMBASE_LIB_AREA}
${IlmBase_library_paths})
endif ()
list (APPEND IlmBase_include_paths ${IlmBase_generic_include_paths})
list (APPEND IlmBase_library_paths ${IlmBase_generic_library_paths})
endif()
list(APPEND IlmBase_include_paths ${IlmBase_generic_include_paths})
list(APPEND IlmBase_library_paths ${IlmBase_generic_library_paths})
# Locate the header files
PREFIX_FIND_INCLUDE_DIR (IlmBase
PREFIX_FIND_INCLUDE_DIR(IlmBase
OpenEXR/IlmBaseConfig.h IlmBase_include_paths)
if (ILMBASE_INCLUDE_DIR)
if(ILMBASE_INCLUDE_DIR)
# Get the version from config file, if not already set.
if (NOT ILMBASE_VERSION)
if(NOT ILMBASE_VERSION)
FILE(STRINGS "${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h" ILMBASE_BUILD_SPECIFICATION
REGEX "^[ \t]*#define[ \t]+ILMBASE_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
if(ILMBASE_BUILD_SPECIFICATION)
if (NOT IlmBase_FIND_QUIETLY)
if(NOT IlmBase_FIND_QUIETLY)
message(STATUS "${ILMBASE_BUILD_SPECIFICATION}")
endif ()
endif()
string(REGEX REPLACE ".*#define[ \t]+ILMBASE_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
"\\1" XYZ ${ILMBASE_BUILD_SPECIFICATION})
set("ILMBASE_VERSION" ${XYZ} CACHE STRING "Version of ILMBase lib")
@@ -178,71 +182,71 @@ if (ILMBASE_INCLUDE_DIR)
set("ILMBASE_VERSION" "2.0" CACHE STRING "Version of ILMBase lib")
endif()
endif()
endif ()
endif()
if (ILMBASE_CUSTOM)
if (NOT ILMBASE_CUSTOM_LIBRARIES)
message (FATAL_ERROR "Custom IlmBase libraries requested but ILMBASE_CUSTOM_LIBRARIES is not set.")
if(ILMBASE_CUSTOM)
if(NOT ILMBASE_CUSTOM_LIBRARIES)
message(FATAL_ERROR "Custom IlmBase libraries requested but ILMBASE_CUSTOM_LIBRARIES is not set.")
endif()
set (IlmBase_Libraries ${ILMBASE_CUSTOM_LIBRARIES})
set(IlmBase_Libraries ${ILMBASE_CUSTOM_LIBRARIES})
separate_arguments(IlmBase_Libraries)
else ()
#elseif (${ILMBASE_VERSION} VERSION_LESS "2.1")
set (IlmBase_Libraries Half Iex Imath IlmThread)
#else ()
else()
#elseif(${ILMBASE_VERSION} VERSION_LESS "2.1")
set(IlmBase_Libraries Half Iex Imath IlmThread)
#else()
# string(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _ilmbase_libs_ver ${ILMBASE_VERSION})
# set (IlmBase_Libraries Half Iex-${_ilmbase_libs_ver} Imath-${_ilmbase_libs_ver} IlmThread-${_ilmbase_libs_ver})
endif ()
# set(IlmBase_Libraries Half Iex-${_ilmbase_libs_ver} Imath-${_ilmbase_libs_ver} IlmThread-${_ilmbase_libs_ver})
endif()
# Locate the IlmBase libraries
set (IlmBase_libvars "")
set (IlmBase_cachevars "")
foreach (ilmbase_lib ${IlmBase_Libraries})
PREFIX_FIND_LIB (IlmBase ${ilmbase_lib}
set(IlmBase_libvars "")
set(IlmBase_cachevars "")
foreach(ilmbase_lib ${IlmBase_Libraries})
PREFIX_FIND_LIB(IlmBase ${ilmbase_lib}
IlmBase_library_paths IlmBase_libvars IlmBase_cachevars)
endforeach ()
endforeach()
# Create the list of variables that might need to be cleared
set (ILMBASE_CACHED_VARS
set(ILMBASE_CACHED_VARS
ILMBASE_INCLUDE_DIR ${IlmBase_cachevars}
CACHE INTERNAL "Variables set by FindIlmBase.cmake" FORCE)
# Store the current state so that variables might be cleared if required
set (ILMBASE_CACHED_STATE ${ILMBASE_CURRENT_STATE}
set(ILMBASE_CACHED_STATE ${ILMBASE_CURRENT_STATE}
CACHE INTERNAL "State last seen by FindIlmBase.cmake" FORCE)
# Link with pthreads if required
if (NOT WIN32 AND EXISTS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h)
file (STRINGS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h
if(NOT WIN32 AND EXISTS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h)
file(STRINGS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h
ILMBASE_HAVE_PTHREAD
REGEX "^[ \\t]*#define[ \\t]+HAVE_PTHREAD[ \\t]1[ \\t]*\$"
)
if (ILMBASE_HAVE_PTHREAD)
find_package (Threads)
if (CMAKE_USE_PTHREADS_INIT)
set (ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT})
endif ()
endif ()
endif ()
if(ILMBASE_HAVE_PTHREAD)
find_package(Threads)
if(CMAKE_USE_PTHREADS_INIT)
set(ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
endif()
# Use the standard function to handle ILMBASE_FOUND
FIND_PACKAGE_HANDLE_STANDARD_ARGS (IlmBase DEFAULT_MSG
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IlmBase DEFAULT_MSG
ILMBASE_INCLUDE_DIR ${IlmBase_libvars})
if (ILMBASE_FOUND)
set (ILMBASE_LIBRARIES "")
foreach (tmplib ${IlmBase_libvars})
list (APPEND ILMBASE_LIBRARIES ${${tmplib}})
endforeach ()
list (APPEND ILMBASE_LIBRARIES ${ILMBASE_PTHREADS})
if (NOT IlmBase_FIND_QUIETLY)
FIND_PACKAGE_MESSAGE (ILMBASE
if(ILMBASE_FOUND)
set(ILMBASE_LIBRARIES "")
foreach(tmplib ${IlmBase_libvars})
list(APPEND ILMBASE_LIBRARIES ${${tmplib}})
endforeach()
list(APPEND ILMBASE_LIBRARIES ${ILMBASE_PTHREADS})
if(NOT IlmBase_FIND_QUIETLY)
FIND_PACKAGE_MESSAGE(ILMBASE
"Found IlmBase: ${ILMBASE_LIBRARIES}"
"[${ILMBASE_INCLUDE_DIR}][${ILMBASE_LIBRARIES}][${ILMBASE_CURRENT_STATE}]"
)
endif ()
endif ()
endif()
endif()
# Restore the original find library ordering
if( ILMBASE_USE_STATIC_LIBS )
@@ -250,11 +254,11 @@ if( ILMBASE_USE_STATIC_LIBS )
endif()
# Unset the helper variables to avoid pollution
unset (ILMBASE_CURRENT_STATE)
unset (IlmBase_include_paths)
unset (IlmBase_library_paths)
unset (IlmBase_generic_include_paths)
unset (IlmBase_generic_library_paths)
unset (IlmBase_libvars)
unset (IlmBase_cachevars)
unset (ILMBASE_PTHREADS)
unset(ILMBASE_CURRENT_STATE)
unset(IlmBase_include_paths)
unset(IlmBase_library_paths)
unset(IlmBase_generic_include_paths)
unset(IlmBase_generic_library_paths)
unset(IlmBase_libvars)
unset(IlmBase_cachevars)
unset(ILMBASE_PTHREADS)

View File

@@ -23,12 +23,12 @@
# OPENEXR_FOUND - True if OpenEXR was found.
# Other standarnd issue macros
include (SelectLibraryConfigurations)
include (FindPackageHandleStandardArgs)
include (FindPackageMessage)
include(SelectLibraryConfigurations)
include(FindPackageHandleStandardArgs)
include(FindPackageMessage)
if( OPENEXR_USE_STATIC_LIBS )
set( _openexr_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(OPENEXR_USE_STATIC_LIBS)
set(_openexr_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
@@ -37,39 +37,39 @@ if( OPENEXR_USE_STATIC_LIBS )
endif()
# Macro to assemble a helper state variable
macro (SET_STATE_VAR varname)
set (tmp_lst
macro(SET_STATE_VAR varname)
set(tmp_lst
${OPENEXR_CUSTOM} | ${OPENEXR_CUSTOM_LIBRARY} |
${OPENEXR_HOME} | ${OPENEXR_VERSION} | ${OPENEXR_LIB_AREA}
)
set (${varname} "${tmp_lst}")
unset (tmp_lst)
endmacro ()
set(${varname} "${tmp_lst}")
unset(tmp_lst)
endmacro()
# To enforce that find_* functions do not use inadvertently existing versions
if (OPENEXR_CUSTOM)
set (OPENEXR_FIND_OPTIONS "NO_DEFAULT_PATH")
endif ()
if(OPENEXR_CUSTOM)
set(OPENEXR_FIND_OPTIONS "NO_DEFAULT_PATH")
endif()
# Macro to search for an include directory
macro (PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var)
string (TOUPPER ${prefix}_INCLUDE_DIR tmp_varname)
macro(PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var)
string(TOUPPER ${prefix}_INCLUDE_DIR tmp_varname)
find_path(${tmp_varname} ${includefile}
HINTS ${${libpath_var}}
PATH_SUFFIXES include
${OPENEXR_FIND_OPTIONS}
)
if (${tmp_varname})
mark_as_advanced (${tmp_varname})
endif ()
unset (tmp_varname)
endmacro ()
if(${tmp_varname})
mark_as_advanced(${tmp_varname})
endif()
unset(tmp_varname)
endmacro()
# Macro to search for the given library and adds the cached
# variable names to the specified list
macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
string (TOUPPER ${prefix}_${libname} tmp_prefix)
macro(PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
string(TOUPPER ${prefix}_${libname} tmp_prefix)
# Handle new library names for OpenEXR 2.1 build via cmake
string(REPLACE "." "_" _ILMBASE_VERSION ${ILMBASE_VERSION})
string(SUBSTRING ${_ILMBASE_VERSION} 0 3 _ILMBASE_VERSION )
@@ -86,89 +86,91 @@ macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var)
${OPENEXR_FIND_OPTIONS}
)
# Properly define ${tmp_prefix}_LIBRARY (cached) and ${tmp_prefix}_LIBRARIES
select_library_configurations (${tmp_prefix})
list (APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES)
select_library_configurations(${tmp_prefix})
list(APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES)
# Add to the list of variables which should be reset
list (APPEND ${cachelist_var}
list(APPEND ${cachelist_var}
${tmp_prefix}_LIBRARY
${tmp_prefix}_LIBRARY_RELEASE
${tmp_prefix}_LIBRARY_DEBUG)
mark_as_advanced (
mark_as_advanced(
${tmp_prefix}_LIBRARY
${tmp_prefix}_LIBRARY_RELEASE
${tmp_prefix}_LIBRARY_DEBUG)
unset (tmp_prefix)
endmacro ()
unset(tmp_prefix)
endmacro()
# Encode the current state of the external variables into a string
SET_STATE_VAR (OPENEXR_CURRENT_STATE)
SET_STATE_VAR(OPENEXR_CURRENT_STATE)
# If the state has changed, clear the cached variables
if (OPENEXR_CACHED_STATE AND
if(OPENEXR_CACHED_STATE AND
NOT OPENEXR_CACHED_STATE STREQUAL OPENEXR_CURRENT_STATE)
foreach (libvar ${OPENEXR_CACHED_VARS})
unset (${libvar} CACHE)
endforeach ()
endif ()
foreach(libvar ${OPENEXR_CACHED_VARS})
unset(${libvar} CACHE)
endforeach()
endif()
# Generic search paths
set (OpenEXR_generic_include_paths
set(OpenEXR_generic_include_paths
${OPENEXR_CUSTOM_INCLUDE_DIR}
/usr/include
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/include
/sw/include
/opt/local/include)
set (OpenEXR_generic_library_paths
/opt/local/include
)
set(OpenEXR_generic_library_paths
${OPENEXR_CUSTOM_LIB_DIR}
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/lib
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/sw/lib
/opt/local/lib)
/opt/local/lib
)
# Search paths for the OpenEXR files
if (OPENEXR_HOME)
set (OpenEXR_library_paths
if(OPENEXR_HOME)
set(OpenEXR_library_paths
${OPENEXR_HOME}/lib
${OPENEXR_HOME}/lib64)
if (OPENEXR_VERSION)
set (OpenEXR_include_paths
if(OPENEXR_VERSION)
set(OpenEXR_include_paths
${OPENEXR_HOME}/openexr-${OPENEXR_VERSION}/include
${OPENEXR_HOME}/include/openexr-${OPENEXR_VERSION})
list (APPEND OpenEXR_library_paths
list(APPEND OpenEXR_library_paths
${OPENEXR_HOME}/openexr-${OPENEXR_VERSION}/lib
${OPENEXR_HOME}/lib/openexr-${OPENEXR_VERSION})
endif()
list (APPEND OpenEXR_include_paths ${OPENEXR_HOME}/include)
if (OPENEXR_LIB_AREA)
list (INSERT OpenEXR_library_paths 2 ${OPENEXR_LIB_AREA})
endif ()
endif ()
if (ILMBASE_HOME AND OPENEXR_VERSION)
list (APPEND OpenEXR_include_paths
list(APPEND OpenEXR_include_paths ${OPENEXR_HOME}/include)
if(OPENEXR_LIB_AREA)
list(INSERT OpenEXR_library_paths 2 ${OPENEXR_LIB_AREA})
endif()
endif()
if(ILMBASE_HOME AND OPENEXR_VERSION)
list(APPEND OpenEXR_include_paths
${ILMBASE_HOME}/include/openexr-${OPENEXR_VERSION})
endif()
list (APPEND OpenEXR_include_paths ${OpenEXR_generic_include_paths})
list (APPEND OpenEXR_library_paths ${OpenEXR_generic_library_paths})
list(APPEND OpenEXR_include_paths ${OpenEXR_generic_include_paths})
list(APPEND OpenEXR_library_paths ${OpenEXR_generic_library_paths})
# Locate the header files
PREFIX_FIND_INCLUDE_DIR (OpenEXR
PREFIX_FIND_INCLUDE_DIR(OpenEXR
OpenEXR/ImfArray.h OpenEXR_include_paths)
if (OPENEXR_INCLUDE_DIR)
if(OPENEXR_INCLUDE_DIR)
# Get the version from config file, if not already set.
if (NOT OPENEXR_VERSION)
if(NOT OPENEXR_VERSION)
FILE(STRINGS "${OPENEXR_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h" OPENEXR_BUILD_SPECIFICATION
REGEX "^[ \t]*#define[ \t]+OPENEXR_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
if(OPENEXR_BUILD_SPECIFICATION)
if (NOT OpenEXR_FIND_QUIETLY)
if(NOT OpenEXR_FIND_QUIETLY)
message(STATUS "${OPENEXR_BUILD_SPECIFICATION}")
endif ()
endif()
string(REGEX REPLACE ".*#define[ \t]+OPENEXR_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
"\\1" XYZ ${OPENEXR_BUILD_SPECIFICATION})
set("OPENEXR_VERSION" ${XYZ} CACHE STRING "Version of OpenEXR lib")
@@ -178,56 +180,56 @@ if (OPENEXR_INCLUDE_DIR)
set("OPENEXR_VERSION" "2.0" CACHE STRING "Version of OpenEXR lib")
endif()
endif()
endif ()
endif()
if (OPENEXR_CUSTOM)
if (NOT OPENEXR_CUSTOM_LIBRARY)
message (FATAL_ERROR "Custom OpenEXR library requested but OPENEXR_CUSTOM_LIBRARY is not set.")
if(OPENEXR_CUSTOM)
if(NOT OPENEXR_CUSTOM_LIBRARY)
message(FATAL_ERROR "Custom OpenEXR library requested but OPENEXR_CUSTOM_LIBRARY is not set.")
endif()
set (OpenEXR_Library ${OPENEXR_CUSTOM_LIBRARY})
else ()
#elseif (${OPENEXR_VERSION} VERSION_LESS "2.1")
set (OpenEXR_Library IlmImf)
#else ()
set(OpenEXR_Library ${OPENEXR_CUSTOM_LIBRARY})
else()
#elseif(${OPENEXR_VERSION} VERSION_LESS "2.1")
set(OpenEXR_Library IlmImf)
#else()
# string(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _openexr_libs_ver ${OPENEXR_VERSION})
# set (OpenEXR_Library IlmImf-${_openexr_libs_ver})
endif ()
# set(OpenEXR_Library IlmImf-${_openexr_libs_ver})
endif()
# Locate the OpenEXR library
set (OpenEXR_libvars "")
set (OpenEXR_cachevars "")
PREFIX_FIND_LIB (OpenEXR ${OpenEXR_Library}
set(OpenEXR_libvars "")
set(OpenEXR_cachevars "")
PREFIX_FIND_LIB(OpenEXR ${OpenEXR_Library}
OpenEXR_library_paths OpenEXR_libvars OpenEXR_cachevars)
# Create the list of variables that might need to be cleared
set (OPENEXR_CACHED_VARS
set(OPENEXR_CACHED_VARS
OPENEXR_INCLUDE_DIR ${OpenEXR_cachevars}
CACHE INTERNAL "Variables set by FindOpenEXR.cmake" FORCE)
# Store the current state so that variables might be cleared if required
set (OPENEXR_CACHED_STATE ${OPENEXR_CURRENT_STATE}
set(OPENEXR_CACHED_STATE ${OPENEXR_CURRENT_STATE}
CACHE INTERNAL "State last seen by FindOpenEXR.cmake" FORCE)
# Always link explicitly with zlib
set (OPENEXR_ZLIB ${ZLIB_LIBRARIES})
set(OPENEXR_ZLIB ${ZLIB_LIBRARIES})
# Use the standard function to handle OPENEXR_FOUND
FIND_PACKAGE_HANDLE_STANDARD_ARGS (OpenEXR DEFAULT_MSG
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG
OPENEXR_INCLUDE_DIR ${OpenEXR_libvars})
if (OPENEXR_FOUND)
set (OPENEXR_LIBRARIES "")
foreach (tmplib ${OpenEXR_libvars})
list (APPEND OPENEXR_LIBRARIES ${${tmplib}})
endforeach ()
list (APPEND OPENEXR_LIBRARIES ${ZLIB_LIBRARIES})
if (NOT OpenEXR_FIND_QUIETLY)
FIND_PACKAGE_MESSAGE (OPENEXR
if(OPENEXR_FOUND)
set(OPENEXR_LIBRARIES "")
foreach(tmplib ${OpenEXR_libvars})
list(APPEND OPENEXR_LIBRARIES ${${tmplib}})
endforeach()
list(APPEND OPENEXR_LIBRARIES ${ZLIB_LIBRARIES})
if(NOT OpenEXR_FIND_QUIETLY)
FIND_PACKAGE_MESSAGE(OPENEXR
"Found OpenEXR: ${OPENEXR_LIBRARIES}"
"[${OPENEXR_INCLUDE_DIR}][${OPENEXR_LIBRARIES}][${OPENEXR_CURRENT_STATE}]"
)
endif ()
endif ()
endif()
endif()
# Restore the original find library ordering
if( OPENEXR_USE_STATIC_LIBS )
@@ -235,10 +237,10 @@ if( OPENEXR_USE_STATIC_LIBS )
endif()
# Unset the helper variables to avoid pollution
unset (OPENEXR_CURRENT_STATE)
unset (OpenEXR_include_paths)
unset (OpenEXR_library_paths)
unset (OpenEXR_generic_include_paths)
unset (OpenEXR_generic_library_paths)
unset (OpenEXR_libvars)
unset (OpenEXR_cachevars)
unset(OPENEXR_CURRENT_STATE)
unset(OpenEXR_include_paths)
unset(OpenEXR_library_paths)
unset(OpenEXR_generic_include_paths)
unset(OpenEXR_generic_library_paths)
unset(OpenEXR_libvars)
unset(OpenEXR_cachevars)

View File

@@ -1,368 +0,0 @@
# -*- python -*-
# ex: set syntax=python:
# <pep8 compliant>
# List of the branches being built automatically overnight
NIGHT_SCHEDULE_BRANCHES = [None, "blender2.8"]
# List of the branches available for force build
FORCE_SCHEDULE_BRANCHES = ["master", "blender2.8", "experimental-build"]
"""
Stock Twisted directory lister doesn't provide any information about last file
modification time, we hack the class a bit in order to have such functionaliity
:)
"""
from buildbot.status.web.base import DirectoryLister
def get_files_and_directories(self, directory):
from twisted.web.static import (getTypeAndEncoding,
formatFileSize)
import urllib
import cgi
import time
import os
files = []
dirs = []
for path in directory:
url = urllib.quote(path, "/")
escapedPath = cgi.escape(path)
lastmodified = time.ctime(os.path.getmtime(
os.path.join(self.path, path)))
if os.path.isdir(os.path.join(self.path, path)):
url = url + '/'
dirs.append({'text': escapedPath + "/", 'href': url,
'size': '', 'type': '[Directory]',
'encoding': '',
'lastmodified': lastmodified})
else:
mimetype, encoding = getTypeAndEncoding(path, self.contentTypes,
self.contentEncodings,
self.defaultType)
try:
size = os.stat(os.path.join(self.path, path)).st_size
except OSError:
continue
files.append({
'text': escapedPath, "href": url,
'type': '[%s]' % mimetype,
'encoding': (encoding and '[%s]' % encoding or ''),
'size': formatFileSize(size),
'lastmodified': lastmodified})
return dirs, files
DirectoryLister._getFilesAndDirectories = get_files_and_directories
# Dictionary that the buildmaster pays attention to.
c = BuildmasterConfig = {}
# BUILD SLAVES
#
# We load the slaves and their passwords from a separator file, so we can have
# this one in SVN.
from buildbot.buildslave import BuildSlave
import master_private
c['slaves'] = []
for slave in master_private.slaves:
c['slaves'].append(BuildSlave(slave['name'], slave['password']))
# TCP port through which slaves connect
c['slavePortnum'] = 9989
# CHANGE SOURCES
from buildbot.changes.svnpoller import SVNPoller
from buildbot.changes.gitpoller import GitPoller
c['change_source'] = GitPoller(
'git://git.blender.org/blender.git',
pollinterval=1200)
# CODEBASES
#
# Allow to control separately things like branches for each repo and submodules.
all_repositories = {
r'git://git.blender.org/blender.git': 'blender',
r'git://git.blender.org/blender-translations.git': 'blender-translations',
r'git://git.blender.org/blender-addons.git': 'blender-addons',
r'git://git.blender.org/blender-addons-contrib.git': 'blender-addons-contrib',
r'git://git.blender.org/blender-dev-tools.git': 'blender-dev-tools',
r'https://svn.blender.org/svnroot/bf-blender/': 'lib svn',
}
def codebaseGenerator(chdict):
return all_repositories[chdict['repository']]
c['codebaseGenerator'] = codebaseGenerator
# SCHEDULERS
#
# Decide how to react to incoming changes.
# from buildbot.scheduler import Scheduler
from buildbot.schedulers import timed, forcesched
c['schedulers'] = []
def schedule_force_build(name):
c['schedulers'].append(forcesched.ForceScheduler(name='force ' + name,
builderNames=[name],
codebases=[forcesched.CodebaseParameter(
codebase="blender",
branch=forcesched.ChoiceStringParameter(
name="branch", choices=FORCE_SCHEDULE_BRANCHES, default="master"),
# Do not hide revision, can be handy!
repository=forcesched.FixedParameter(name="repository", default="", hide=True),
project=forcesched.FixedParameter(name="project", default="", hide=True)),
# For now, hide other codebases.
forcesched.CodebaseParameter(hide=True, codebase="blender-translations"),
forcesched.CodebaseParameter(
codebase="blender-addons",
branch=forcesched.ChoiceStringParameter(
name="branch", choices=["master", "blender2.8"], default="master"),
repository=forcesched.FixedParameter(name="repository", default="", hide=True),
project=forcesched.FixedParameter(name="project", default="", hide=True),
revision=forcesched.FixedParameter(name="revision", default="", hide=True),
),
forcesched.CodebaseParameter(hide=True, codebase="blender-addons-contrib"),
forcesched.CodebaseParameter(hide=True, codebase="blender-dev-tools"),
forcesched.CodebaseParameter(hide=True, codebase="lib svn")],
properties=[]))
def schedule_build(name, hour, minute=0):
for current_branch in NIGHT_SCHEDULE_BRANCHES:
scheduler_name = "nightly " + name
if current_branch:
scheduler_name += ' ' + current_branch
# Use special addons submodule branch when building blender2.8 branch.
addons_branch = "master"
if current_branch == "blender2.8":
addons_branch = "blender2.8"
c['schedulers'].append(timed.Nightly(name=scheduler_name,
codebases={
"blender": {"repository": ""},
"blender-translations": {"repository": "", "branch": "master"},
"blender-addons": {"repository": "", "branch": addons_branch},
"blender-addons-contrib": {"repository": "", "branch": "master"},
"blender-dev-tools": {"repository": "", "branch": "master"},
"lib svn": {"repository": "", "branch": "trunk"}},
branch=current_branch,
builderNames=[name],
hour=hour,
minute=minute))
# BUILDERS
#
# The 'builders' list defines the Builders, which tell Buildbot how to
# perform a build: what steps, and which slaves can execute them.
# Note that any particular build will only take place on one slave.
from buildbot.process.factory import BuildFactory
from buildbot.process.properties import Interpolate
from buildbot.steps.source import SVN
from buildbot.steps.source import Git
from buildbot.steps.shell import ShellCommand
from buildbot.steps.shell import Compile
from buildbot.steps.shell import Test
from buildbot.steps.transfer import FileUpload
from buildbot.steps.master import MasterShellCommand
from buildbot.config import BuilderConfig
# add builder utility
c['builders'] = []
buildernames = []
def add_builder(c, name, libdir, factory, branch='',
rsync=False, hour=3, minute=0):
slavenames = []
for slave in master_private.slaves:
if name in slave['builders']:
slavenames.append(slave['name'])
if len(slavenames) > 0:
f = factory(name, libdir, branch, rsync)
c['builders'].append(BuilderConfig(name=name,
slavenames=slavenames,
factory=f,
category='blender'))
buildernames.append(name)
schedule_build(name, hour, minute)
schedule_force_build(name)
# common steps
def git_submodule_step(submodule):
return Git(name=submodule + '.git',
repourl='git://git.blender.org/' + submodule + '.git',
mode='update',
codebase=submodule,
workdir=submodule + '.git')
def git_step(branch=''):
if branch:
return Git(name='blender.git',
repourl='git://git.blender.org/blender.git',
mode='update',
branch=branch,
codebase='blender',
workdir='blender.git',
submodules=True)
else:
return Git(name='blender.git',
repourl='git://git.blender.org/blender.git',
mode='update',
codebase='blender',
workdir='blender.git',
submodules=True)
def git_submodules_update():
command = ['git', 'submodule', 'update', '--remote']
return ShellCommand(name='Submodules Update',
command=command,
description='updating',
descriptionDone='up to date',
workdir='blender.git')
def lib_svn_step(dir):
return SVN(name='lib svn',
baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir,
codebase='lib svn',
mode='update',
defaultBranch='trunk',
workdir='lib/' + dir)
def rsync_step(id, branch, rsync_script):
return ShellCommand(name='rsync',
command=['python', rsync_script, id, branch],
description='uploading',
descriptionDone='uploaded',
workdir='install')
# generic builder
def generic_builder(id, libdir='', branch='', rsync=False):
filename = 'uploaded/buildbot_upload_' + id + '.zip'
compile_script = '../blender.git/build_files/buildbot/slave_compile.py'
test_script = '../blender.git/build_files/buildbot/slave_test.py'
pack_script = '../blender.git/build_files/buildbot/slave_pack.py'
rsync_script = '../blender.git/build_files/buildbot/slave_rsync.py'
unpack_script = 'master_unpack.py'
f = BuildFactory()
if libdir != '':
f.addStep(lib_svn_step(libdir))
for submodule in ('blender-translations',
'blender-addons',
'blender-addons-contrib',
'blender-dev-tools'):
f.addStep(git_submodule_step(submodule))
f.addStep(git_step(branch))
f.addStep(git_submodules_update())
f.addStep(Compile(command=['python', compile_script, id], timeout=3600))
f.addStep(Test(command=['python', test_script, id]))
f.addStep(ShellCommand(name='package',
command=['python', pack_script, id, branch or Interpolate('%(src:blender:branch)s')],
description='packaging',
descriptionDone='packaged'))
if rsync:
f.addStep(rsync_step(id, branch, rsync_script))
else:
f.addStep(FileUpload(name='upload',
slavesrc='buildbot_upload.zip',
masterdest=filename,
maxsize=180 * 1024 * 1024,
workdir='install'))
f.addStep(MasterShellCommand(name='unpack',
command=['python2.7', unpack_script, filename],
description='unpacking',
descriptionDone='unpacked'))
return f
# Builders
add_builder(c, 'mac_x86_64_10_9_cmake', 'darwin', generic_builder, hour=1)
add_builder(c, 'linux_glibc219_i686_cmake', '', generic_builder, hour=2)
add_builder(c, 'linux_glibc219_x86_64_cmake', '', generic_builder, hour=1)
add_builder(c, 'win32_cmake_vc2013', 'windows_vc12', generic_builder, hour=1)
add_builder(c, 'win64_cmake_vc2013', 'win64_vc12', generic_builder, hour=2)
add_builder(c, 'win32_cmake_vc2015', 'windows_vc14', generic_builder, hour=3)
add_builder(c, 'win64_cmake_vc2015', 'win64_vc14', generic_builder, hour=4)
# STATUS TARGETS
#
# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
# including web pages, email senders, and IRC bots.
c['status'] = []
from buildbot.status import html
from buildbot.status.web import authz
from buildbot.status.web import auth
users = []
for slave in master_private.slaves:
users += [(slave['name'], slave['password'])]
authz_cfg = authz.Authz(
auth=auth.BasicAuth(users),
# change any of these to True to enable; see the manual for more
# options
gracefulShutdown=False,
forceBuild=True, # use this to test your slave once it is set up
forceAllBuilds=False,
pingBuilder=False,
stopBuild=True,
stopAllBuilds=False,
cancelPendingBuild=True,
)
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))
#c['status'].append(html.WebStatus(http_port=8010))
# PROJECT IDENTITY
c['projectName'] = "Blender"
c['projectURL'] = "http://www.blender.org"
# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server (usually the html.WebStatus page) is visible. This
# typically uses the port number set in the Waterfall 'status' entry, but
# with an externally-visible host name which the buildbot cannot figure out
# without some help.
c['buildbotURL'] = "http://builder.blender.org/"
# DB URL
#
# This specifies what database buildbot uses to store change and scheduler
# state. You can leave this at its default for all but the largest
# installations.
c['db_url'] = "sqlite:///state.sqlite"

View File

@@ -1,151 +0,0 @@
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# Runs on Buildbot master, to unpack incoming unload.zip into latest
# builds directory and remove older builds.
# <pep8 compliant>
import os
import shutil
import sys
import zipfile
# extension stripping
def strip_extension(filename):
extensions = '.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'
for ext in extensions:
if filename.endswith(ext):
filename = filename[:-len(ext)]
return filename
# extract platform from package name
def get_platform(filename):
# name is blender-version-platform.extension. we want to get the
# platform out, but there may be some variations, so we fiddle a
# bit to handle current and hopefully future names
filename = strip_extension(filename)
filename = strip_extension(filename)
tokens = filename.split("-")
platforms = ('osx', 'mac', 'bsd',
'win', 'linux', 'source',
'irix', 'solaris')
platform_tokens = []
found = False
for i, token in enumerate(tokens):
if not found:
for platform in platforms:
if platform in token.lower():
found = True
break
if found:
platform_tokens += [token]
return '-'.join(platform_tokens)
def get_branch(filename):
if filename.startswith("blender-2.8"):
return "blender2.8"
tokens = filename.split("-")
branch = ""
for token in tokens:
if token == "blender":
return branch
if branch == "":
branch = token
else:
branch = branch + "-" + token
return ""
# get filename
if len(sys.argv) < 2:
sys.stderr.write("Not enough arguments, expecting file to unpack\n")
sys.exit(1)
filename = sys.argv[1]
# open zip file
if not os.path.exists(filename):
sys.stderr.write("File %r not found.\n" % filename)
sys.exit(1)
try:
z = zipfile.ZipFile(filename, "r")
except Exception as ex:
sys.stderr.write('Failed to open zip file: %s\n' % str(ex))
sys.exit(1)
if len(z.namelist()) != 1:
sys.stderr.write("Expected one file in %r." % filename)
sys.exit(1)
package = z.namelist()[0]
packagename = os.path.basename(package)
# detect platform and branch
platform = get_platform(packagename)
branch = get_branch(packagename)
if platform == '':
sys.stderr.write('Failed to detect platform ' +
'from package: %r\n' % packagename)
sys.exit(1)
# extract
if not branch or branch == 'master':
directory = 'public_html/download'
elif branch == 'experimental-build':
directory = 'public_html/download/experimental'
else:
directory = 'public_html/download'
try:
filename = os.path.join(directory, packagename)
zf = z.open(package)
f = file(filename, "wb")
shutil.copyfileobj(zf, f)
os.chmod(filename, 0644)
zf.close()
z.close()
except Exception as ex:
sys.stderr.write('Failed to unzip package: %s\n' % str(ex))
sys.exit(1)
# remove other files from the same platform and branch
try:
for f in os.listdir(directory):
if get_platform(f) == platform and get_branch(f) == branch:
if f != packagename:
os.remove(os.path.join(directory, f))
except Exception as ex:
sys.stderr.write('Failed to remove old packages: %s\n' % str(ex))
sys.exit(1)

View File

@@ -73,8 +73,9 @@ if 'cmake' in builder:
if builder.endswith('x86_64_10_9_cmake'):
cmake_extra_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
cmake_extra_options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
cmake_extra_options.append('-DCUDA_HOST_COMPILER=/usr/local/cuda-hack/clang')
cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
# Used to trick CUDFA to see CLang as an older version.
# cmake_extra_options.append('-DCUDA_HOST_COMPILER=/usr/local/cuda-hack/clang')
# cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
elif builder.startswith('win'):
if builder.endswith('_vc2015'):
@@ -107,25 +108,24 @@ if 'cmake' in builder:
elif builder.endswith('i686_cmake'):
bits = 32
chroot_name = 'buildbot_' + deb_name + '_i686'
cuda_chroot_name = 'buildbot_' + deb_name + '_x86_64'
targets = ['player', 'blender', 'cuda']
targets = ['player', 'blender']
cmake_extra_options.extend(["-DCMAKE_C_COMPILER=/usr/bin/gcc-7",
"-DCMAKE_CXX_COMPILER=/usr/bin/g++-7"])
cmake_options.append("-C" + os.path.join(blender_dir, cmake_config_file))
# Prepare CMake options needed to configure cuda binaries compilation.
cuda_cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=%s" % ('ON' if build_cubins else 'OFF'))
cuda_cmake_options.append("-DCYCLES_CUDA_BINARIES_ARCH=sm_20;sm_21;sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61")
if build_cubins or 'cuda' in targets:
if bits == 32:
cuda_cmake_options.append("-DCUDA_64_BIT_DEVICE_CODE=OFF")
else:
# Prepare CMake options needed to configure cuda binaries compilation, 64bit only.
if bits == 64:
cuda_cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=%s" % ('ON' if build_cubins else 'OFF'))
cuda_cmake_options.append("-DCYCLES_CUDA_BINARIES_ARCH=sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61;sm_70")
if build_cubins or 'cuda' in targets:
cuda_cmake_options.append("-DCUDA_64_BIT_DEVICE_CODE=ON")
# Only modify common cmake options if cuda doesn't require separate target.
if 'cuda' not in targets:
cmake_options += cuda_cmake_options
# Only modify common cmake options if cuda doesn't require separate target.
if 'cuda' not in targets:
cmake_options += cuda_cmake_options
else:
cuda_cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=OFF")
cmake_options.append("-DCMAKE_INSTALL_PREFIX=%s" % (install_dir))

View File

@@ -138,11 +138,11 @@ if builder.find('cmake') != -1:
blender_glibc = builder.split('_')[1]
if builder.endswith('x86_64_cmake'):
chroot_name = 'buildbot_squeeze_x86_64'
chroot_name = 'buildbot_jessie_x86_64'
bits = 64
blender_arch = 'x86_64'
elif builder.endswith('i686_cmake'):
chroot_name = 'buildbot_squeeze_i686'
chroot_name = 'buildbot_jessie_i686'
bits = 32
blender_arch = 'i686'

View File

@@ -44,9 +44,9 @@ if "cmake" in builder:
"""
if builder.endswith('x86_64_cmake'):
chroot_name = 'buildbot_squeeze_x86_64'
chroot_name = 'buildbot_jessie_x86_64'
elif builder.endswith('i686_cmake'):
chroot_name = 'buildbot_squeeze_i686'
chroot_name = 'buildbot_jessie_i686'
if chroot_name:
chroot_prefix = ['schroot', '-c', chroot_name, '--']
"""

View File

@@ -42,7 +42,7 @@ FIND_PATH(SDL2_INCLUDE_DIR
HINTS
${_sdl2_SEARCH_DIRS}
PATH_SUFFIXES
include/SDL2 include
include/SDL2 include SDL2
)
FIND_LIBRARY(SDL2_LIBRARY

View File

@@ -25,10 +25,6 @@ IGNORE = (
"extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h",
"extern/bullet2/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.h",
"extern/bullet2/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h",
"extern/carve/include/carve/config.h",
"extern/carve/include/carve/random/random.h",
"extern/carve/patches/files/config.h",
"extern/carve/patches/files/random.h",
"intern/audaspace/SRC/AUD_SRCResampleFactory.h",
"intern/audaspace/SRC/AUD_SRCResampleReader.h",
)

View File

@@ -34,7 +34,6 @@ set(WITH_INTERNATIONAL ON CACHE BOOL "" FORCE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_LZMA ON CACHE BOOL "" FORCE)
set(WITH_LZO ON CACHE BOOL "" FORCE)
set(WITH_MOD_BOOLEAN ON CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID ON CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH ON CACHE BOOL "" FORCE)
set(WITH_MOD_SMOKE ON CACHE BOOL "" FORCE)

View File

@@ -9,6 +9,7 @@ set(WITH_INSTALL_PORTABLE ON CACHE BOOL "" FORCE)
set(WITH_SYSTEM_GLEW ON CACHE BOOL "" FORCE)
set(WITH_ALEMBIC OFF CACHE BOOL "" FORCE)
set(WITH_BOOST OFF CACHE BOOL "" FORCE)
set(WITH_BUILDINFO OFF CACHE BOOL "" FORCE)
set(WITH_BULLET OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_AVI OFF CACHE BOOL "" FORCE)
@@ -38,7 +39,6 @@ set(WITH_INTERNATIONAL OFF CACHE BOOL "" FORCE)
set(WITH_JACK OFF CACHE BOOL "" FORCE)
set(WITH_LZMA OFF CACHE BOOL "" FORCE)
set(WITH_LZO OFF CACHE BOOL "" FORCE)
set(WITH_MOD_BOOLEAN OFF CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID OFF CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH OFF CACHE BOOL "" FORCE)
set(WITH_MOD_SMOKE OFF CACHE BOOL "" FORCE)
@@ -55,4 +55,3 @@ set(WITH_RAYOPTIMIZATION OFF CACHE BOOL "" FORCE)
set(WITH_SDL OFF CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE OFF CACHE BOOL "" FORCE)

View File

@@ -34,7 +34,6 @@ set(WITH_INTERNATIONAL ON CACHE BOOL "" FORCE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_LZMA ON CACHE BOOL "" FORCE)
set(WITH_LZO ON CACHE BOOL "" FORCE)
set(WITH_MOD_BOOLEAN ON CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID ON CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH ON CACHE BOOL "" FORCE)
set(WITH_MOD_SMOKE ON CACHE BOOL "" FORCE)
@@ -55,7 +54,7 @@ set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
set(WITH_PLAYER ON CACHE BOOL "" FORCE)
set(WITH_MEM_JEMALLOC ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_CUDA_BINARIES ON CACHE BOOL "" FORCE)
set(CYCLES_CUDA_BINARIES_ARCH sm_20;sm_21;sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61 CACHE STRING "" FORCE)
set(CYCLES_CUDA_BINARIES_ARCH sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61 CACHE STRING "" FORCE)
# platform dependent options
if(UNIX AND NOT APPLE)

View File

@@ -107,12 +107,12 @@ def main():
return
# execute
cmd = "make %s %s blender/fast" % (" ".join(args), " ".join(targets_new))
cmd = ["make"] + args + targets_new + ["blender/fast"]
print("cmake building with targets: %s" % " ".join(targets_new))
print("executing: %s" % cmd)
print("executing: %s" % " ".join(cmd))
import os
os.system(cmd)
import subprocess
subprocess.call(cmd)
if __name__ == "__main__":
main()

View File

@@ -242,6 +242,13 @@ function(blender_add_lib__impl
# listed is helpful for IDE's (QtCreator/MSVC)
blender_source_group("${sources}")
#if enabled, set the FOLDER property for visual studio projects
if(WINDOWS_USE_VISUAL_STUDIO_FOLDERS)
get_filename_component(FolderDir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
string(REPLACE ${CMAKE_SOURCE_DIR} "" FolderDir ${FolderDir})
set_target_properties(${name} PROPERTIES FOLDER ${FolderDir})
endif()
list_assert_duplicates("${sources}")
list_assert_duplicates("${includes}")
# Not for system includes because they can resolve to the same path
@@ -558,6 +565,8 @@ function(SETUP_BLENDER_SORTED_LIBS)
set(BLENDER_SORTED_LIBS
bf_windowmanager
bf_editor_undo
bf_editor_space_api
bf_editor_space_action
bf_editor_space_buttons
@@ -588,6 +597,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_editor_mesh
bf_editor_metaball
bf_editor_object
bf_editor_lattice
bf_editor_armature
bf_editor_physics
bf_editor_render
@@ -681,6 +691,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
extern_sdlew
bf_intern_glew_mx
bf_intern_clog
)
if(NOT WITH_SYSTEM_GLOG)
@@ -729,10 +740,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
list(APPEND BLENDER_SORTED_LIBS bf_intern_itasc)
endif()
if(WITH_MOD_BOOLEAN)
list(APPEND BLENDER_SORTED_LIBS extern_carve)
endif()
if(WITH_GHOST_XDND)
list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
endif()
@@ -815,7 +822,7 @@ macro(TEST_SSE_SUPPORT
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
set(${_sse_flags} "") # icc defaults to -msse
set(${_sse2_flags} "-msse2")
set(${_sse2_flags} "") # icc defaults to -msse2
else()
message(WARNING "SSE flags for this compiler: '${CMAKE_C_COMPILER_ID}' not known")
set(${_sse_flags})
@@ -1141,7 +1148,9 @@ endmacro()
# External libs may need 'signed char' to be default.
macro(remove_cc_flag_unsigned_char)
if(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|Intel)$")
if(CMAKE_COMPILER_IS_GNUCC OR
(CMAKE_C_COMPILER_ID MATCHES "Clang") OR
(CMAKE_C_COMPILER_ID MATCHES "Intel"))
remove_cc_flag("-funsigned-char")
elseif(MSVC)
remove_cc_flag("/J")
@@ -1387,7 +1396,7 @@ endfunction()
# macro for converting pixmap directory to a png and then a c file
function(data_to_c_simple_icons
path_from
path_from icon_prefix icon_names
list_to_add
)
@@ -1405,8 +1414,11 @@ function(data_to_c_simple_icons
get_filename_component(_file_to_path ${_file_to} PATH)
# ideally we wouldn't glob, but storing all names for all pixmaps is a bit heavy
file(GLOB _icon_files "${path_from}/*.dat")
# Construct a list of absolute paths from input
set(_icon_files)
foreach(_var ${icon_names})
list(APPEND _icon_files "${_path_from_abs}/${icon_prefix}${_var}.dat")
endforeach()
add_custom_command(
OUTPUT ${_file_from} ${_file_to}
@@ -1519,6 +1531,7 @@ function(find_python_package
PATH_SUFFIXES
site-packages
dist-packages
vendor-packages
NO_DEFAULT_PATH
)
@@ -1529,6 +1542,8 @@ function(find_python_package
"'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/${package}', "
"'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/${package}', "
"'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/${package}', "
"'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/vendor-packages/${package}', "
"'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/vendor-packages/${package}', "
"\n"
"The 'WITH_PYTHON_INSTALL_${_upper_package}' option will be ignored when installing Python.\n"
"The build will be usable, only add-ons that depend on this package won't be functional."
@@ -1566,7 +1581,7 @@ macro(openmp_delayload
endif()
endmacro()
MACRO(WINDOWS_SIGN_TARGET target)
macro(WINDOWS_SIGN_TARGET target)
if(WITH_WINDOWS_CODESIGN)
if(!SIGNTOOL_EXE)
error("Codesigning is enabled, but signtool is not found")
@@ -1587,4 +1602,4 @@ MACRO(WINDOWS_SIGN_TARGET target)
)
endif()
endif()
ENDMACRO()
endmacro()

View File

@@ -25,7 +25,7 @@ set(MY_WC_HASH "unknown")
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/)
find_package(Git)
if(GIT_FOUND)
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
# message(STATUS "Found Git: ${GIT_EXECUTABLE}")
execute_process(COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH

View File

@@ -31,6 +31,9 @@ endmacro()
if(NOT DEFINED LIBDIR)
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
# Prefer lib directory paths
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
set(CMAKE_PREFIX_PATH ${LIB_SUBDIRS})
else()
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
endif()
@@ -327,8 +330,8 @@ if(WITH_OPENVDB)
endif()
if(WITH_LLVM)
set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation")
set(LLVM_VERSION "3.4" CACHE STRING "Version of LLVM to use")
set(LLVM_ROOT_DIR ${LIBDIR}/llvm)
set(LLVM_VERSION 3.4)
if(EXISTS "${LLVM_ROOT_DIR}/bin/llvm-config")
set(LLVM_CONFIG "${LLVM_ROOT_DIR}/bin/llvm-config")
else()
@@ -365,7 +368,7 @@ if(WITH_LLVM)
endif()
if(WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
set(CYCLES_OSL ${LIBDIR}/osl)
find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)

View File

@@ -23,6 +23,19 @@
# Libraries configuration for any *nix system including Linux and Unix.
# Detect precompiled library directory
set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME)
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
if(EXISTS ${LIBDIR})
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
set(CMAKE_PREFIX_PATH ${LIB_SUBDIRS})
set(WITH_STATIC_LIBS ON)
set(WITH_OPENMP_STATIC ON)
endif()
# Wrapper to prefer static libraries
macro(find_package_wrapper)
if(WITH_STATIC_LIBS)
find_package_static(${ARGV})
@@ -141,8 +154,15 @@ if(WITH_CODEC_SNDFILE)
endif()
if(WITH_CODEC_FFMPEG)
set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
if(EXISTS ${LIBDIR})
# For precompiled lib directory, all ffmpeg dependencies are in the same folder
file(GLOB ffmpeg_libs ${LIBDIR}/ffmpeg/lib/*.a ${LIBDIR}/sndfile/lib/*.a)
set(FFMPEG ${LIBDIR}/ffmpeg CACHE PATH "FFMPEG Directory")
set(FFMPEG_LIBRARIES ${ffmpeg_libs} ${ffmpeg_libs} CACHE STRING "FFMPEG Libraries")
else()
set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
endif()
mark_as_advanced(FFMPEG)
@@ -329,6 +349,14 @@ if(WITH_OPENCOLORIO)
endif()
if(WITH_LLVM)
# Symbol conflicts with same UTF library used by OpenCollada
if(EXISTS ${LIBDIR})
set(LLVM_STATIC ON)
if(WITH_OPENCOLLADA)
list(REMOVE_ITEM OPENCOLLADA_LIBRARIES ${OPENCOLLADA_UTF_LIBRARY})
endif()
endif()
find_package_wrapper(LLVM)
if(NOT LLVM_FOUND)
@@ -358,7 +386,11 @@ if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
endif()
# OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm)
if(HAIKU)
list(APPEND PLATFORM_LINKLIBS -lnetwork)
else()
list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm)
endif()
find_package(Threads REQUIRED)
list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT})

View File

@@ -31,6 +31,12 @@ endif()
# Libraries configuration for Windows when compiling with MSVC.
set_property(GLOBAL PROPERTY USE_FOLDERS ${WINDOWS_USE_VISUAL_STUDIO_FOLDERS})
if(NOT WITH_PYTHON_MODULE)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT blender)
endif()
macro(warn_hardcoded_paths package_name
)
if(WITH_WINDOWS_FIND_MODULES)
@@ -52,6 +58,11 @@ macro(find_package_wrapper)
endmacro()
add_definitions(-DWIN32)
# Needed, otherwise system encoding causes utf-8 encoding to fail in some cases (C4819)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
# Minimum MSVC Version
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
if(MSVC_VERSION EQUAL 1800)
@@ -102,7 +113,10 @@ add_definitions(-D_ALLOW_KEYWORD_MACROS)
add_definitions(-D_WIN32_WINNT=0x600)
# Make cmake find the msvc redistributables
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP FALSE)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
include(InstallRequiredSystemLibraries)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc")
@@ -142,10 +156,8 @@ if(NOT DEFINED LIBDIR)
message(STATUS "32 bit compiler detected.")
set(LIBDIR_BASE "windows")
endif()
if(MSVC_VERSION EQUAL 1911)
message(STATUS "Visual Studio 2017 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
elseif(MSVC_VERSION EQUAL 1910)
# Can be 1910..1912
if(MSVC_VERSION GREATER 1909)
message(STATUS "Visual Studio 2017 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
elseif(MSVC_VERSION EQUAL 1900)

View File

@@ -28,6 +28,9 @@ Module for accessing project file data for Blender.
Before use, call init(cmake_build_dir).
"""
# TODO: Use CMAKE_EXPORT_COMPILE_COMMANDS (compile_commands.json)
# Instead of Eclipse project format.
__all__ = (
"SIMPLE_PROJECTFILE",
"SOURCE_DIR",
@@ -45,14 +48,22 @@ __all__ = (
import sys
if not sys.version.startswith("3"):
if sys.version_info.major < 3:
print("\nPython3.x needed, found %s.\nAborting!\n" %
sys.version.partition(" ")[0])
sys.exit(1)
import subprocess
import os
from os.path import join, dirname, normpath, abspath, splitext, exists
from os.path import (
abspath,
dirname,
exists,
join,
normpath,
splitext,
)
SOURCE_DIR = join(dirname(__file__), "..", "..")
SOURCE_DIR = normpath(SOURCE_DIR)
@@ -146,13 +157,13 @@ def cmake_advanced_info():
raise Exception("Error: win32 is not supported")
else:
if make_exe_basename.startswith(("make", "gmake")):
cmd = 'cmake "%s" -G"Eclipse CDT4 - Unix Makefiles"' % CMAKE_DIR
cmd = ("cmake", CMAKE_DIR, "-GEclipse CDT4 - Unix Makefiles")
elif make_exe_basename.startswith("ninja"):
cmd = 'cmake "%s" -G"Eclipse CDT4 - Ninja"' % CMAKE_DIR
cmd = ("cmake", CMAKE_DIR, "-GEclipse CDT4 - Ninja")
else:
raise Exception("Unknown make program %r" % make_exe)
os.system(cmd)
subprocess.check_call(cmd)
return join(CMAKE_DIR, ".cproject")
includes = []

View File

@@ -10,6 +10,10 @@
* \ingroup intern
*/
/** \defgroup clog C-Logging (CLOG)
* \ingroup intern
*/
/** \defgroup ctr container
* \ingroup intern
*/

View File

@@ -196,6 +196,10 @@
* \ingroup editors
*/
/** \defgroup edlattice lattice
* \ingroup editors
*/
/** \defgroup edmesh mesh
* \ingroup editors
*/
@@ -316,6 +320,10 @@
* \ingroup editors
*/
/** \defgroup edundo undo utilities
* \ingroup editors
*/
/** \defgroup spuv UV editing
* \ingroup editors
*/

View File

@@ -1,7 +1,7 @@
MEMORY MANAGEMENT IN BLENDER (guardedalloc)
-------------------------------------------
NOTE: This file does not cover memutil and smart pointers and rerefence counted
NOTE: This file does not cover memutil and smart pointers and reference counted
garbage collection, which are contained in the memutil module.
Blender takes care of dynamic memory allocation using a set of own functions
@@ -51,7 +51,7 @@ void MEM_printmemlist(void);
- if err_stream is set by MEM_set_error_stream() this function dumps a list of all
currently allocated memory blocks with length and name to the stream
int MEM_check_memory_integrity(void);
bool MEM_consistency_check(void);
- this function tests if the internal structures of the memory manager are intact
- returns 0 on success and !=0 on error

View File

@@ -1,8 +1,11 @@
"""
Basic Video Playback
++++++++++++++++++++
Example of how to replace a texture in game with a video. It needs to run
everyframe.
Example of how to replace a texture in game with a video.
It needs to run everyframe.
To avoid any confusion with the location of the file,
we will use ``GameLogic.expandPath()`` to build an absolute file name,
assuming the video file is in the same directory as the blend-file.
"""
import bge
from bge import texture
@@ -26,8 +29,18 @@ if not hasattr(logic, 'video'):
logic.video.source = texture.VideoFFmpeg(movie)
logic.video.source.scale = True
# Note that we can change the ``Texture`` source at any time.
# Suppose we want to switch between two movies during the game:
logic.mySources[0] = texture.VideoFFmpeg('movie1.avi')
logic.mySources[1] = texture.VideoFFmpeg('movie2.avi')
#And then assign (and reassign) the source during the game
logic.video.source = logic.mySources[movieSel]
# quick off the movie, but it wont play in the background
logic.video.source.play()
# you need to call this function every frame to ensure update of the texture.
# Video playback is not a background process: it happens only when we refresh the texture.
# So you need to call this function every frame to ensure update of the texture.
logic.video.refresh(True)

View File

@@ -2,30 +2,56 @@
Operator Example
++++++++++++++++
A common use of custom properties is for python based :class:`Operator` classes.
A common use of custom properties is for python based :class:`Operator`
classes. Test this code by running it in the text editor, or by clicking the
button in the 3D Viewport's Tools panel. The latter will show the properties
in the Redo panel and allow you to change them.
"""
import bpy
class DialogOperator(bpy.types.Operator):
bl_idname = "object.dialog_operator"
class OBJECT_OT_property_example(bpy.types.Operator):
bl_idname = "object.property_example"
bl_label = "Property Example"
bl_options = {'REGISTER', 'UNDO'}
my_float = bpy.props.FloatProperty(name="Some Floating Point")
my_bool = bpy.props.BoolProperty(name="Toggle Option")
my_string = bpy.props.StringProperty(name="String Value")
def execute(self, context):
print("Dialog Runs")
self.report({'INFO'}, 'F: %.2f B: %s S: %r' %
(self.my_float, self.my_bool, self.my_string))
print('My float:', self.my_float)
print('My bool:', self.my_bool)
print('My string:', self.my_string)
return {'FINISHED'}
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
class OBJECT_PT_property_example(bpy.types.Panel):
bl_idname = "object_PT_property_example"
bl_label = "Property Example"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_category = "Tools"
def draw(self, context):
# You can set the property values that should be used when the user
# presses the button in the UI.
props = self.layout.operator('object.property_example')
props.my_bool = True
props.my_string = "Shouldn't that be 47?"
# You can set properties dynamically:
if context.object:
props.my_float = context.object.location.x
else:
props.my_float = 327
bpy.utils.register_class(DialogOperator)
bpy.utils.register_class(OBJECT_OT_property_example)
bpy.utils.register_class(OBJECT_PT_property_example)
# test call
bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
# Demo call. Be sure to also test in the 3D Viewport.
bpy.ops.object.property_example(my_float=47, my_bool=True,
my_string="Shouldn't that be 327?")

View File

@@ -1,13 +1,12 @@
"""
Get/Set Example
+++++++++++++++
Getter/Setter Example
+++++++++++++++++++++
Get/Set functions can be used for boolean, int, float, string and enum properties.
Getter/setter functions can be used for boolean, int, float, string and enum properties.
If these callbacks are defined the property will not be stored in the ID properties
automatically, instead the get/set functions will be called when the property is
read or written from the API.
automatically. Instead, the `get` and `set` functions will be called when the property
is respectively read or written from the API.
"""
import bpy
@@ -65,25 +64,24 @@ def set_enum(self, value):
bpy.types.Scene.test_enum = bpy.props.EnumProperty(items=test_items, get=get_enum, set=set_enum)
# Testing
# Testing the properties:
scene = bpy.context.scene
scene.test_float = 12.34
print(scene.test_float)
print('test_float:', scene.test_float)
scene.test_array = (True, False)
print([x for x in scene.test_array])
print('test_array:', tuple(scene.test_array))
# scene.test_date = "blah" # this would fail, property is read-only
print(scene.test_date)
print('test_date:', scene.test_date)
scene.test_enum = 'BLUE'
print(scene.test_enum)
print('test_enum:', scene.test_enum)
# >>> 12.34000015258789
# >>> [True, False]
# >>> 2013-01-05 16:33:52.135340
# >>> setting value 3
# >>> GREEN
# The above outputs:
# test_float: 12.34000015258789
# test_array: (True, False)
# test_date: 2018-03-14 11:36:53.158653
# setting value 3
# test_enum: GREEN

View File

@@ -1,29 +0,0 @@
"""
Manipulator Overview
--------------------
Manipulators are created using two classes.
- :class:`bpy.types.ManipulatorGroup` - stores a list of manipulators.
The manipulator group is associated with a space and region type.
- :class:`bpy.types.Manipulator` - a single item which can be used.
Each manipulator group has a collection of manipulators which it manages.
The following example shows a manipulator group with a single,
manipulator used to control a lamp objects energy.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_simple.py
It's also possible to use a manipulator to run an operator.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_operator_target.py
This more comprehensive example shows how an operator can create a temporary manipulator group to adjust its settings.
.. literalinclude:: __/__/__/release/scripts/templates_py/manipulator_operator.py
"""

View File

@@ -0,0 +1,38 @@
"""
Enum Search Popup
+++++++++++++++++
You may want to have an operator prompt the user to select an item
from a search field, this can be done using :class:`bpy.types.Operator.invoke_search_popup`.
"""
import bpy
from bpy.props import EnumProperty
class SearchEnumOperator(bpy.types.Operator):
bl_idname = "object.search_enum_operator"
bl_label = "Search Enum Operator"
bl_property = "my_search"
my_search = EnumProperty(
name="My Search",
items=(
('FOO', "Foo", ""),
('BAR', "Bar", ""),
('BAZ', "Baz", ""),
),
)
def execute(self, context):
self.report({'INFO'}, "Selected:" + self.my_search)
return {'FINISHED'}
def invoke(self, context, event):
context.window_manager.invoke_search_popup(self)
return {'RUNNING_MODAL'}
bpy.utils.register_class(SearchEnumOperator)
# test call
bpy.ops.object.search_enum_operator('INVOKE_DEFAULT')

View File

@@ -6,18 +6,15 @@ Video Texture (bge.texture)
Introduction
************
The bge.texture module allows you to manipulate textures during the game.
Several sources for texture are possible: video files, image files, video capture, memory buffer,
camera render or a mix of that.
The video and image files can be loaded from the internet using an URL instead of a file name.
In addition, you can apply filters on the images before sending them to the GPU, allowing video effect:
blue screen, color band, gray, normal map.
bge.texture uses FFmpeg to load images and videos.
All the formats and codecs that FFmpeg supports are supported by this module, including but not limited to:
The ``bge.texture`` module allows you to manipulate textures during the game.
Several sources for texture are possible: video files, image files, video capture,
memory buffer, camera render or a mix of that.
The video and image files can be loaded from the Internet using a URL instead of a file name.
In addition, you can apply filters on the images before sending them to the GPU,
allowing video effect: blue screen, color band, gray, normal map.
``bge.texture`` uses FFmpeg to load images and videos.
All the formats and codecs that FFmpeg supports are supported by ``bge.texture``,
including but not limited to:
* AVI
* Ogg
@@ -28,16 +25,45 @@ All the formats and codecs that FFmpeg supports are supported by this module, in
* videoForWindows capture card (this includes many webcams)
* JPG
The principle is simple: first you identify a texture on an existing object using
the :class:`~bge.texture.materialID` function, then you create a new texture with dynamic content
How it works
------------
The principle is simple: first you identify a texture on an existing object using the
:class:`~bge.texture.materialID` function, then you create a new texture with dynamic content
and swap the two textures in the GPU.
The GE is not aware of the substitution and continues to display the object as always,
The game engine is not aware of the substitution and continues to display the object as always,
except that you are now in control of the texture.
When the texture object is deleted, the new texture is deleted and the old texture restored.
.. module:: bge.texture
Game Preparation
----------------
Before you can use the :mod:`bge.texture` module,
you must have objects with textures applied appropriately.
Imagine you want to have a television showing live broadcast programs in the game.
You will create a television object and UV-apply a different texture at the place of the screen,
for example ``tv.png``. What this texture looks like is not important;
probably you want to make it dark gray to simulate power-off state.
When the television must be turned on, you create a dynamic texture from a video capture card
and use it instead of ``tv.png``: the TV screen will come to life.
You have two ways to define textures that ``bge.texture`` can grab:
- Simple UV texture.
- Blender material with image texture channel.
Because ``bge.texture`` works at texture level, it is compatible with all
the Blender Game Engine's fancy texturing features: GLSL, multi-texture, custom shaders, etc.
********
Examples
********
.. include:: __/examples/bge.texture.py
:start-line: 1
@@ -53,7 +79,6 @@ When the texture object is deleted, the new texture is deleted and the old textu
.. literalinclude:: __/examples/bge.texture.1.py
:lines: 8-
.. include:: __/examples/bge.texture.2.py
:start-line: 1
:end-line: 6
@@ -62,13 +87,15 @@ When the texture object is deleted, the new texture is deleted and the old textu
:lines: 8-
.. module:: bge.texture
*************
Video classes
*************
.. class:: VideoFFmpeg(file, capture=-1, rate=25.0, width=0, height=0)
FFmpeg video source.
FFmpeg video source, used for video files, video captures, or video streams.
:arg file: Path to the video to load; if capture >= 0 on Windows, this parameter will not be used.
:type file: str
@@ -90,19 +117,20 @@ Video classes
.. attribute:: range
Replay range.
The start and stop time of the video playback, expressed in seconds from beginning.
By default the entire video.
:type: sequence of two floats
.. attribute:: repeat
Repeat count, -1 for infinite repeat.
Number of times to replay the video, -1 for infinite repeat.
:type: int
.. attribute:: framerate
Frame rate.
Relative frame rate, <1.0 for slow, >1.0 for fast.
:type: float
@@ -126,21 +154,26 @@ Video classes
.. attribute:: scale
Fast scale of image (near neighbour).
Set to True to activate fast nearest neighbor scaling algorithm.
Texture width and height must be a power of 2.
If the video picture size is not a power of 2, rescaling is required.
By default ``bge.texture`` uses the precise but slow ``gluScaleImage()`` function.
Best is to rescale the video offline so that no scaling is necessary at runtime!
:type: bool
.. attribute:: flip
Flip image vertically.
If True the imaged will be flipped vertically.
FFmpeg always delivers the image upside down, so this attribute is set to True by default.
:type: bool
.. attribute:: filter
Pixel filter.
An additional filter that is applied on the video before sending it to the GPU.
:type: one of...
:type: one of:
* :class:`FilterBGR24`
* :class:`FilterBlueScreen`
@@ -207,7 +240,7 @@ Image classes
.. class:: ImageFFmpeg(file)
FFmpeg image source.
FFmpeg image source, used for image files and web based images.
:arg file: Path to the image to load.
:type file: str
@@ -286,7 +319,8 @@ Image classes
.. class:: ImageBuff(width, height, color=0, scale=False)
Image source from image buffer.
Image from application memory.
For computer generated images, drawing applications.
:arg width: Width of the image.
:type width: int
@@ -477,7 +511,7 @@ Image classes
.. class:: ImageMix
Image mixer.
Image mixer used to mix multiple image sources together.
.. attribute:: filter
@@ -592,7 +626,7 @@ Image classes
.. class:: ImageRender(scene, camera)
Image source from render.
Image source from a render of a non active camera.
The render is done on a custom framebuffer object if fbo is specified,
otherwise on the default framebuffer.
@@ -723,7 +757,8 @@ Image classes
.. class:: ImageViewport
Image source from viewport.
Image source from viewport rendered by the active camera.
To render from a non active camera see :class:`ImageRender`.
.. attribute:: alpha
@@ -774,11 +809,10 @@ Image classes
Refresh video - copy the viewport to an external buffer (optional) then invalidate its current content.
:arg buffer: An optional object that implements the buffer protocol.
If specified, the image is copied to the buffer, which must be big enough or an exception is thrown.
The transfer to the buffer is optimal if no processing of the image is needed.
This is the case if ``flip=False, alpha=True, scale=False, whole=True, depth=False, zbuff=False``
and no filter is set.
:arg buffer: An optional object that implements the buffer protocol. If specified,
the image is copied to the buffer, which must be big enough or an exception is thrown.
The transfer to the buffer is optimal if no processing of the image is needed. This is the case if
``flip=False, alpha=True, scale=False, whole=True, depth=False, zbuff=False`` and no filter is set.
:type buffer: any buffer type
:arg format: An optional image format specifier for the image that will be copied to the buffer.
Only valid values are "RGBA" or "BGRA"
@@ -838,18 +872,16 @@ Image classes
:arg capture: Card number from which the input video must be captured.
:type capture: int
The format argument must be written as ``<displayMode>/<pixelFormat>[/3D][:<cacheSize>]`` where ``<displayMode>``
describes the frame size and rate and <pixelFormat> the encoding of the pixels.
The format argument must be written as ``<displayMode>/<pixelFormat>[/3D][:<cacheSize>]``
where ``<displayMode>`` describes the frame size and rate and <pixelFormat> the encoding of the pixels.
The optional ``/3D`` suffix is to be used if the video stream is stereo with a left and right eye feed.
The optional ``:<cacheSize>`` suffix determines the number of the video frames kept in cache, by default 8.
Some DeckLink cards won't work below a certain cache size.
The default value 8 should be sufficient for all cards.
Some DeckLink cards won't work below a certain cache size. The default value 8 should be sufficient for all cards.
You may try to reduce the cache size to reduce the memory footprint. For example the The 4K Extreme is known
to work with 3 frames only, the Extreme 2 needs 4 frames and the Intensity Shuttle needs 6 frames, etc.
Reducing the cache size may be useful when Decklink is used in conjunction with GPUDirect:
all frames must be locked in memory in that case and that puts a lot of pressure on memory.
If you reduce the cache size too much,
you'll get no error but no video feed either.
If you reduce the cache size too much, you'll get no error but no video feed either.
The valid ``<displayMode>`` values are copied from the ``BMDDisplayMode`` enum in the DeckLink API
without the 'bmdMode' prefix. In case a mode that is not in this list is added in a later version
@@ -1006,15 +1038,20 @@ Texture classes
.. class:: Texture(gameObj, materialID=0, textureID=0, textureObj=None)
Texture object.
Class that creates the ``Texture`` object that loads the dynamic texture on the GPU.
:arg gameObj: Game object to be created a video texture on.
:type gameObj: :class:`~bge.types.KX_GameObject`
:arg materialID: Material ID. (optional)
:arg materialID: Material ID default, 0 is the first material. (optional)
:type materialID: int
:arg textureID: Texture ID. (optional)
:arg textureID: Texture index in case of multi-texture channel, 0 = first channel by default.
In case of UV texture, this parameter should always be 0. (optional)
:type textureID: int
:arg textureObj: Texture object with shared bindId. (optional)
:arg textureObj: Reference to another ``Texture`` object with shared bindId
which he user might want to reuse the texture.
If this argument is used, you should not create any source on this texture
and there is no need to refresh it either: the other ``Texture`` object will
provide the texture for both materials/textures.(optional)
:type textureObj: :class:`Texture`
.. attribute:: bindId
@@ -1094,7 +1131,7 @@ Texture classes
.. attribute:: source
This attribute must be set to one of the image source. If the image size does not fit exactly
This attribute must be set to one of the image sources. If the image size does not fit exactly
the frame size, the extend attribute determines what to do.
For best performance, the source image should match exactly the size of the output frame.
@@ -1368,7 +1405,7 @@ Functions
Returns a :class:`~bgl.Buffer` corresponding to the current image stored in a texture source object.
:arg image: Image source object of type ...
:arg image: Image source object of type:
* :class:`VideoFFmpeg`
* :class:`ImageFFmpeg`
@@ -1387,7 +1424,7 @@ Functions
- "BGR" will return 3 bytes per pixel with the
Blue, Green and Red channels in that order.
- "RGB1" will return 4 bytes per pixel with the
- "RGB1" will return 4 bytes per pixel with the
Red, Green, Blue channels in that order and the alpha channel forced to 255.
- A special mode "F" allows to return the image as an array of float.
@@ -1429,9 +1466,10 @@ Functions
.. function:: setLogFile(filename)
Sets the name of a text file in which runtime error messages will be written, in addition to the printing
of the messages on the Python console. Only the runtime errors specific to the VideoTexture module
are written in that file, ordinary runtime time errors are not written.
Sets the name of a text file in which runtime error messages will be written,
in addition to the printing of the messages on the Python console.
Only the runtime errors specific to the VideoTexture module are written in that file,
ordinary runtime time errors are not written.
:arg filename: Name of the error log file.
:type filename: str
@@ -1517,4 +1555,3 @@ See Wikipedia's `Blend Modes <https://en.wikipedia.org/wiki/Blend_modes>`_ for r
.. data:: IMB_BLEND_COPY_RGB
.. data:: IMB_BLEND_COPY_ALPHA

View File

@@ -53,7 +53,7 @@ Here are some characteristics ID Data-Blocks share.
Simple Data Access
------------------
Lets start with a simple case, say you wan't a python script to adjust the objects location.
Lets start with a simple case, say you want a python script to adjust the objects location.
Start by finding this setting in the interface ``Properties Window -> Object -> Transform -> Location``

View File

@@ -194,10 +194,11 @@ User interface classes are given a context in which to draw, buttons window, fil
then they are drawn when that area is displayed so they are never called by Python scripts directly.
.. _info_overview_registration:
Registration
============
Module Registration
-------------------

View File

@@ -420,19 +420,28 @@ MODULE_GROUPING = {
# -------------------------------BLENDER----------------------------------------
blender_version_strings = [str(v) for v in bpy.app.version]
is_release = bpy.app.version_cycle in {"rc", "release"}
# converting bytes to strings, due to T30154
BLENDER_REVISION = str(bpy.app.build_hash, 'utf_8')
BLENDER_DATE = str(bpy.app.build_date, 'utf_8')
BLENDER_VERSION_DOTS = ".".join(blender_version_strings) # '2.62.1'
if is_release:
# '2.62a'
BLENDER_VERSION_DOTS = ".".join(blender_version_strings[:2]) + bpy.app.version_char
else:
# '2.62.1'
BLENDER_VERSION_DOTS = ".".join(blender_version_strings)
if BLENDER_REVISION != "Unknown":
BLENDER_VERSION_DOTS += " " + BLENDER_REVISION # '2.62.1 SHA1'
# '2.62a SHA1' (release) or '2.62.1 SHA1' (non-release)
BLENDER_VERSION_DOTS += " " + BLENDER_REVISION
BLENDER_VERSION_PATH = "_".join(blender_version_strings) # '2_62_1'
if bpy.app.version_cycle in {"rc", "release"}:
if is_release:
# '2_62a_release'
BLENDER_VERSION_PATH = "%s%s_release" % ("_".join(blender_version_strings[:2]), bpy.app.version_char)
else:
# '2_62_1'
BLENDER_VERSION_PATH = "_".join(blender_version_strings)
# --------------------------DOWNLOADABLE FILES----------------------------------

View File

@@ -86,10 +86,6 @@ if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
endif()
endif()
if(WITH_MOD_BOOLEAN)
add_subdirectory(carve)
endif()
if(WITH_X11 AND WITH_GHOST_XDND)
add_subdirectory(xdnd)
endif()

View File

@@ -782,6 +782,12 @@ int btGeneric6DofSpring2Constraint::get_limit_motor_info2(
btScalar cfm = BT_ZERO;
btScalar mA = BT_ONE / m_rbA.getInvMass();
btScalar mB = BT_ONE / m_rbB.getInvMass();
if (rotational) {
btScalar rrA = (m_calculatedTransformA.getOrigin() - transA.getOrigin()).length2();
btScalar rrB = (m_calculatedTransformB.getOrigin() - transB.getOrigin()).length2();
if (m_rbA.getInvMass()) mA = mA * rrA + 1 / (m_rbA.getInvInertiaTensorWorld() * ax1).length();
if (m_rbB.getInvMass()) mB = mB * rrB + 1 / (m_rbB.getInvInertiaTensorWorld() * ax1).length();
}
btScalar m = mA > mB ? mB : mA;
btScalar angularfreq = sqrt(ks / m);
@@ -800,7 +806,18 @@ int btGeneric6DofSpring2Constraint::get_limit_motor_info2(
btScalar fd = -kd * (vel) * (rotational ? -1 : 1) * dt;
btScalar f = (fs+fd);
info->m_constraintError[srow] = (vel + f * (rotational ? -1 : 1)) ;
// after the spring force affecting the body(es) the new velocity will be
// vel + f / m * (rotational ? -1 : 1)
// so in theory this should be set here for m_constraintError
// (with m_constraintError we set a desired velocity for the affected body(es))
// however in practice any value is fine as long as it is greater then the "proper" velocity,
// because the m_lowerLimit and the m_upperLimit will determinate the strength of the final pulling force
// so it is much simpler (and more robust) just to simply use inf (with the proper sign)
// you may also wonder what if the current velocity (vel) so high that the pulling force will not change its direction (in this iteration)
// will we not request a velocity with the wrong direction ?
// and the answare is not, because in practice during the solving the current velocity is subtracted from the m_constraintError
// so the sign of the force that is really matters
info->m_constraintError[srow] = (rotational ? -1 : 1) * (f < 0 ? -SIMD_INFINITY : SIMD_INFINITY);
btScalar minf = f < fd ? f : fd;
btScalar maxf = f < fd ? fd : f;

View File

@@ -1,170 +0,0 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Jacques Beaurai, Erwin Coumans
#
# ***** END GPL LICENSE BLOCK *****
# NOTE: This file is automatically generated by bundle.sh script
# If you're doing changes in this file, please update template
# in that script too
set(INC
include
)
set(INC_SYS
)
set(SRC
carve-capi.cc
carve-util.cc
lib/carve.cpp
lib/convex_hull.cpp
lib/csg_collector.cpp
lib/csg.cpp
lib/face.cpp
lib/geom2d.cpp
lib/geom3d.cpp
lib/intersect_classify_edge.cpp
lib/intersect_classify_group.cpp
lib/intersect.cpp
lib/intersect_debug.cpp
lib/intersect_face_division.cpp
lib/intersect_group.cpp
lib/intersect_half_classify_group.cpp
lib/intersection.cpp
lib/math.cpp
lib/mesh.cpp
lib/octree.cpp
lib/pointset.cpp
lib/polyhedron.cpp
lib/polyline.cpp
lib/tag.cpp
lib/timing.cpp
lib/triangulator.cpp
carve-capi.h
carve-util.h
lib/csg_collector.hpp
lib/csg_data.hpp
lib/csg_detail.hpp
lib/intersect_classify_common.hpp
lib/intersect_classify_common_impl.hpp
lib/intersect_common.hpp
lib/intersect_debug.hpp
include/carve/aabb.hpp
include/carve/aabb_impl.hpp
include/carve/carve.hpp
include/carve/cbrt.h
include/carve/classification.hpp
include/carve/collection.hpp
include/carve/collection_types.hpp
include/carve/collection/unordered/boost_impl.hpp
include/carve/collection/unordered/fallback_impl.hpp
include/carve/collection/unordered.hpp
include/carve/collection/unordered/libstdcpp_impl.hpp
include/carve/collection/unordered/std_impl.hpp
include/carve/collection/unordered/tr1_impl.hpp
include/carve/collection/unordered/vcpp_impl.hpp
include/carve/colour.hpp
include/carve/convex_hull.hpp
include/carve/csg.hpp
include/carve/csg_triangulator.hpp
include/carve/debug_hooks.hpp
include/carve/djset.hpp
include/carve/edge_decl.hpp
include/carve/edge_impl.hpp
include/carve/exact.hpp
include/carve/face_decl.hpp
include/carve/face_impl.hpp
include/carve/faceloop.hpp
include/carve/geom2d.hpp
include/carve/geom3d.hpp
include/carve/geom.hpp
include/carve/geom_impl.hpp
include/carve/gnu_cxx.h
include/carve/heap.hpp
include/carve/input.hpp
include/carve/interpolator.hpp
include/carve/intersection.hpp
include/carve/iobj.hpp
include/carve/kd_node.hpp
include/carve/math_constants.hpp
include/carve/math.hpp
include/carve/matrix.hpp
include/carve/mesh.hpp
include/carve/mesh_impl.hpp
include/carve/mesh_ops.hpp
include/carve/mesh_simplify.hpp
include/carve/octree_decl.hpp
include/carve/octree_impl.hpp
include/carve/pointset_decl.hpp
include/carve/pointset.hpp
include/carve/pointset_impl.hpp
include/carve/pointset_iter.hpp
include/carve/poly_decl.hpp
include/carve/polyhedron_base.hpp
include/carve/polyhedron_decl.hpp
include/carve/polyhedron_impl.hpp
include/carve/poly.hpp
include/carve/poly_impl.hpp
include/carve/polyline_decl.hpp
include/carve/polyline.hpp
include/carve/polyline_impl.hpp
include/carve/polyline_iter.hpp
include/carve/rescale.hpp
include/carve/rtree.hpp
include/carve/spacetree.hpp
include/carve/tag.hpp
include/carve/timing.hpp
include/carve/tree.hpp
include/carve/triangle_intersection.hpp
include/carve/triangulator.hpp
include/carve/triangulator_impl.hpp
include/carve/util.hpp
include/carve/vcpp_config.h
include/carve/vector.hpp
include/carve/vertex_decl.hpp
include/carve/vertex_impl.hpp
include/carve/win32.h
)
if(WITH_BOOST)
if(NOT MSVC)
# Boost is setting as preferred collections library in the Carve code when using MSVC compiler
add_definitions(
-DHAVE_BOOST_UNORDERED_COLLECTIONS
)
endif()
add_definitions(
-DCARVE_SYSTEM_BOOST
-DHAVE_BOOST_LIBRARY
)
list(APPEND INC_SYS
${BOOST_INCLUDE_DIR}
)
endif()
blender_add_lib(extern_carve "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -1,361 +0,0 @@
GNU GENERAL PUBLIC LICENSE
The Qt GUI Toolkit is Copyright (C) 1994-2008 Trolltech ASA.
You may use, distribute and copy the Qt GUI Toolkit under the terms of
GNU General Public License version 2, which is displayed below.
-------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
-------------------------------------------------------------------------
In addition, as a special exception, Trolltech gives permission to link the
code of its release of Qt with the OpenSSL project's "OpenSSL" library (or
modified versions of it that use the same license as the "OpenSSL"
library), and distribute the linked executables. You must comply with the GNU
General Public License version 2 or the GNU General Public License version 3
in all respects for all of the code used other than the "OpenSSL" code. If
you modify this file, you may extend this exception to your version of the
file, but you are not obligated to do so. If you do not wish to do so,
delete this exception statement from your version of this file.

View File

@@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -1,4 +0,0 @@
Project: Carve, CSG library
URL: https://code.google.com/archive/p/carve/
Upstream version 9a85d733a43d
Local modifications: See patches/ folder

105
extern/carve/bundle.sh vendored
View File

@@ -1,105 +0,0 @@
#!/bin/sh
if [ "x$1" = "x--i-really-know-what-im-doing" ] ; then
echo Proceeding as requested by command line ...
else
echo "*** Please run again with --i-really-know-what-im-doing ..."
exit 1
fi
tmp=`mktemp -d`
hg clone https://code.google.com/p/carve/ $tmp/carve
for p in `cat ./patches/series`; do
echo "Applying patch $p..."
cat ./patches/$p | patch -d $tmp/carve -p1
done
find include -type f -not -iwholename '*.svn*' -exec rm -rf {} \;
find lib -type f -not -iwholename '*.svn*' -exec rm -rf {} \;
cat "files.txt" | while read f; do
mkdir -p `dirname $f`
cp $tmp/carve/$f $f
done
rm -rf $tmp
sources=`find ./lib -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t/' | sort -d`
headers=`find ./lib -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t/' | sort -d`
includes=`find ./include -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t/' | sort -d`
cp patches/files/config.h include/carve/config.h
mkdir -p include/carve/random
cp patches/files/random.h include/carve/random/random.h
cat > CMakeLists.txt << EOF
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Jacques Beaurai, Erwin Coumans
#
# ***** END GPL LICENSE BLOCK *****
# NOTE: This file is automatically generated by bundle.sh script
# If you're doing changes in this file, please update template
# in that script too
set(INC
include
)
set(INC_SYS
)
set(SRC
carve-capi.cc
carve-util.cc
${sources}
carve-capi.h
carve-util.h
${headers}
${includes}
)
if(WITH_BOOST)
if(NOT MSVC)
# Boost is setting as preferred collections library in the Carve code when using MSVC compiler
add_definitions(
-DHAVE_BOOST_UNORDERED_COLLECTIONS
)
endif()
add_definitions(
-DCARVE_SYSTEM_BOOST
-DHAVE_BOOST_LIBRARY
)
list(APPEND INC_SYS
\${BOOST_INCLUDE_DIR}
)
endif()
blender_add_lib(extern_carve "\${SRC}" "\${INC}" "\${INC_SYS}")
EOF

View File

@@ -1,994 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "carve-capi.h"
#include "carve-util.h"
#include <carve/interpolator.hpp>
#include <carve/rescale.hpp>
#include <carve/csg_triangulator.hpp>
#include <carve/mesh_simplify.hpp>
using carve::mesh::MeshSet;
typedef std::pair<int, int> OrigIndex;
typedef std::pair<MeshSet<3>::vertex_t *, MeshSet<3>::vertex_t *> VertexPair;
typedef carve::interpolate::VertexAttr<OrigIndex> OrigVertMapping;
typedef carve::interpolate::FaceAttr<OrigIndex> OrigFaceMapping;
typedef carve::interpolate::SwapableFaceEdgeAttr<OrigIndex> OrigFaceEdgeMapping;
typedef carve::interpolate::SimpleFaceEdgeAttr<bool> FaceEdgeTriangulatedFlag;
typedef struct CarveMeshDescr {
// Stores mesh data itself.
MeshSet<3> *poly;
// N-th element of the vector indicates index of an original mesh loop.
std::unordered_map<std::pair<int, int>, int> orig_loop_index_map;
// Mapping from carve face to an original face index in DM.
std::unordered_map<const MeshSet<3>::face_t *, int> orig_poly_index_map;
// The folloving mapping is only filled in for output mesh.
// Mapping from the face verts back to original vert index.
OrigVertMapping orig_vert_mapping;
// Mapping from the face edges back to (original edge index, original loop index).
OrigFaceEdgeMapping orig_face_edge_mapping;
FaceEdgeTriangulatedFlag face_edge_triangulated_flag;
// Mapping from the faces back to original poly index.
OrigFaceMapping orig_face_mapping;
} CarveMeshDescr;
namespace {
template <typename T1, typename T2>
void edgeIndexMap_put(std::unordered_map<std::pair<T1, T1>, T2> *edge_map,
const T1 &v1,
const T1 &v2,
const T2 &index)
{
if (v1 < v2) {
(*edge_map)[std::make_pair(v1, v2)] = index;
}
else {
(*edge_map)[std::make_pair(v2, v1)] = index;
}
}
template <typename T1, typename T2>
const T2 &edgeIndexMap_get(const std::unordered_map<std::pair<T1, T1>, T2> &edge_map,
const T1 &v1,
const T1 &v2)
{
typedef std::unordered_map<std::pair<T1, T1>, T2> Map;
typename Map::const_iterator found;
if (v1 < v2) {
found = edge_map.find(std::make_pair(v1, v2));
}
else {
found = edge_map.find(std::make_pair(v2, v1));
}
assert(found != edge_map.end());
return found->second;
}
template <typename T1, typename T2>
bool edgeIndexMap_get_if_exists(const std::unordered_map<std::pair<T1, T1>, T2> &edge_map,
const T1 &v1,
const T1 &v2,
T2 *out)
{
typedef std::unordered_map<std::pair<T1, T1>, T2> Map;
typename Map::const_iterator found;
if (v1 < v2) {
found = edge_map.find(std::make_pair(v1, v2));
}
else {
found = edge_map.find(std::make_pair(v2, v1));
}
if (found == edge_map.end()) {
return false;
}
*out = found->second;
return true;
}
template <typename T1, typename T2>
bool edgeIndexMap_exists(const std::unordered_map<std::pair<T1, T1>, T2> &edge_map,
const T1 &v1,
const T1 &v2)
{
typedef std::unordered_map<std::pair<T1, T1>, T2> Map;
typename Map::const_iterator found;
if (v1 < v2) {
found = edge_map.find(std::make_pair(v1, v2));
}
else {
found = edge_map.find(std::make_pair(v2, v1));
}
return found != edge_map.end();
}
template <typename T>
inline int indexOf(const T *element, const std::vector<T> &vector_from)
{
return element - &vector_from.at(0);
}
void initOrigIndexMeshFaceMapping(CarveMeshDescr *mesh,
int which_mesh,
std::unordered_map<std::pair<int, int>, int> &orig_loop_index_map,
std::unordered_map<const MeshSet<3>::face_t*, int> &orig_poly_index_map,
OrigVertMapping *orig_vert_mapping,
OrigFaceEdgeMapping *orig_face_edge_mapping,
FaceEdgeTriangulatedFlag *face_edge_triangulated_flag,
OrigFaceMapping *orig_face_attr)
{
MeshSet<3> *poly = mesh->poly;
std::vector<MeshSet<3>::vertex_t>::iterator vertex_iter =
poly->vertex_storage.begin();
for (int i = 0;
vertex_iter != poly->vertex_storage.end();
++i, ++vertex_iter)
{
MeshSet<3>::vertex_t *vertex = &(*vertex_iter);
orig_vert_mapping->setAttribute(vertex,
std::make_pair(which_mesh, i));
}
MeshSet<3>::face_iter face_iter = poly->faceBegin();
for (int i = 0, loop_map_index = 0;
face_iter != poly->faceEnd();
++face_iter, ++i)
{
const MeshSet<3>::face_t *face = *face_iter;
// Mapping from carve face back to original poly index.
int orig_poly_index = orig_poly_index_map[face];
orig_face_attr->setAttribute(face, std::make_pair(which_mesh, orig_poly_index));
for (MeshSet<3>::face_t::const_edge_iter_t edge_iter = face->begin();
edge_iter != face->end();
++edge_iter, ++loop_map_index)
{
int v1 = indexOf(edge_iter->v1(), poly->vertex_storage);
int v2 = indexOf(edge_iter->v2(), poly->vertex_storage);
int orig_loop_index;
if (!edgeIndexMap_get_if_exists(orig_loop_index_map,
v1, v2,
&orig_loop_index))
{
orig_loop_index = -1;
}
if (orig_loop_index != -1) {
// Mapping from carve face edge back to original loop index.
orig_face_edge_mapping->setAttribute(face,
edge_iter.idx(),
std::make_pair(which_mesh,
orig_loop_index));
}
else {
face_edge_triangulated_flag->setAttribute(face,
edge_iter.idx(),
true);
}
}
}
}
void initOrigIndexMapping(CarveMeshDescr *left_mesh,
CarveMeshDescr *right_mesh,
OrigVertMapping *orig_vert_mapping,
OrigFaceEdgeMapping *orig_face_edge_mapping,
FaceEdgeTriangulatedFlag *face_edge_triangulated_flag,
OrigFaceMapping *orig_face_mapping)
{
initOrigIndexMeshFaceMapping(left_mesh,
CARVE_MESH_LEFT,
left_mesh->orig_loop_index_map,
left_mesh->orig_poly_index_map,
orig_vert_mapping,
orig_face_edge_mapping,
face_edge_triangulated_flag,
orig_face_mapping);
initOrigIndexMeshFaceMapping(right_mesh,
CARVE_MESH_RIGHT,
right_mesh->orig_loop_index_map,
right_mesh->orig_poly_index_map,
orig_vert_mapping,
orig_face_edge_mapping,
face_edge_triangulated_flag,
orig_face_mapping);
}
void origEdgeMappingForFace(MeshSet<3>::face_t *face,
OrigFaceEdgeMapping *orig_face_edge_mapping,
std::unordered_map<VertexPair, OrigIndex> *edge_origindex_map)
{
OrigIndex origindex_none = std::make_pair((int)CARVE_MESH_NONE, -1);
MeshSet<3>::edge_t *edge = face->edge;
for (int i = 0;
i < face->nEdges();
++i, edge = edge->next)
{
MeshSet<3>::vertex_t *v1 = edge->v1();
MeshSet<3>::vertex_t *v2 = edge->v2();
OrigIndex orig_edge_index =
orig_face_edge_mapping->getAttribute(edge->face, i, origindex_none);
edgeIndexMap_put(edge_origindex_map, v1, v2, orig_edge_index);
}
}
void dissolveTriangulatedEdges(MeshSet<3>::mesh_t *mesh,
const std::set< std::pair<int, int> > &open_edges,
FaceEdgeTriangulatedFlag *face_edge_triangulated_flag,
OrigFaceEdgeMapping *orig_face_edge_mapping)
{
typedef std::unordered_set<MeshSet<3>::edge_t *> edge_set_t;
typedef std::unordered_set<MeshSet<3>::face_t *> face_set_t;
edge_set_t triangulated_face_edges;
for (int face_index = 0; face_index < mesh->faces.size(); ++face_index) {
MeshSet<3>::face_t *face = mesh->faces[face_index];
MeshSet<3>::edge_t *edge = face->edge;
for (int edge_index = 0;
edge_index < face->nEdges();
++edge_index, edge = edge->next)
{
if (edge->rev) {
const bool is_triangulated_edge =
face_edge_triangulated_flag->getAttribute(face,
edge_index,
false);
if (is_triangulated_edge) {
MeshSet<3>::edge_t *e1 = std::min(edge, edge->rev);
int v1 = indexOf(e1->v1(), mesh->meshset->vertex_storage),
v2 = indexOf(e1->v2(), mesh->meshset->vertex_storage);
bool is_open = false;
if (v1 < v2) {
is_open = open_edges.find(std::make_pair(v1, v2)) != open_edges.end();
}
else {
is_open = open_edges.find(std::make_pair(v2, v1)) != open_edges.end();
}
if (is_open == false) {
triangulated_face_edges.insert(e1);
}
}
}
}
}
if (triangulated_face_edges.size()) {
face_set_t triangulated_faces;
std::unordered_map<VertexPair, OrigIndex> edge_origindex_map;
for (edge_set_t::iterator it = triangulated_face_edges.begin();
it != triangulated_face_edges.end();
++it)
{
MeshSet<3>::edge_t *edge = *it;
origEdgeMappingForFace(edge->face,
orig_face_edge_mapping,
&edge_origindex_map);
triangulated_faces.insert(edge->face);
origEdgeMappingForFace(edge->rev->face,
orig_face_edge_mapping,
&edge_origindex_map);
triangulated_faces.insert(edge->rev->face);
}
carve::mesh::MeshSimplifier simplifier;
simplifier.dissolveMeshEdges(mesh, triangulated_face_edges);
for (int face_index = 0; face_index < mesh->faces.size(); face_index++) {
MeshSet<3>::face_t *face = mesh->faces[face_index];
if (triangulated_faces.find(face) != triangulated_faces.end()) {
MeshSet<3>::edge_t *edge = face->edge;
for (int edge_index = 0;
edge_index < face->nEdges();
++edge_index, edge = edge->next)
{
MeshSet<3>::vertex_t *v1 = edge->v1();
MeshSet<3>::vertex_t *v2 = edge->v2();
OrigIndex orig_edge_index =
edgeIndexMap_get(edge_origindex_map,
v1,
v2);
orig_face_edge_mapping->setAttribute(face, edge_index, orig_edge_index);
}
}
}
}
}
void dissolveTriangulatedEdges(CarveMeshDescr *mesh_descr)
{
MeshSet<3> *poly = mesh_descr->poly;
FaceEdgeTriangulatedFlag *face_edge_triangulated_flag =
&mesh_descr->face_edge_triangulated_flag;
std::set< std::pair<int, int> > open_edges;
for (int mesh_index = 0;
mesh_index < poly->meshes.size();
++mesh_index)
{
const MeshSet<3>::mesh_t *mesh = poly->meshes[mesh_index];
for (int edge_index = 0;
edge_index < mesh->open_edges.size();
++edge_index)
{
const MeshSet<3>::edge_t *edge = mesh->open_edges[edge_index];
int v1 = indexOf(edge->v1(), poly->vertex_storage),
v2 = indexOf(edge->v2(), poly->vertex_storage);
if (v1 < v2) {
open_edges.insert(std::make_pair(v1, v2));
}
else {
open_edges.insert(std::make_pair(v2, v1));
}
}
}
for (int mesh_index = 0; mesh_index < poly->meshes.size(); ++mesh_index) {
MeshSet<3>::mesh_t *mesh = poly->meshes[mesh_index];
dissolveTriangulatedEdges(mesh,
open_edges,
face_edge_triangulated_flag,
&mesh_descr->orig_face_edge_mapping);
}
}
void clipEar(MeshSet<3>::edge_t *ear)
{
MeshSet<3>::edge_t *p_edge = ear->prev;
MeshSet<3>::edge_t *n_edge = ear->next;
p_edge->next = n_edge;
n_edge->prev = p_edge;
if (ear->face->edge == ear) {
ear->face->edge = n_edge;
}
ear->face->n_edges--;
delete ear;
}
MeshSet<3>::edge_t *findDegenerateEar(MeshSet<3>::face_t *face)
{
for (MeshSet<3>::face_t::edge_iter_t edge_iter = face->begin();
edge_iter != face->end();
++edge_iter)
{
MeshSet<3>::edge_t &edge = *edge_iter;
if (edge.vert == edge.next->next->vert) {
return edge.next->next;
}
}
return NULL;
}
class EarClipper : public carve::csg::CSG::Hook {
public:
virtual ~EarClipper() {
}
virtual void processOutputFace(std::vector<MeshSet<3>::face_t *> &faces,
const MeshSet<3>::face_t *orig,
bool flipped) {
for (size_t face_index = 0; face_index < faces.size(); ++face_index) {
carve::mesh::MeshSet<3>::face_t *face = faces[face_index];
// There's no ears in quads and tris.
if (face->nVertices() <= 4) {
continue;
}
MeshSet<3>::edge_t *ear;
while ((ear = findDegenerateEar(face)) != NULL) {
clipEar(ear);
}
}
}
};
class HoleResolver : public carve::csg::CarveHoleResolver {
void removeDuplicatedFaces(std::vector<MeshSet<3>::face_t *> &faces) {
std::vector<MeshSet<3>::face_t *> out_faces;
std::vector<MeshSet<3>::face_t *> duplicated_faces;
for (size_t face_index = 0; face_index < faces.size(); ++face_index) {
carve::mesh::MeshSet<3>::face_t *face = faces[face_index];
face->canonicalize();
}
for (size_t i = 0; i < faces.size(); ++i) {
carve::mesh::MeshSet<3>::face_t *face = faces[i];
bool found = false;
for (size_t j = i + 1; j < faces.size() && found == false; ++j) {
MeshSet<3>::face_t *cur_face = faces[j];
if (cur_face->nEdges() == face->nEdges() &&
cur_face->edge->vert == face->edge->vert)
{
MeshSet<3>::edge_t *cur_edge = cur_face->edge,
*forward_edge = face->edge,
*backward_edge = face->edge;
bool forward_matches = true, backward_matches = true;
for (int a = 0; a < cur_face->nEdges(); ++a) {
if (forward_edge->vert != cur_edge->vert) {
forward_matches = false;
if (backward_matches == false) {
break;
}
}
if (backward_edge->vert != cur_edge->vert) {
backward_matches = false;
if (forward_matches == false) {
break;
}
}
cur_edge = cur_edge->next;
forward_edge = forward_edge->next;
backward_edge = backward_edge->prev;
}
if (forward_matches || backward_matches) {
found = true;
break;
}
}
}
if (found) {
duplicated_faces.push_back(face);
}
else {
out_faces.push_back(face);
}
}
for (int i = 0; i < duplicated_faces.size(); ++i) {
delete duplicated_faces[i];
}
std::swap(faces, out_faces);
}
public:
virtual ~HoleResolver() {
}
virtual void processOutputFace(std::vector<MeshSet<3>::face_t *> &faces,
const MeshSet<3>::face_t *orig,
bool flipped) {
carve::csg::CarveHoleResolver::processOutputFace(faces, orig, flipped);
if (faces.size() > 1) {
removeDuplicatedFaces(faces);
}
}
};
template <typename Interpolator>
void copyFaceEdgeAttrs(const MeshSet<3> *poly,
Interpolator *old_interpolator,
Interpolator *new_interpolator)
{
for (MeshSet<3>::const_face_iter face_iter = poly->faceBegin();
face_iter != poly->faceEnd();
++face_iter)
{
const MeshSet<3>::face_t *face = *face_iter;
for (int edge_index = 0;
edge_index < face->nEdges();
++edge_index)
{
new_interpolator->copyAttribute(face,
edge_index,
old_interpolator);
}
}
}
template <typename Interpolator>
void cleanupFaceEdgeAttrs(const MeshSet<3> *left,
const MeshSet<3> *right,
Interpolator *interpolator)
{
Interpolator new_interpolator;
copyFaceEdgeAttrs(left, interpolator, &new_interpolator);
copyFaceEdgeAttrs(right, interpolator, &new_interpolator);
interpolator->swapAttributes(&new_interpolator);
}
void cleanupFaceEdgeAttrsCallback(const MeshSet<3> *left,
const MeshSet<3> *right,
void *descr_v)
{
CarveMeshDescr *descr = (CarveMeshDescr *) descr_v;
cleanupFaceEdgeAttrs(left,
right,
&descr->face_edge_triangulated_flag);
cleanupFaceEdgeAttrs(left,
right,
&descr->orig_face_edge_mapping);
}
void copyVertexAttrsCallback(const carve::mesh::MeshSet<3>::vertex_t *orig_vert,
const carve::mesh::MeshSet<3>::vertex_t *new_vert,
void *descr_v)
{
CarveMeshDescr *descr = (CarveMeshDescr *) descr_v;
if (!descr->orig_vert_mapping.hasAttribute(orig_vert)) {
return;
}
if (descr->orig_vert_mapping.hasAttribute(new_vert)) {
return;
}
OrigIndex attr = descr->orig_vert_mapping.getAttribute(orig_vert);
descr->orig_vert_mapping.setAttribute(new_vert, attr);
descr->orig_vert_mapping.removeAttribute(orig_vert);
}
} // namespace
CarveMeshDescr *carve_addMesh(struct ImportMeshData *import_data,
CarveMeshImporter *mesh_importer)
{
#define MAX_STATIC_VERTS 64
CarveMeshDescr *mesh_descr = new CarveMeshDescr;
// Import verices from external mesh to Carve.
int num_verts = mesh_importer->getNumVerts(import_data);
std::vector<MeshSet<3>::vertex_t> vertex_storage;
vertex_storage.reserve(num_verts);
for (int i = 0; i < num_verts; i++) {
float position[3];
mesh_importer->getVertCoord(import_data, i, position);
vertex_storage.push_back(carve::geom::VECTOR(position[0],
position[1],
position[2]));
}
// Import polys from external mesh to Carve.
int verts_of_poly_static[MAX_STATIC_VERTS];
int *verts_of_poly_dynamic = NULL;
int verts_of_poly_dynamic_size = 0;
int num_polys = mesh_importer->getNumPolys(import_data);
int loop_index = 0;
std::vector<int> face_indices;
TrianglesStorage triangles_storage;
std::vector<MeshSet<3>::face_t *> faces;
std::vector<MeshSet<3>::vertex_t *> face_vertices;
faces.reserve(num_polys);
for (int i = 0; i < num_polys; i++) {
int verts_per_poly =
mesh_importer->getNumPolyVerts(import_data, i);
int *verts_of_poly;
if (verts_per_poly <= MAX_STATIC_VERTS) {
verts_of_poly = verts_of_poly_static;
}
else {
if (verts_of_poly_dynamic_size < verts_per_poly) {
if (verts_of_poly_dynamic != NULL) {
delete [] verts_of_poly_dynamic;
}
verts_of_poly_dynamic = new int[verts_per_poly];
verts_of_poly_dynamic_size = verts_per_poly;
}
verts_of_poly = verts_of_poly_dynamic;
}
mesh_importer->getPolyVerts(import_data, i, verts_of_poly);
carve::math::Matrix3 axis_matrix;
if (!carve_checkPolyPlanarAndGetNormal(vertex_storage,
verts_per_poly,
verts_of_poly,
&axis_matrix)) {
face_indices.clear();
int num_triangles = carve_triangulatePoly(import_data,
mesh_importer,
vertex_storage,
verts_per_poly,
verts_of_poly,
axis_matrix,
&face_indices,
&triangles_storage);
for (int j = 0; j < num_triangles; ++j) {
MeshSet<3>::face_t *face = new MeshSet<3>::face_t(
&vertex_storage[face_indices[j * 3]],
&vertex_storage[face_indices[j * 3 + 1]],
&vertex_storage[face_indices[j * 3 + 2]]);
mesh_descr->orig_poly_index_map[face] = i;
faces.push_back(face);
}
}
else {
face_vertices.clear();
face_vertices.reserve(verts_per_poly);
for (int j = 0; j < verts_per_poly; ++j) {
face_vertices.push_back(&vertex_storage[verts_of_poly[j]]);
}
MeshSet<3>::face_t *face =
new MeshSet<3>::face_t(face_vertices.begin(),
face_vertices.end());
mesh_descr->orig_poly_index_map[face] = i;
faces.push_back(face);
}
for (int j = 0; j < verts_per_poly; ++j) {
int v1 = verts_of_poly[j];
int v2 = verts_of_poly[(j + 1) % verts_per_poly];
edgeIndexMap_put(&mesh_descr->orig_loop_index_map, v1, v2, loop_index++);
}
}
if (verts_of_poly_dynamic != NULL) {
delete [] verts_of_poly_dynamic;
}
std::vector<MeshSet<3>::mesh_t *> meshes;
MeshSet<3>::mesh_t::create(faces.begin(), faces.end(), meshes, carve::mesh::MeshOptions());
mesh_descr->poly = new MeshSet<3> (vertex_storage, meshes);
return mesh_descr;
#undef MAX_STATIC_VERTS
}
void carve_deleteMesh(CarveMeshDescr *mesh_descr)
{
delete mesh_descr->poly;
delete mesh_descr;
}
bool carve_performBooleanOperation(CarveMeshDescr *left_mesh,
CarveMeshDescr *right_mesh,
int operation,
CarveMeshDescr **output_mesh)
{
*output_mesh = NULL;
carve::csg::CSG::OP op;
switch (operation) {
#define OP_CONVERT(the_op) \
case CARVE_OP_ ## the_op: \
op = carve::csg::CSG::the_op; \
break;
OP_CONVERT(UNION)
OP_CONVERT(INTERSECTION)
OP_CONVERT(A_MINUS_B)
default:
return false;
#undef OP_CONVERT
}
CarveMeshDescr *output_descr = new CarveMeshDescr;
output_descr->poly = NULL;
try {
MeshSet<3> *left = left_mesh->poly, *right = right_mesh->poly;
carve::geom3d::Vector min, max;
// TODO(sergey): Make importer/exporter to care about re-scale
// to save extra mesh iteration here.
carve_getRescaleMinMax(left, right, &min, &max);
carve::rescale::rescale scaler(min.x, min.y, min.z, max.x, max.y, max.z);
carve::rescale::fwd fwd_r(scaler);
carve::rescale::rev rev_r(scaler);
left->transform(fwd_r);
right->transform(fwd_r);
// Initialize attributes for maping from boolean result mesh back to
// original geometry indices.
initOrigIndexMapping(left_mesh, right_mesh,
&output_descr->orig_vert_mapping,
&output_descr->orig_face_edge_mapping,
&output_descr->face_edge_triangulated_flag,
&output_descr->orig_face_mapping);
carve::csg::CSG csg;
csg.hooks.registerHook(new HoleResolver,
carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);
csg.hooks.registerHook(new EarClipper,
carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);
output_descr->orig_vert_mapping.installHooks(csg);
output_descr->orig_face_edge_mapping.installHooks(csg);
output_descr->face_edge_triangulated_flag.installHooks(csg);
output_descr->orig_face_mapping.installHooks(csg);
// Prepare operands for actual boolean operation.
//
// It's needed because operands might consist of several intersecting
// meshes and in case of another operands intersect an edge loop of
// intersecting that meshes tessellation of operation result can't be
// done properly. The only way to make such situations working is to
// union intersecting meshes of the same operand.
carve_unionIntersections(&csg, &left, &right,
copyVertexAttrsCallback,
cleanupFaceEdgeAttrsCallback,
(void *) output_descr);
left_mesh->poly = left;
right_mesh->poly = right;
if (left->meshes.size() == 0 || right->meshes.size() == 0) {
// Normally shouldn't happen (zero-faces objects are handled by
// modifier itself), but unioning intersecting meshes which doesn't
// have consistent normals might lead to empty result which
// wouldn't work here.
return false;
}
output_descr->poly = csg.compute(left,
right,
op,
NULL,
carve::csg::CSG::CLASSIFY_EDGE);
if (output_descr->poly) {
output_descr->poly->transform(rev_r);
dissolveTriangulatedEdges(output_descr);
}
}
catch (carve::exception e) {
std::cerr << "CSG failed, exception " << e.str() << std::endl;
}
catch (...) {
std::cerr << "Unknown error in Carve library" << std::endl;
}
*output_mesh = output_descr;
return output_descr->poly != NULL;
}
static int exportMesh_handle_edges_list(MeshSet<3> *poly,
const std::vector<MeshSet<3>::edge_t*> &edges,
int start_edge_index,
CarveMeshExporter *mesh_exporter,
struct ExportMeshData *export_data,
std::unordered_map<VertexPair, OrigIndex> &edge_origindex_map,
std::unordered_map<VertexPair, int> *edge_map)
{
int num_exported_edges = 0;
for (int i = 0, edge_index = start_edge_index;
i < edges.size();
++i)
{
MeshSet<3>::edge_t *edge = edges.at(i);
MeshSet<3>::vertex_t *v1 = edge->v1();
MeshSet<3>::vertex_t *v2 = edge->v2();
if (edgeIndexMap_exists(*edge_map, v1, v2)) {
continue;
}
const OrigIndex &orig_edge_index = edgeIndexMap_get(edge_origindex_map,
v1,
v2);
mesh_exporter->setEdge(export_data,
edge_index,
indexOf(v1, poly->vertex_storage),
indexOf(v2, poly->vertex_storage),
orig_edge_index.first,
orig_edge_index.second);
edgeIndexMap_put(edge_map, v1, v2, edge_index);
++edge_index;
++num_exported_edges;
}
return num_exported_edges;
}
void carve_exportMesh(CarveMeshDescr *mesh_descr,
CarveMeshExporter *mesh_exporter,
struct ExportMeshData *export_data)
{
OrigIndex origindex_none = std::make_pair((int)CARVE_MESH_NONE, -1);
MeshSet<3> *poly = mesh_descr->poly;
int num_vertices = poly->vertex_storage.size();
int num_edges = 0, num_loops = 0, num_polys = 0;
// Get mapping from edge denoted by vertex pair to original edge index,
//
// This is needed because internally Carve interpolates data for per-face
// edges rather then having some global edge storage.
std::unordered_map<VertexPair, OrigIndex> edge_origindex_map;
for (MeshSet<3>::face_iter face_iter = poly->faceBegin();
face_iter != poly->faceEnd();
++face_iter)
{
MeshSet<3>::face_t *face = *face_iter;
for (MeshSet<3>::face_t::edge_iter_t edge_iter = face->begin();
edge_iter != face->end();
++edge_iter)
{
MeshSet<3>::edge_t &edge = *edge_iter;
int edge_iter_index = edge_iter.idx();
const OrigIndex &orig_loop_index =
mesh_descr->orig_face_edge_mapping.getAttribute(face,
edge_iter_index,
origindex_none);
OrigIndex orig_edge_index;
if (orig_loop_index.first != CARVE_MESH_NONE) {
orig_edge_index.first = orig_loop_index.first;
orig_edge_index.second =
mesh_exporter->mapLoopToEdge(export_data,
orig_loop_index.first,
orig_loop_index.second);
}
else {
orig_edge_index.first = CARVE_MESH_NONE;
orig_edge_index.second = -1;
}
MeshSet<3>::vertex_t *v1 = edge.v1();
MeshSet<3>::vertex_t *v2 = edge.v2();
edgeIndexMap_put(&edge_origindex_map, v1, v2, orig_edge_index);
}
}
num_edges = edge_origindex_map.size();
// Count polys and loops from all manifolds.
for (MeshSet<3>::face_iter face_iter = poly->faceBegin();
face_iter != poly->faceEnd();
++face_iter, ++num_polys)
{
MeshSet<3>::face_t *face = *face_iter;
num_loops += face->nEdges();
}
// Initialize arrays for geometry in exported mesh.
mesh_exporter->initGeomArrays(export_data,
num_vertices,
num_edges,
num_loops,
num_polys);
// Export all the vertices.
std::vector<MeshSet<3>::vertex_t>::iterator vertex_iter = poly->vertex_storage.begin();
for (int i = 0; vertex_iter != poly->vertex_storage.end(); ++i, ++vertex_iter) {
MeshSet<3>::vertex_t *vertex = &(*vertex_iter);
OrigIndex orig_vert_index =
mesh_descr->orig_vert_mapping.getAttribute(vertex, origindex_none);
float coord[3];
coord[0] = vertex->v[0];
coord[1] = vertex->v[1];
coord[2] = vertex->v[2];
mesh_exporter->setVert(export_data, i, coord,
orig_vert_index.first,
orig_vert_index.second);
}
// Export all the edges.
std::unordered_map<VertexPair, int> edge_map;
for (int i = 0, edge_index = 0; i < poly->meshes.size(); ++i) {
carve::mesh::Mesh<3> *mesh = poly->meshes[i];
// Export closed edges.
edge_index += exportMesh_handle_edges_list(poly,
mesh->closed_edges,
edge_index,
mesh_exporter,
export_data,
edge_origindex_map,
&edge_map);
// Export open edges.
edge_index += exportMesh_handle_edges_list(poly,
mesh->open_edges,
edge_index,
mesh_exporter,
export_data,
edge_origindex_map,
&edge_map);
}
// Export all the loops and polys.
MeshSet<3>::face_iter face_iter = poly->faceBegin();
for (int loop_index = 0, poly_index = 0;
face_iter != poly->faceEnd();
++face_iter, ++poly_index)
{
int start_loop_index = loop_index;
MeshSet<3>::face_t *face = *face_iter;
const OrigIndex &orig_face_index =
mesh_descr->orig_face_mapping.getAttribute(face, origindex_none);
for (MeshSet<3>::face_t::edge_iter_t edge_iter = face->begin();
edge_iter != face->end();
++edge_iter, ++loop_index)
{
MeshSet<3>::edge_t &edge = *edge_iter;
const OrigIndex &orig_loop_index =
mesh_descr->orig_face_edge_mapping.getAttribute(face,
edge_iter.idx(),
origindex_none);
mesh_exporter->setLoop(export_data,
loop_index,
indexOf(edge.vert, poly->vertex_storage),
edgeIndexMap_get(edge_map, edge.v1(), edge.v2()),
orig_loop_index.first,
orig_loop_index.second);
}
mesh_exporter->setPoly(export_data,
poly_index, start_loop_index, face->nEdges(),
orig_face_index.first, orig_face_index.second);
}
}

View File

@@ -1,164 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __CARVE_CAPI_H__
#define __CARVE_CAPI_H__
#ifdef __cplusplus
extern "C" {
#endif
struct CarveMeshDescr;
//
// Importer from external storage to Carve module
//
struct ImportMeshData;
// Get number of vertices.
typedef int (*CarveImporter_GetNumVerts) (struct ImportMeshData *import_data);
// Get number of edges.
typedef int (*CarveImporter_GetNumEdges) (struct ImportMeshData *import_data);
// Get number of loops.
typedef int (*CarveImporter_GetNumLoops) (struct ImportMeshData *import_data);
// Get number of polys.
typedef int (*CarveImporter_GetNumPolys) (struct ImportMeshData *import_data);
// Get 3D coordinate of vertex with given index.
typedef void (*CarveImporter_GetVertCoord) (struct ImportMeshData *import_data, int vert_index, float coord[3]);
// Get index of vertices which are adjacent to edge specified by its index.
typedef void (*CarveImporter_GetEdgeVerts) (struct ImportMeshData *import_data, int edge_index, int *v1, int *v2);
// Get number of adjacent vertices to the poly specified by its index.
typedef int (*CarveImporter_GetPolyNumVerts) (struct ImportMeshData *import_data, int poly_index);
// Get list of adjacent vertices to the poly specified by its index.
typedef void (*CarveImporter_GetPolyVerts) (struct ImportMeshData *import_data, int poly_index, int *verts);
// Triangulate 2D polygon.
typedef int (*CarveImporter_Triangulate2DPoly) (struct ImportMeshData *import_data,
const float (*vertices)[2], int num_vertices,
unsigned int (*triangles)[3]);
typedef struct CarveMeshImporter {
CarveImporter_GetNumVerts getNumVerts;
CarveImporter_GetNumEdges getNumEdges;
CarveImporter_GetNumLoops getNumLoops;
CarveImporter_GetNumPolys getNumPolys;
CarveImporter_GetVertCoord getVertCoord;
CarveImporter_GetEdgeVerts getEdgeVerts;
CarveImporter_GetPolyNumVerts getNumPolyVerts;
CarveImporter_GetPolyVerts getPolyVerts;
CarveImporter_Triangulate2DPoly triangulate2DPoly;
} CarveMeshImporter;
//
// Exporter from Carve module to external storage
//
struct ExportMeshData;
// Initialize arrays for geometry.
typedef void (*CarveExporter_InitGeomArrays) (struct ExportMeshData *export_data,
int num_verts, int num_edges,
int num_loops, int num_polys);
// Set coordinate of vertex with given index.
typedef void (*CarveExporter_SetVert) (struct ExportMeshData *export_data,
int vert_index, float coord[3],
int which_orig_mesh, int orig_vert_index);
// Set vertices which are adjacent to the edge specified by its index.
typedef void (*CarveExporter_SetEdge) (struct ExportMeshData *export_data,
int edge_index, int v1, int v2,
int which_orig_mesh, int orig_edge_index);
// Set adjacent loops to the poly specified by its index.
typedef void (*CarveExporter_SetPoly) (struct ExportMeshData *export_data,
int poly_index, int start_loop, int num_loops,
int which_orig_mesh, int orig_poly_index);
// Set list vertex and edge which are adjacent to loop with given index.
typedef void (*CarveExporter_SetLoop) (struct ExportMeshData *export_data,
int loop_index, int vertex, int edge,
int which_orig_mesh, int orig_loop_index);
// Get edge index from a loop index for a given original mesh.
//
// A bit of a bummer to access original operands data on export stage,
// but Blender side still does have this information in derived meshes
// and we use API to get this data instead of duplicating it in Carve
// API side. This is because of optimizations reasons.
typedef int (*CarveExporter_MapLoopToEdge) (struct ExportMeshData *export_data,
int which_mesh, int loop_index);
typedef struct CarveMeshExporter {
CarveExporter_InitGeomArrays initGeomArrays;
CarveExporter_SetVert setVert;
CarveExporter_SetEdge setEdge;
CarveExporter_SetPoly setPoly;
CarveExporter_SetLoop setLoop;
CarveExporter_MapLoopToEdge mapLoopToEdge;
} CarveMeshExporter;
enum {
CARVE_OP_UNION,
CARVE_OP_INTERSECTION,
CARVE_OP_A_MINUS_B,
};
enum {
CARVE_MESH_NONE,
CARVE_MESH_LEFT,
CARVE_MESH_RIGHT
};
struct CarveMeshDescr *carve_addMesh(struct ImportMeshData *import_data,
CarveMeshImporter *mesh_importer);
void carve_deleteMesh(struct CarveMeshDescr *mesh_descr);
bool carve_performBooleanOperation(struct CarveMeshDescr *left_mesh,
struct CarveMeshDescr *right_mesh,
int operation,
struct CarveMeshDescr **output_mesh);
void carve_exportMesh(struct CarveMeshDescr *mesh_descr,
CarveMeshExporter *mesh_exporter,
struct ExportMeshData *export_data);
void carve_unionIntersections(struct CarveMeshDescr **left_mesh_r, struct CarveMeshDescr **right_mesh_r);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __CARVE_CAPI_H__

View File

@@ -1,838 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "carve-util.h"
#include "carve-capi.h"
#include <cfloat>
#include <carve/csg.hpp>
#include <carve/csg_triangulator.hpp>
#include <carve/rtree.hpp>
using carve::csg::Intersections;
using carve::geom::aabb;
using carve::geom::RTreeNode;
using carve::geom3d::Vector;
using carve::math::Matrix3;
using carve::mesh::Face;
using carve::mesh::MeshSet;
using carve::triangulate::tri_idx;
using carve::triangulate::triangulate;
typedef std::map< MeshSet<3>::mesh_t*, RTreeNode<3, Face<3> *> * > RTreeCache;
typedef std::map< MeshSet<3>::mesh_t*, bool > IntersectCache;
namespace {
// Functions adopted from BLI_math.h to use Carve Vector and Matrix.
void transpose_m3__bli(double mat[3][3])
{
double t;
t = mat[0][1];
mat[0][1] = mat[1][0];
mat[1][0] = t;
t = mat[0][2];
mat[0][2] = mat[2][0];
mat[2][0] = t;
t = mat[1][2];
mat[1][2] = mat[2][1];
mat[2][1] = t;
}
void ortho_basis_v3v3_v3__bli(double r_n1[3], double r_n2[3], const double n[3])
{
const double eps = FLT_EPSILON;
const double f = (n[0] * n[0]) + (n[1] * n[1]);
if (f > eps) {
const double d = 1.0f / sqrt(f);
r_n1[0] = n[1] * d;
r_n1[1] = -n[0] * d;
r_n1[2] = 0.0f;
r_n2[0] = -n[2] * r_n1[1];
r_n2[1] = n[2] * r_n1[0];
r_n2[2] = n[0] * r_n1[1] - n[1] * r_n1[0];
}
else {
/* degenerate case */
r_n1[0] = (n[2] < 0.0f) ? -1.0f : 1.0f;
r_n1[1] = r_n1[2] = r_n2[0] = r_n2[2] = 0.0f;
r_n2[1] = 1.0f;
}
}
void axis_dominant_v3_to_m3__bli(Matrix3 *r_mat, const Vector &normal)
{
memcpy(r_mat->m[2], normal.v, sizeof(double[3]));
ortho_basis_v3v3_v3__bli(r_mat->m[0], r_mat->m[1], r_mat->m[2]);
transpose_m3__bli(r_mat->m);
}
void meshset_minmax(const MeshSet<3> *mesh,
Vector *min,
Vector *max)
{
for (size_t i = 0; i < mesh->vertex_storage.size(); ++i) {
min->x = std::min(min->x, mesh->vertex_storage[i].v.x);
min->y = std::min(min->y, mesh->vertex_storage[i].v.y);
min->z = std::min(min->z, mesh->vertex_storage[i].v.z);
max->x = std::max(max->x, mesh->vertex_storage[i].v.x);
max->y = std::max(max->y, mesh->vertex_storage[i].v.y);
max->z = std::max(max->z, mesh->vertex_storage[i].v.z);
}
}
} // namespace
void carve_getRescaleMinMax(const MeshSet<3> *left,
const MeshSet<3> *right,
Vector *min,
Vector *max)
{
min->x = max->x = left->vertex_storage[0].v.x;
min->y = max->y = left->vertex_storage[0].v.y;
min->z = max->z = left->vertex_storage[0].v.z;
meshset_minmax(left, min, max);
meshset_minmax(right, min, max);
// Make sure we don't scale object with zero scale.
if (std::abs(min->x - max->x) < carve::EPSILON) {
min->x = -1.0;
max->x = 1.0;
}
if (std::abs(min->y - max->y) < carve::EPSILON) {
min->y = -1.0;
max->y = 1.0;
}
if (std::abs(min->z - max->z) < carve::EPSILON) {
min->z = -1.0;
max->z = 1.0;
}
}
namespace {
struct UnionIntersectionContext {
VertexAttrsCallback vertex_attr_callback;
void *user_data;
};
void copyMeshes(const std::vector<MeshSet<3>::mesh_t*> &meshes,
std::vector<MeshSet<3>::mesh_t*> *new_meshes)
{
std::vector<MeshSet<3>::mesh_t*>::const_iterator it = meshes.begin();
new_meshes->reserve(meshes.size());
for (; it != meshes.end(); it++) {
MeshSet<3>::mesh_t *mesh = *it;
MeshSet<3>::mesh_t *new_mesh = new MeshSet<3>::mesh_t(mesh->faces);
new_meshes->push_back(new_mesh);
}
}
struct NewMeshMapping {
std::map<const MeshSet<3>::edge_t*, MeshSet<3>::vertex_t*> orig_edge_vert;
};
void prepareNewMeshMapping(const std::vector<MeshSet<3>::mesh_t*> &meshes,
NewMeshMapping *mapping)
{
for (size_t m = 0; m < meshes.size(); ++m) {
MeshSet<3>::mesh_t *mesh = meshes[m];
for (size_t f = 0; f < mesh->faces.size(); ++f) {
MeshSet<3>::face_t *face = mesh->faces[f];
MeshSet<3>::edge_t *edge = face->edge;
do {
mapping->orig_edge_vert[edge] = edge->vert;
edge = edge->next;
} while (edge != face->edge);
}
}
}
void runNewMeshSetHooks(UnionIntersectionContext *ctx,
NewMeshMapping *mapping,
MeshSet<3> *mesh_set)
{
for (size_t m = 0; m < mesh_set->meshes.size(); ++m) {
MeshSet<3>::mesh_t *mesh = mesh_set->meshes[m];
for (size_t f = 0; f < mesh->faces.size(); ++f) {
MeshSet<3>::face_t *face = mesh->faces[f];
MeshSet<3>::edge_t *edge = face->edge;
do {
const MeshSet<3>::vertex_t *orig_vert = mapping->orig_edge_vert[edge];
const MeshSet<3>::vertex_t *new_vert = edge->vert;
ctx->vertex_attr_callback(orig_vert, new_vert, ctx->user_data);
edge = edge->next;
} while (edge != face->edge);
}
}
}
MeshSet<3> *newMeshSetFromMeshesWithAttrs(
UnionIntersectionContext *ctx,
std::vector<MeshSet<3>::mesh_t*> &meshes)
{
NewMeshMapping mapping;
prepareNewMeshMapping(meshes, &mapping);
MeshSet<3> *mesh_set = new MeshSet<3>(meshes);
runNewMeshSetHooks(ctx, &mapping, mesh_set);
return mesh_set;
}
MeshSet<3> *meshSetFromMeshes(UnionIntersectionContext *ctx,
const std::vector<MeshSet<3>::mesh_t*> &meshes)
{
std::vector<MeshSet<3>::mesh_t*> new_meshes;
copyMeshes(meshes, &new_meshes);
return newMeshSetFromMeshesWithAttrs(ctx, new_meshes);
}
MeshSet<3> *meshSetFromTwoMeshes(UnionIntersectionContext *ctx,
const std::vector<MeshSet<3>::mesh_t*> &left_meshes,
const std::vector<MeshSet<3>::mesh_t*> &right_meshes)
{
std::vector<MeshSet<3>::mesh_t*> new_meshes;
copyMeshes(left_meshes, &new_meshes);
copyMeshes(right_meshes, &new_meshes);
return newMeshSetFromMeshesWithAttrs(ctx, new_meshes);
}
bool checkEdgeFaceIntersections_do(Intersections &intersections,
MeshSet<3>::face_t *face_a,
MeshSet<3>::edge_t *edge_b)
{
if (intersections.intersects(edge_b, face_a))
return true;
carve::mesh::MeshSet<3>::vertex_t::vector_t _p;
if (face_a->simpleLineSegmentIntersection(carve::geom3d::LineSegment(edge_b->v1()->v, edge_b->v2()->v), _p))
return true;
return false;
}
bool checkEdgeFaceIntersections(Intersections &intersections,
MeshSet<3>::face_t *face_a,
MeshSet<3>::face_t *face_b)
{
MeshSet<3>::edge_t *edge_b;
edge_b = face_b->edge;
do {
if (checkEdgeFaceIntersections_do(intersections, face_a, edge_b))
return true;
edge_b = edge_b->next;
} while (edge_b != face_b->edge);
return false;
}
inline bool facesAreCoplanar(const MeshSet<3>::face_t *a, const MeshSet<3>::face_t *b)
{
carve::geom3d::Ray temp;
// XXX: Find a better definition. This may be a source of problems
// if floating point inaccuracies cause an incorrect answer.
return !carve::geom3d::planeIntersection(a->plane, b->plane, temp);
}
bool checkMeshSetInterseciton_do(Intersections &intersections,
const RTreeNode<3, Face<3> *> *a_node,
const RTreeNode<3, Face<3> *> *b_node,
bool descend_a = true)
{
if (!a_node->bbox.intersects(b_node->bbox)) {
return false;
}
if (a_node->child && (descend_a || !b_node->child)) {
for (RTreeNode<3, Face<3> *> *node = a_node->child; node; node = node->sibling) {
if (checkMeshSetInterseciton_do(intersections, node, b_node, false)) {
return true;
}
}
}
else if (b_node->child) {
for (RTreeNode<3, Face<3> *> *node = b_node->child; node; node = node->sibling) {
if (checkMeshSetInterseciton_do(intersections, a_node, node, true)) {
return true;
}
}
}
else {
for (size_t i = 0; i < a_node->data.size(); ++i) {
MeshSet<3>::face_t *fa = a_node->data[i];
aabb<3> aabb_a = fa->getAABB();
if (aabb_a.maxAxisSeparation(b_node->bbox) > carve::EPSILON) {
continue;
}
for (size_t j = 0; j < b_node->data.size(); ++j) {
MeshSet<3>::face_t *fb = b_node->data[j];
aabb<3> aabb_b = fb->getAABB();
if (aabb_b.maxAxisSeparation(aabb_a) > carve::EPSILON) {
continue;
}
std::pair<double, double> a_ra = fa->rangeInDirection(fa->plane.N, fa->edge->vert->v);
std::pair<double, double> b_ra = fb->rangeInDirection(fa->plane.N, fa->edge->vert->v);
if (carve::rangeSeparation(a_ra, b_ra) > carve::EPSILON) {
continue;
}
std::pair<double, double> a_rb = fa->rangeInDirection(fb->plane.N, fb->edge->vert->v);
std::pair<double, double> b_rb = fb->rangeInDirection(fb->plane.N, fb->edge->vert->v);
if (carve::rangeSeparation(a_rb, b_rb) > carve::EPSILON) {
continue;
}
if (!facesAreCoplanar(fa, fb)) {
if (checkEdgeFaceIntersections(intersections, fa, fb)) {
return true;
}
}
}
}
}
return false;
}
bool checkMeshSetInterseciton(RTreeNode<3, Face<3> *> *rtree_a, RTreeNode<3, Face<3> *> *rtree_b)
{
Intersections intersections;
return checkMeshSetInterseciton_do(intersections, rtree_a, rtree_b);
}
void getIntersectedOperandMeshes(std::vector<MeshSet<3>::mesh_t*> *meshes,
const MeshSet<3>::aabb_t &otherAABB,
std::vector<MeshSet<3>::mesh_t*> *operandMeshes,
RTreeCache *rtree_cache,
IntersectCache *intersect_cache)
{
std::vector<MeshSet<3>::mesh_t*>::iterator it = meshes->begin();
std::vector< RTreeNode<3, Face<3> *> *> meshRTree;
while (it != meshes->end()) {
MeshSet<3>::mesh_t *mesh = *it;
bool isAdded = false;
RTreeNode<3, Face<3> *> *rtree;
bool intersects;
RTreeCache::iterator rtree_found = rtree_cache->find(mesh);
if (rtree_found != rtree_cache->end()) {
rtree = rtree_found->second;
}
else {
rtree = RTreeNode<3, Face<3> *>::construct_STR(mesh->faces.begin(), mesh->faces.end(), 4, 4);
(*rtree_cache)[mesh] = rtree;
}
IntersectCache::iterator intersect_found = intersect_cache->find(mesh);
if (intersect_found != intersect_cache->end()) {
intersects = intersect_found->second;
}
else {
intersects = rtree->bbox.intersects(otherAABB);
(*intersect_cache)[mesh] = intersects;
}
if (intersects) {
bool isIntersect = false;
std::vector<MeshSet<3>::mesh_t*>::iterator operand_it = operandMeshes->begin();
std::vector<RTreeNode<3, Face<3> *> *>::iterator tree_it = meshRTree.begin();
for (; operand_it!=operandMeshes->end(); operand_it++, tree_it++) {
RTreeNode<3, Face<3> *> *operandRTree = *tree_it;
if (checkMeshSetInterseciton(rtree, operandRTree)) {
isIntersect = true;
break;
}
}
if (!isIntersect) {
operandMeshes->push_back(mesh);
meshRTree.push_back(rtree);
it = meshes->erase(it);
isAdded = true;
}
}
if (!isAdded) {
//delete rtree;
it++;
}
}
std::vector<RTreeNode<3, Face<3> *> *>::iterator tree_it = meshRTree.begin();
for (; tree_it != meshRTree.end(); tree_it++) {
//delete *tree_it;
}
}
MeshSet<3> *getIntersectedOperand(UnionIntersectionContext *ctx,
std::vector<MeshSet<3>::mesh_t*> *meshes,
const MeshSet<3>::aabb_t &otherAABB,
RTreeCache *rtree_cache,
IntersectCache *intersect_cache)
{
std::vector<MeshSet<3>::mesh_t*> operandMeshes;
getIntersectedOperandMeshes(meshes, otherAABB, &operandMeshes, rtree_cache, intersect_cache);
if (operandMeshes.size() == 0)
return NULL;
return meshSetFromMeshes(ctx, operandMeshes);
}
MeshSet<3> *unionIntersectingMeshes(carve::csg::CSG *csg,
MeshSet<3> *poly,
const MeshSet<3> *other_poly,
const MeshSet<3>::aabb_t &otherAABB,
VertexAttrsCallback vertex_attr_callback,
UnionIntersectionsCallback callback,
void *user_data)
{
if (poly->meshes.size() <= 1) {
return poly;
}
std::vector<MeshSet<3>::mesh_t*> orig_meshes =
std::vector<MeshSet<3>::mesh_t*>(poly->meshes.begin(), poly->meshes.end());
RTreeCache rtree_cache;
IntersectCache intersect_cache;
UnionIntersectionContext ctx;
ctx.vertex_attr_callback = vertex_attr_callback;
ctx.user_data = user_data;
MeshSet<3> *left = getIntersectedOperand(&ctx,
&orig_meshes,
otherAABB,
&rtree_cache,
&intersect_cache);
if (!left) {
// No maniforlds which intersects another object at all.
return poly;
}
while (orig_meshes.size()) {
MeshSet<3> *right = getIntersectedOperand(&ctx,
&orig_meshes,
otherAABB,
&rtree_cache,
&intersect_cache);
if (!right) {
// No more intersecting manifolds which intersects other object
break;
}
try {
if (left->meshes.size()==0) {
delete left;
left = right;
}
else {
MeshSet<3> *result = csg->compute(left, right,
carve::csg::CSG::UNION,
NULL, carve::csg::CSG::CLASSIFY_EDGE);
callback(result, other_poly, user_data);
delete left;
delete right;
left = result;
}
}
catch (carve::exception e) {
std::cerr << "CSG failed, exception " << e.str() << std::endl;
MeshSet<3> *result = meshSetFromTwoMeshes(&ctx,
left->meshes,
right->meshes);
callback(result, other_poly, user_data);
delete left;
delete right;
left = result;
}
catch (...) {
delete left;
delete right;
throw "Unknown error in Carve library";
}
}
for (RTreeCache::iterator it = rtree_cache.begin();
it != rtree_cache.end();
it++)
{
delete it->second;
}
// Append all meshes which doesn't have intersection with another operand as-is.
if (orig_meshes.size()) {
MeshSet<3> *result = meshSetFromTwoMeshes(&ctx,
left->meshes,
orig_meshes);
delete left;
left = result;
}
return left;
}
} // namespace
// TODO(sergey): This function is to be totally re-implemented to make it
// more clear what's going on and hopefully optimize it as well.
void carve_unionIntersections(carve::csg::CSG *csg,
MeshSet<3> **left_r,
MeshSet<3> **right_r,
VertexAttrsCallback vertex_attr_callback,
UnionIntersectionsCallback callback,
void *user_data)
{
MeshSet<3> *left = *left_r, *right = *right_r;
if (left->meshes.size() == 1 && right->meshes.size() == 0) {
return;
}
MeshSet<3>::aabb_t leftAABB = left->getAABB();
MeshSet<3>::aabb_t rightAABB = right->getAABB();;
left = unionIntersectingMeshes(csg, left, right, rightAABB,
vertex_attr_callback, callback, user_data);
right = unionIntersectingMeshes(csg, right, left, leftAABB,
vertex_attr_callback, callback, user_data);
if (left != *left_r) {
delete *left_r;
}
if (right != *right_r) {
delete *right_r;
}
*left_r = left;
*right_r = right;
}
static inline void add_newell_cross_v3_v3v3(const Vector &v_prev,
const Vector &v_curr,
Vector *n)
{
(*n)[0] += (v_prev[1] - v_curr[1]) * (v_prev[2] + v_curr[2]);
(*n)[1] += (v_prev[2] - v_curr[2]) * (v_prev[0] + v_curr[0]);
(*n)[2] += (v_prev[0] - v_curr[0]) * (v_prev[1] + v_curr[1]);
}
// Axis matrix is being set for non-flat ngons only.
bool carve_checkPolyPlanarAndGetNormal(const std::vector<MeshSet<3>::vertex_t> &vertex_storage,
const int verts_per_poly,
const int *verts_of_poly,
Matrix3 *axis_matrix_r)
{
if (verts_per_poly == 3) {
// Triangles are always planar.
return true;
}
else if (verts_per_poly == 4) {
// Presumably faster than using generig n-gon check for quads.
const Vector &v1 = vertex_storage[verts_of_poly[0]].v,
&v2 = vertex_storage[verts_of_poly[1]].v,
&v3 = vertex_storage[verts_of_poly[2]].v,
&v4 = vertex_storage[verts_of_poly[3]].v;
Vector vec1, vec2, vec3, cross;
vec1 = v2 - v1;
vec2 = v4 - v1;
vec3 = v3 - v1;
cross = carve::geom::cross(vec1, vec2);
double production = carve::geom::dot(cross, vec3);
// TODO(sergey): Check on whether we could have length-independent
// magnitude here.
double magnitude = 1e-3 * cross.length2();
return fabs(production) < magnitude;
}
else {
const Vector *vert_prev = &vertex_storage[verts_of_poly[verts_per_poly - 1]].v;
const Vector *vert_curr = &vertex_storage[verts_of_poly[0]].v;
Vector normal = carve::geom::VECTOR(0.0, 0.0, 0.0);
for (int i = 0; i < verts_per_poly; i++) {
add_newell_cross_v3_v3v3(*vert_prev, *vert_curr, &normal);
vert_prev = vert_curr;
vert_curr = &vertex_storage[verts_of_poly[(i + 1) % verts_per_poly]].v;
}
if (normal.length2() < FLT_EPSILON) {
// Degenerated face, couldn't triangulate properly anyway.
return true;
}
else {
double magnitude = normal.length2();
normal.normalize();
axis_dominant_v3_to_m3__bli(axis_matrix_r, normal);
Vector first_projected = *axis_matrix_r * vertex_storage[verts_of_poly[0]].v;
double min_z = first_projected[2], max_z = first_projected[2];
for (int i = 1; i < verts_per_poly; i++) {
const Vector &vertex = vertex_storage[verts_of_poly[i]].v;
Vector projected = *axis_matrix_r * vertex;
if (projected[2] < min_z) {
min_z = projected[2];
}
if (projected[2] > max_z) {
max_z = projected[2];
}
}
if (std::abs(min_z - max_z) > FLT_EPSILON * magnitude) {
return false;
}
}
return true;
}
return false;
}
namespace {
int triangulateNGon_carveTriangulator(const std::vector<MeshSet<3>::vertex_t> &vertex_storage,
const int verts_per_poly,
const int *verts_of_poly,
const Matrix3 &axis_matrix,
std::vector<tri_idx> *triangles)
{
// Project vertices to 2D plane.
Vector projected;
std::vector<carve::geom::vector<2> > poly_2d;
poly_2d.reserve(verts_per_poly);
for (int i = 0; i < verts_per_poly; ++i) {
projected = axis_matrix * vertex_storage[verts_of_poly[i]].v;
poly_2d.push_back(carve::geom::VECTOR(projected[0], projected[1]));
}
carve::triangulate::triangulate(poly_2d, *triangles);
carve::triangulate::improve(poly_2d, *triangles);
return triangles->size();
}
int triangulateNGon_importerTriangulator(struct ImportMeshData *import_data,
CarveMeshImporter *mesh_importer,
const std::vector<MeshSet<3>::vertex_t> &vertex_storage,
const int verts_per_poly,
const int *verts_of_poly,
const Matrix3 &axis_matrix,
std::vector<tri_idx> *triangles)
{
typedef float Vector2D[2];
typedef unsigned int Triangle[3];
// Project vertices to 2D plane.
Vector2D *poly_2d = new Vector2D[verts_per_poly];
Vector projected;
for (int i = 0; i < verts_per_poly; ++i) {
projected = axis_matrix * vertex_storage[verts_of_poly[i]].v;
poly_2d[i][0] = projected[0];
poly_2d[i][1] = projected[1];
}
Triangle *api_triangles = new Triangle[verts_per_poly - 2];
int num_triangles =
mesh_importer->triangulate2DPoly(import_data,
poly_2d,
verts_per_poly,
api_triangles);
triangles->reserve(num_triangles);
for (int i = 0; i < num_triangles; ++i) {
triangles->push_back(tri_idx(api_triangles[i][0],
api_triangles[i][1],
api_triangles[i][2]));
}
delete [] poly_2d;
delete [] api_triangles;
return num_triangles;
}
template <typename T>
void sortThreeNumbers(T &a, T &b, T &c)
{
if (a > b)
std::swap(a, b);
if (b > c)
std::swap(b, c);
if (a > b)
std::swap(a, b);
}
bool pushTriangle(int v1, int v2, int v3,
std::vector<int> *face_indices,
TrianglesStorage *triangles_storage)
{
tri_idx triangle(v1, v2, v3);
sortThreeNumbers(triangle.a, triangle.b, triangle.c);
assert(triangle.a < triangle.b);
assert(triangle.b < triangle.c);
if (triangles_storage->find(triangle) == triangles_storage->end()) {
face_indices->push_back(v1);
face_indices->push_back(v2);
face_indices->push_back(v3);
triangles_storage->insert(triangle);
return true;
}
else {
return false;
}
}
} // namespace
int carve_triangulatePoly(struct ImportMeshData *import_data,
CarveMeshImporter *mesh_importer,
const std::vector<MeshSet<3>::vertex_t> &vertex_storage,
const int verts_per_poly,
const int *verts_of_poly,
const Matrix3 &axis_matrix,
std::vector<int> *face_indices,
TrianglesStorage *triangles_storage)
{
int num_triangles = 0;
assert(verts_per_poly > 3);
if (verts_per_poly == 4) {
// Quads we triangulate by 1-3 diagonal, it is an original behavior
// of boolean modifier.
//
// TODO(sergey): Consider using shortest diagonal here. However
// display code in Blende use static 1-3 split, so some experiments
// are needed here.
if (pushTriangle(verts_of_poly[0],
verts_of_poly[1],
verts_of_poly[2],
face_indices,
triangles_storage))
{
num_triangles++;
}
if (pushTriangle(verts_of_poly[0],
verts_of_poly[2],
verts_of_poly[3],
face_indices,
triangles_storage))
{
num_triangles++;
}
}
else {
std::vector<tri_idx> triangles;
triangles.reserve(verts_per_poly - 2);
// Make triangulator callback optional so we could do some tests
// in the future.
if (mesh_importer->triangulate2DPoly) {
triangulateNGon_importerTriangulator(import_data,
mesh_importer,
vertex_storage,
verts_per_poly,
verts_of_poly,
axis_matrix,
&triangles);
}
else {
triangulateNGon_carveTriangulator(vertex_storage,
verts_per_poly,
verts_of_poly,
axis_matrix,
&triangles);
}
for (int i = 0; i < triangles.size(); ++i) {
int v1 = triangles[i].a,
v2 = triangles[i].b,
v3 = triangles[i].c;
// Sanity check of the triangle.
assert(v1 != v2);
assert(v1 != v3);
assert(v2 != v3);
assert(v1 < verts_per_poly);
assert(v2 < verts_per_poly);
assert(v3 < verts_per_poly);
if (pushTriangle(verts_of_poly[v1],
verts_of_poly[v2],
verts_of_poly[v3],
face_indices,
triangles_storage))
{
num_triangles++;
}
}
}
return num_triangles;
}

View File

@@ -1,300 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __CARVE_UTIL_H__
#define __CARVE_UTIL_H__
#include <carve/csg.hpp>
#include <carve/geom3d.hpp>
#include <carve/interpolator.hpp>
#include <carve/mesh.hpp>
#include <carve/triangulator.hpp>
#include "carve-capi.h"
struct TriIdxCompare {
bool operator() (const carve::triangulate::tri_idx &left,
const carve::triangulate::tri_idx &right) const {
if (left.a < right.a) {
return true;
}
else if (left.a > right.a) {
return false;
}
if (left.b < right.b) {
return true;
}
else if (left.b > right.b) {
return false;
}
if (left.c < right.c) {
return true;
}
else if (left.c > right.c) {
return false;
}
return false;
}
};
typedef std::set<carve::triangulate::tri_idx, TriIdxCompare> TrianglesStorage;
void carve_getRescaleMinMax(const carve::mesh::MeshSet<3> *left,
const carve::mesh::MeshSet<3> *right,
carve::geom3d::Vector *min,
carve::geom3d::Vector *max);
typedef void (*VertexAttrsCallback) (const carve::mesh::MeshSet<3>::vertex_t *orig_vert,
const carve::mesh::MeshSet<3>::vertex_t *new_vert,
void *userdata);
typedef void (*UnionIntersectionsCallback) (const carve::mesh::MeshSet<3> *left,
const carve::mesh::MeshSet<3> *right,
void *userdata);
void carve_unionIntersections(carve::csg::CSG *csg,
carve::mesh::MeshSet<3> **left_r,
carve::mesh::MeshSet<3> **right_r,
VertexAttrsCallback vertex_attr_callback,
UnionIntersectionsCallback callback,
void *user_data);
bool carve_checkPolyPlanarAndGetNormal(const std::vector<carve::mesh::MeshSet<3>::vertex_t> &vertex_storage,
const int verts_per_poly,
const int *verts_of_poly,
carve::math::Matrix3 *axis_matrix_r);
int carve_triangulatePoly(struct ImportMeshData *import_data,
CarveMeshImporter *mesh_importer,
const std::vector<carve::mesh::MeshSet<3>::vertex_t> &vertex_storage,
const int verts_per_poly,
const int *verts_of_poly,
const carve::math::Matrix3 &axis_matrix,
std::vector<int> *face_indices,
TrianglesStorage *triangles_storage);
namespace carve {
namespace interpolate {
template<typename attr_t>
class VertexAttr : public Interpolator {
public:
typedef const meshset_t::vertex_t *key_t;
protected:
typedef std::unordered_map<key_t, attr_t> attrmap_t;
attrmap_t attrs;
virtual void resultFace(const carve::csg::CSG &csg,
const meshset_t::face_t *new_face,
const meshset_t::face_t *orig_face,
bool flipped)
{
typedef meshset_t::face_t::const_edge_iter_t const_edge_iter_t;
for (const_edge_iter_t new_edge_iter = new_face->begin();
new_edge_iter != new_face->end();
++new_edge_iter)
{
typename attrmap_t::const_iterator found =
attrs.find(new_edge_iter->vert);
if (found == attrs.end()) {
for (const_edge_iter_t orig_edge_iter = orig_face->begin();
orig_edge_iter != orig_face->end();
++orig_edge_iter)
{
if ((orig_edge_iter->vert->v - new_edge_iter->vert->v).length2() < 1e-5) {
attrs[new_edge_iter->vert] = attrs[orig_edge_iter->vert];
}
}
}
}
}
public:
bool hasAttribute(const meshset_t::vertex_t *v) {
return attrs.find(v) != attrs.end();
}
const attr_t &getAttribute(const meshset_t::vertex_t *v, const attr_t &def = attr_t()) {
typename attrmap_t::const_iterator found = attrs.find(v);
if (found != attrs.end()) {
return found->second;
}
return def;
}
void setAttribute(const meshset_t::vertex_t *v, const attr_t &attr) {
attrs[v] = attr;
}
void removeAttribute(const meshset_t::vertex_t *v) {
typename attrmap_t::iterator it = attrs.find(v);
if (it != attrs.end()) {
attrs.erase(it);
}
}
};
template<typename attr_t>
class SimpleFaceEdgeAttr : public Interpolator {
public:
typedef std::pair<const meshset_t::face_t *, unsigned> key_t;
protected:
typedef std::pair<const meshset_t::vertex_t *, const meshset_t::vertex_t *> vpair_t;
struct key_hash {
size_t operator()(const key_t &v) const {
return size_t(v.first) ^ size_t(v.second);
}
};
struct vpair_hash {
size_t operator()(const vpair_t &v) const {
return size_t(v.first) ^ size_t(v.second);
}
};
typedef std::unordered_map<key_t, attr_t, key_hash> attrmap_t;
typedef std::unordered_map<vpair_t, key_t, vpair_hash> edgedivmap_t;
attrmap_t attrs;
struct Hook : public Interpolator::Hook {
public:
virtual unsigned hookBits() const {
return carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT;
}
Hook(Interpolator *_interpolator, const carve::csg::CSG &_csg) : Interpolator::Hook(_interpolator, _csg) {
}
virtual ~Hook() {
}
};
virtual Interpolator::Hook *makeHook(carve::csg::CSG &csg) {
return new Hook(this, csg);
}
virtual void processOutputFace(const carve::csg::CSG &csg,
std::vector<carve::mesh::MeshSet<3>::face_t *> &new_faces,
const meshset_t::face_t *orig_face,
bool flipped) {
edgedivmap_t undiv;
for (meshset_t::face_t::const_edge_iter_t e = orig_face->begin(); e != orig_face->end(); ++e) {
key_t k(orig_face, e.idx());
typename attrmap_t::const_iterator attr_i = attrs.find(k);
if (attr_i == attrs.end()) {
continue;
} else {
undiv[vpair_t(e->v1(), e->v2())] = k;
}
}
for (size_t fnum = 0; fnum < new_faces.size(); ++fnum) {
const carve::mesh::MeshSet<3>::face_t *new_face = new_faces[fnum];
for (meshset_t::face_t::const_edge_iter_t e = new_face->begin(); e != new_face->end(); ++e) {
key_t k(new_face, e.idx());
vpair_t vp;
if (!flipped) {
vp = vpair_t(e->v1(), e->v2());
} else {
vp = vpair_t(e->v2(), e->v1());
}
typename edgedivmap_t::const_iterator vp_i;
if ((vp_i = undiv.find(vp)) != undiv.end()) {
attrs[k] = attrs[vp_i->second];
}
}
}
}
public:
bool hasAttribute(const meshset_t::face_t *f, unsigned e) {
return attrs.find(std::make_pair(f, e)) != attrs.end();
}
attr_t getAttribute(const meshset_t::face_t *f, unsigned e, const attr_t &def = attr_t()) {
typename attrmap_t::const_iterator fv = attrs.find(std::make_pair(f, e));
if (fv != attrs.end()) {
return (*fv).second;
}
return def;
}
void setAttribute(const meshset_t::face_t *f, unsigned e, const attr_t &attr) {
attrs[std::make_pair(f, e)] = attr;
}
void copyAttribute(const meshset_t::face_t *face,
unsigned edge,
SimpleFaceEdgeAttr<attr_t> *interpolator) {
key_t key(face, edge);
typename attrmap_t::const_iterator fv = interpolator->attrs.find(key);
if (fv != interpolator->attrs.end()) {
attrs[key] = (*fv).second;
}
}
void swapAttributes(SimpleFaceEdgeAttr<attr_t> *interpolator) {
attrs.swap(interpolator->attrs);
}
SimpleFaceEdgeAttr() : Interpolator() {
}
virtual ~SimpleFaceEdgeAttr() {
}
};
template<typename attr_t>
class SwapableFaceEdgeAttr : public FaceEdgeAttr<attr_t> {
public:
typedef carve::mesh::MeshSet<3> meshset_t;
void copyAttribute(const meshset_t::face_t *face,
unsigned edge,
SwapableFaceEdgeAttr<attr_t> *interpolator) {
typename FaceEdgeAttr<attr_t>::key_t key(face, edge);
typename FaceEdgeAttr<attr_t>::attrmap_t::const_iterator fv = interpolator->attrs.find(key);
if (fv != interpolator->attrs.end()) {
this->attrs[key] = (*fv).second;
}
}
void swapAttributes(SwapableFaceEdgeAttr<attr_t> *interpolator) {
this->attrs.swap(interpolator->attrs);
}
};
} // namespace interpolate
} // namespace carve
#endif // __CARVE_UTIL_H__

107
extern/carve/files.txt vendored
View File

@@ -1,107 +0,0 @@
include/carve/edge_impl.hpp
include/carve/tag.hpp
include/carve/colour.hpp
include/carve/math_constants.hpp
include/carve/csg.hpp
include/carve/heap.hpp
include/carve/vector.hpp
include/carve/djset.hpp
include/carve/mesh_impl.hpp
include/carve/polyline_iter.hpp
include/carve/input.hpp
include/carve/geom2d.hpp
include/carve/aabb_impl.hpp
include/carve/geom.hpp
include/carve/triangulator.hpp
include/carve/pointset_iter.hpp
include/carve/spacetree.hpp
include/carve/vertex_impl.hpp
include/carve/vcpp_config.h
include/carve/octree_decl.hpp
include/carve/rescale.hpp
include/carve/collection_types.hpp
include/carve/faceloop.hpp
include/carve/polyhedron_base.hpp
include/carve/vertex_decl.hpp
include/carve/cbrt.h
include/carve/matrix.hpp
include/carve/tree.hpp
include/carve/debug_hooks.hpp
include/carve/rtree.hpp
include/carve/math.hpp
include/carve/convex_hull.hpp
include/carve/polyline.hpp
include/carve/geom3d.hpp
include/carve/aabb.hpp
include/carve/pointset_decl.hpp
include/carve/intersection.hpp
include/carve/face_impl.hpp
include/carve/collection.hpp
include/carve/poly_impl.hpp
include/carve/exact.hpp
include/carve/timing.hpp
include/carve/poly.hpp
include/carve/mesh.hpp
include/carve/win32.h
include/carve/mesh_simplify.hpp
include/carve/classification.hpp
include/carve/collection/unordered/fallback_impl.hpp
include/carve/collection/unordered/std_impl.hpp
include/carve/collection/unordered/vcpp_impl.hpp
include/carve/collection/unordered/boost_impl.hpp
include/carve/collection/unordered/libstdcpp_impl.hpp
include/carve/collection/unordered/tr1_impl.hpp
include/carve/collection/unordered.hpp
include/carve/pointset.hpp
include/carve/mesh_ops.hpp
include/carve/triangle_intersection.hpp
include/carve/octree_impl.hpp
include/carve/pointset_impl.hpp
include/carve/carve.hpp
include/carve/kd_node.hpp
include/carve/polyhedron_impl.hpp
include/carve/interpolator.hpp
include/carve/edge_decl.hpp
include/carve/face_decl.hpp
include/carve/geom_impl.hpp
include/carve/util.hpp
include/carve/random/random.h
include/carve/gnu_cxx.h
include/carve/polyline_decl.hpp
include/carve/triangulator_impl.hpp
include/carve/iobj.hpp
include/carve/csg_triangulator.hpp
include/carve/polyline_impl.hpp
include/carve/poly_decl.hpp
include/carve/polyhedron_decl.hpp
lib/math.cpp
lib/intersect_classify_edge.cpp
lib/csg_detail.hpp
lib/polyhedron.cpp
lib/csg.cpp
lib/intersect.cpp
lib/csg_data.hpp
lib/intersection.cpp
lib/timing.cpp
lib/intersect_classify_common_impl.hpp
lib/geom2d.cpp
lib/csg_collector.hpp
lib/mesh.cpp
lib/intersect_half_classify_group.cpp
lib/octree.cpp
lib/csg_collector.cpp
lib/intersect_debug.hpp
lib/intersect_classify_common.hpp
lib/geom3d.cpp
lib/intersect_face_division.cpp
lib/face.cpp
lib/triangulator.cpp
lib/tag.cpp
lib/intersect_classify_group.cpp
lib/polyline.cpp
lib/intersect_common.hpp
lib/convex_hull.cpp
lib/intersect_group.cpp
lib/carve.cpp
lib/pointset.cpp
lib/intersect_debug.cpp

View File

@@ -1,156 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom.hpp>
#include <vector>
namespace carve {
namespace geom {
// n-dimensional AABB
template<unsigned ndim>
struct aabb {
typedef vector<ndim> vector_t;
typedef aabb<ndim> aabb_t;
vector_t pos; // the centre of the AABB
vector_t extent; // the extent of the AABB - the vector from the centre to the maximal vertex.
void empty();
bool isEmpty() const;
void fit(const vector_t &v1);
void fit(const vector_t &v1, const vector_t &v2);
void fit(const vector_t &v1, const vector_t &v2, const vector_t &v3);
template<typename iter_t, typename value_type>
void _fit(iter_t begin, iter_t end, value_type);
template<typename iter_t>
void _fit(iter_t begin, iter_t end, vector_t);
template<typename iter_t>
void _fit(iter_t begin, iter_t end, aabb_t);
template<typename iter_t>
void fit(iter_t begin, iter_t end);
template<typename iter_t, typename adapt_t>
void fit(iter_t begin, iter_t end, adapt_t adapt);
void unionAABB(const aabb<ndim> &a);
void expand(double pad);
bool completelyContains(const aabb<ndim> &other) const;
bool containsPoint(const vector_t &v) const;
bool intersectsLineSegment(const vector_t &v1, const vector_t &v2) const;
double axisSeparation(const aabb<ndim> &other, unsigned axis) const;
double maxAxisSeparation(const aabb<ndim> &other) const;
bool intersects(const aabb<ndim> &other) const;
bool intersects(const sphere<ndim> &s) const;
bool intersects(const plane<ndim> &plane) const;
bool intersects(const ray<ndim> &ray) const;
bool intersects(tri<ndim> tri) const;
bool intersects(const linesegment<ndim> &ls) const;
std::pair<double, double> rangeInDirection(const carve::geom::vector<ndim> &v) const;
vector_t min() const;
vector_t mid() const;
vector_t max() const;
double min(unsigned dim) const;
double mid(unsigned dim) const;
double max(unsigned dim) const;
double volume() const;
int compareAxis(const axis_pos &ap) const;
void constrainMax(const axis_pos &ap);
void constrainMin(const axis_pos &ap);
aabb getAABB() const;
aabb(const vector_t &_pos = vector_t::ZERO(),
const vector_t &_extent = vector_t::ZERO());
template<typename iter_t, typename adapt_t>
aabb(iter_t begin, iter_t end, adapt_t adapt);
template<typename iter_t>
aabb(iter_t begin, iter_t end);
aabb(const aabb<ndim> &a, const aabb<ndim> &b);
};
template<unsigned ndim>
bool operator==(const aabb<ndim> &a, const aabb<ndim> &b);
template<unsigned ndim>
bool operator!=(const aabb<ndim> &a, const aabb<ndim> &b);
template<unsigned ndim>
std::ostream &operator<<(std::ostream &o, const aabb<ndim> &a);
template<unsigned ndim>
double distance2(const aabb<3> &a, const vector<ndim> &v);
template<unsigned ndim>
double distance(const aabb<3> &a, const vector<ndim> &v);
template<unsigned ndim, typename obj_t>
struct get_aabb {
aabb<ndim> operator()(const obj_t &obj) const {
return obj.getAABB();
}
};
template<unsigned ndim, typename obj_t>
struct get_aabb<ndim, obj_t *> {
aabb<ndim> operator()(const obj_t *obj) const {
return obj->getAABB();
}
};
}
}
namespace carve {
namespace geom3d {
typedef carve::geom::aabb<3> AABB;
}
}
#include <carve/aabb_impl.hpp>

View File

@@ -1,440 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/vector.hpp>
#include <carve/geom3d.hpp>
#include <carve/geom.hpp>
#include <vector>
namespace carve {
namespace geom {
template<unsigned ndim>
void aabb<ndim>::empty() {
pos.setZero();
extent.setZero();
}
template<unsigned ndim>
bool aabb<ndim>::isEmpty() const {
return extent.exactlyZero();
}
template<unsigned ndim>
template<typename iter_t, typename value_type>
void aabb<ndim>::_fit(iter_t begin, iter_t end, value_type) {
if (begin == end) {
empty();
return;
}
vector_t min, max;
aabb<ndim> a = get_aabb<ndim, value_type>()(*begin); ++begin;
min = a.min();
max = a.max();
while (begin != end) {
aabb<ndim> a = get_aabb<ndim, value_type>()(*begin); ++begin;
assign_op(min, min, a.min(), carve::util::min_functor());
assign_op(max, max, a.max(), carve::util::max_functor());
}
pos = (min + max) / 2.0;
assign_op(extent, max - pos, pos - min, carve::util::max_functor());
}
template<unsigned ndim>
template<typename iter_t>
void aabb<ndim>::_fit(iter_t begin, iter_t end, vector_t) {
if (begin == end) {
empty();
return;
}
vector_t min, max;
bounds(begin, end, min, max);
pos = (min + max) / 2.0;
assign_op(extent, max - pos, pos - min, carve::util::max_functor());
}
template<unsigned ndim>
template<typename iter_t>
void aabb<ndim>::_fit(iter_t begin, iter_t end, aabb_t) {
if (begin == end) {
empty();
return;
}
vector_t min, max;
aabb<ndim> a = *begin++;
min = a.min();
max = a.max();
while (begin != end) {
aabb<ndim> a = *begin; ++begin;
assign_op(min, min, a.min(), carve::util::min_functor());
assign_op(max, max, a.max(), carve::util::max_functor());
}
pos = (min + max) / 2.0;
assign_op(extent, max - pos, pos - min, carve::util::max_functor());
}
template<unsigned ndim>
void aabb<ndim>::fit(const vector_t &v1) {
pos = v1;
extent.setZero();
}
template<unsigned ndim>
void aabb<ndim>::fit(const vector_t &v1, const vector_t &v2) {
vector_t min, max;
assign_op(min, v1, v2, carve::util::min_functor());
assign_op(max, v1, v2, carve::util::max_functor());
pos = (min + max) / 2.0;
assign_op(extent, max - pos, pos - min, carve::util::max_functor());
}
template<unsigned ndim>
void aabb<ndim>::fit(const vector_t &v1, const vector_t &v2, const vector_t &v3) {
vector_t min, max;
min = max = v1;
assign_op(min, min, v2, carve::util::min_functor());
assign_op(max, max, v2, carve::util::max_functor());
assign_op(min, min, v3, carve::util::min_functor());
assign_op(max, max, v3, carve::util::max_functor());
pos = (min + max) / 2.0;
assign_op(extent, max - pos, pos - min, carve::util::max_functor());
}
template<unsigned ndim>
template<typename iter_t, typename adapt_t>
void aabb<ndim>::fit(iter_t begin, iter_t end, adapt_t adapt) {
vector_t min, max;
bounds(begin, end, adapt, min, max);
pos = (min + max) / 2.0;
assign_op(extent, max - pos, pos - min, carve::util::max_functor());
}
template<unsigned ndim>
template<typename iter_t>
void aabb<ndim>::fit(iter_t begin, iter_t end) {
_fit(begin, end, typename std::iterator_traits<iter_t>::value_type());
}
template<unsigned ndim>
void aabb<ndim>::expand(double pad) {
extent += pad;
}
template<unsigned ndim>
void aabb<ndim>::unionAABB(const aabb<ndim> &a) {
vector_t vmin, vmax;
assign_op(vmin, min(), a.min(), carve::util::min_functor());
assign_op(vmax, max(), a.max(), carve::util::max_functor());
pos = (vmin + vmax) / 2.0;
assign_op(extent, vmax - pos, pos - vmin, carve::util::max_functor());
}
template<unsigned ndim>
bool aabb<ndim>::completelyContains(const aabb<ndim> &other) const {
for (unsigned i = 0; i < ndim; ++i) {
if (fabs(other.pos.v[i] - pos.v[i]) + other.extent.v[i] > extent.v[i]) return false;
}
return true;
}
template<unsigned ndim>
bool aabb<ndim>::containsPoint(const vector_t &v) const {
for (unsigned i = 0; i < ndim; ++i) {
if (fabs(v.v[i] - pos.v[i]) > extent.v[i]) return false;
}
return true;
}
template<unsigned ndim>
double aabb<ndim>::axisSeparation(const aabb<ndim> &other, unsigned axis) const {
return fabs(other.pos.v[axis] - pos.v[axis]) - extent.v[axis] - other.extent.v[axis];
}
template<unsigned ndim>
double aabb<ndim>::maxAxisSeparation(const aabb<ndim> &other) const {
double m = axisSeparation(other, 0);
for (unsigned i = 1; i < ndim; ++i) {
m = std::max(m, axisSeparation(other, i));
}
return m;
}
template<unsigned ndim>
bool aabb<ndim>::intersects(const aabb<ndim> &other) const {
return maxAxisSeparation(other) <= 0.0;
}
template<unsigned ndim>
bool aabb<ndim>::intersects(const sphere<ndim> &s) const {
double r = 0.0;
for (unsigned i = 0; i < ndim; ++i) {
double t = fabs(s.C[i] - pos[i]) - extent[i]; if (t > 0.0) r += t*t;
}
return r <= s.r*s.r;
}
template<unsigned ndim>
bool aabb<ndim>::intersects(const plane<ndim> &plane) const {
double d1 = fabs(distance(plane, pos));
double d2 = dot(abs(plane.N), extent);
return d1 <= d2;
}
template<unsigned ndim>
bool aabb<ndim>::intersects(const linesegment<ndim> &ls) const {
return intersectsLineSegment(ls.v1, ls.v2);
}
template<unsigned ndim>
std::pair<double, double> aabb<ndim>::rangeInDirection(const carve::geom::vector<ndim> &v) const {
double d1 = dot(v, pos);
double d2 = dot(abs(v), extent);
return std::make_pair(d1 - d2, d1 + d2);
}
template<unsigned ndim>
typename aabb<ndim>::vector_t aabb<ndim>::min() const { return pos - extent; }
template<unsigned ndim>
typename aabb<ndim>::vector_t aabb<ndim>::mid() const { return pos; }
template<unsigned ndim>
typename aabb<ndim>::vector_t aabb<ndim>::max() const { return pos + extent; }
template<unsigned ndim>
double aabb<ndim>::min(unsigned dim) const { return pos.v[dim] - extent.v[dim]; }
template<unsigned ndim>
double aabb<ndim>::mid(unsigned dim) const { return pos.v[dim]; }
template<unsigned ndim>
double aabb<ndim>::max(unsigned dim) const { return pos.v[dim] + extent.v[dim]; }
template<unsigned ndim>
double aabb<ndim>::volume() const {
double v = 1.0;
for (size_t dim = 0; dim < ndim; ++dim) { v *= 2.0 * extent.v[dim]; }
return v;
}
template<unsigned ndim>
int aabb<ndim>::compareAxis(const axis_pos &ap) const {
double p = ap.pos - pos[ap.axis];
if (p > extent[ap.axis]) return -1;
if (p < -extent[ap.axis]) return +1;
return 0;
}
template<unsigned ndim>
void aabb<ndim>::constrainMax(const axis_pos &ap) {
if (pos[ap.axis] + extent[ap.axis] > ap.pos) {
double min = std::min(ap.pos, pos[ap.axis] - extent[ap.axis]);
pos[ap.axis] = (min + ap.pos) / 2.0;
extent[ap.axis] = ap.pos - pos[ap.axis];
}
}
template<unsigned ndim>
void aabb<ndim>::constrainMin(const axis_pos &ap) {
if (pos[ap.axis] - extent[ap.axis] < ap.pos) {
double max = std::max(ap.pos, pos[ap.axis] + extent[ap.axis]);
pos[ap.axis] = (ap.pos + max) / 2.0;
extent[ap.axis] = pos[ap.axis] - ap.pos;
}
}
template<unsigned ndim>
aabb<ndim> aabb<ndim>::getAABB() const {
return *this;
}
template<unsigned ndim>
aabb<ndim>::aabb(const vector_t &_pos,
const vector_t &_extent) : pos(_pos), extent(_extent) {
}
template<unsigned ndim>
template<typename iter_t, typename adapt_t>
aabb<ndim>::aabb(iter_t begin, iter_t end, adapt_t adapt) {
fit(begin, end, adapt);
}
template<unsigned ndim>
template<typename iter_t>
aabb<ndim>::aabb(iter_t begin, iter_t end) {
fit(begin, end);
}
template<unsigned ndim>
aabb<ndim>::aabb(const aabb<ndim> &a, const aabb<ndim> &b) {
fit(a, b);
}
template<unsigned ndim>
bool operator==(const aabb<ndim> &a, const aabb<ndim> &b) {
return a.pos == b.pos && a.extent == b.extent;
}
template<unsigned ndim>
bool operator!=(const aabb<ndim> &a, const aabb<ndim> &b) {
return a.pos != b.pos || a.extent != b.extent;
}
template<unsigned ndim>
std::ostream &operator<<(std::ostream &o, const aabb<ndim> &a) {
o << (a.pos - a.extent) << "--" << (a.pos + a.extent);
return o;
}
template<unsigned ndim>
double distance2(const aabb<3> &a, const vector<ndim> &v) {
double d2 = 0.0;
for (unsigned i = 0; i < ndim; ++i) {
double d = ::fabs(v.v[i] - a.pos.v[i]) - a.extent.v[i];
if (d > 0.0) {
d2 += d * d;
}
}
return d2;
}
template<unsigned ndim>
double distance(const aabb<3> &a, const vector<ndim> &v) {
return ::sqrt(distance2(a, v));
}
template<>
inline bool aabb<3>::intersects(const ray<3> &ray) const {
vector<3> t = pos - ray.v;
double r;
//l.cross(x-axis)?
r = extent.y * fabs(ray.D.z) + extent.z * fabs(ray.D.y);
if (fabs(t.y * ray.D.z - t.z * ray.D.y) > r) return false;
//ray.D.cross(y-axis)?
r = extent.x * fabs(ray.D.z) + extent.z * fabs(ray.D.x);
if (fabs(t.z * ray.D.x - t.x * ray.D.z) > r) return false;
//ray.D.cross(z-axis)?
r = extent.x*fabs(ray.D.y) + extent.y*fabs(ray.D.x);
if (fabs(t.x * ray.D.y - t.y * ray.D.x) > r) return false;
return true;
}
template<>
inline bool aabb<3>::intersectsLineSegment(const vector<3> &v1, const vector<3> &v2) const {
vector<3> half_length = 0.5 * (v2 - v1);
vector<3> t = pos - half_length - v1;
double r;
//do any of the principal axes form a separating axis?
if(fabs(t.x) > extent.x + fabs(half_length.x)) return false;
if(fabs(t.y) > extent.y + fabs(half_length.y)) return false;
if(fabs(t.z) > extent.z + fabs(half_length.z)) return false;
// NOTE: Since the separating axis is perpendicular to the line in
// these last four cases, the line does not contribute to the
// projection.
//line.cross(x-axis)?
r = extent.y * fabs(half_length.z) + extent.z * fabs(half_length.y);
if (fabs(t.y * half_length.z - t.z * half_length.y) > r) return false;
//half_length.cross(y-axis)?
r = extent.x * fabs(half_length.z) + extent.z * fabs(half_length.x);
if (fabs(t.z * half_length.x - t.x * half_length.z) > r) return false;
//half_length.cross(z-axis)?
r = extent.x*fabs(half_length.y) + extent.y*fabs(half_length.x);
if (fabs(t.x * half_length.y - t.y * half_length.x) > r) return false;
return true;
}
template<int Ax, int Ay, int Az, int c>
static inline bool intersectsTriangle_axisTest_3(const aabb<3> &aabb, const tri<3> &tri) {
const int d = (c+1) % 3, e = (c+2) % 3;
const vector<3> a = cross(VECTOR(Ax, Ay, Az), tri.v[d] - tri.v[c]);
double p1 = dot(a, tri.v[c]), p2 = dot(a, tri.v[e]);
if (p1 > p2) std::swap(p1, p2);
const double r = dot(abs(a), aabb.extent);
return !(p1 > r || p2 < -r);
}
template<int c>
static inline bool intersectsTriangle_axisTest_2(const aabb<3> &aabb, const tri<3> &tri) {
double vmin = std::min(std::min(tri.v[0][c], tri.v[1][c]), tri.v[2][c]),
vmax = std::max(std::max(tri.v[0][c], tri.v[1][c]), tri.v[2][c]);
return !(vmin > aabb.extent[c] || vmax < -aabb.extent[c]);
}
static inline bool intersectsTriangle_axisTest_1(const aabb<3> &aabb, const tri<3> &tri) {
vector<3> n = cross(tri.v[1] - tri.v[0], tri.v[2] - tri.v[0]);
double d1 = fabs(dot(n, tri.v[0]));
double d2 = dot(abs(n), aabb.extent);
return d1 <= d2;
}
template<>
inline bool aabb<3>::intersects(tri<3> tri) const {
tri.v[0] -= pos;
tri.v[1] -= pos;
tri.v[2] -= pos;
if (!intersectsTriangle_axisTest_2<0>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_2<1>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_2<2>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<1,0,0,0>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<1,0,0,1>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<1,0,0,2>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<0,1,0,0>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<0,1,0,1>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<0,1,0,2>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<0,0,1,0>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<0,0,1,1>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_3<0,0,1,2>(*this, tri)) return false;
if (!intersectsTriangle_axisTest_1(*this, tri)) return false;
return true;
}
}
}

View File

@@ -1,238 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#if defined(CMAKE_BUILD)
# include <carve/config.h>
#elif defined(XCODE_BUILD)
# include <carve/xcode_config.h>
#elif defined(_MSC_VER)
# include <carve/vcpp_config.h>
#else
# include <carve/config.h>
#endif
#if defined(WIN32)
# include <carve/win32.h>
#elif defined(__GNUC__)
# include <carve/gnu_cxx.h>
#endif
#if defined(CARVE_SYSTEM_BOOST)
# define BOOST_INCLUDE(x) <boost/x>
#else
# define BOOST_INCLUDE(x) <carve/external/boost/x>
#endif
#include <math.h>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <sstream>
#include <iomanip>
#include <carve/collection.hpp>
#include <carve/util.hpp>
#include <stdarg.h>
#define STR(x) #x
#define XSTR(x) STR(x)
/**
* \brief Top level Carve namespace.
*/
namespace carve {
static struct noinit_t {} NOINIT;
inline std::string fmtstring(const char *fmt, ...);
/**
* \brief Base class for all Carve exceptions.
*/
struct exception {
private:
mutable std::string err;
mutable std::ostringstream accum;
public:
exception(const std::string &e) : err(e), accum() { }
exception() : err(), accum() { }
exception(const exception &e) : err(e.str()), accum() { }
exception &operator=(const exception &e) {
if (this != &e) {
err = e.str();
accum.str("");
}
return *this;
}
const std::string &str() const {
if (accum.str().size() > 0) {
err += accum.str();
accum.str("");
}
return err;
}
template<typename T>
exception &operator<<(const T &t) {
accum << t;
return *this;
}
};
template<typename iter_t, typename order_t = std::less<typename std::iterator_traits<iter_t>::value_type > >
struct index_sort {
iter_t base;
order_t order;
index_sort(const iter_t &_base) : base(_base), order() { }
index_sort(const iter_t &_base, const order_t &_order) : base(_base), order(_order) { }
template<typename U>
bool operator()(const U &a, const U &b) {
return order(*(base + a), *(base + b));
}
};
template<typename iter_t, typename order_t>
index_sort<iter_t, order_t> make_index_sort(const iter_t &base, const order_t &order) {
return index_sort<iter_t, order_t>(base, order);
}
template<typename iter_t>
index_sort<iter_t> make_index_sort(const iter_t &base) {
return index_sort<iter_t>(base);
}
enum RayIntersectionClass {
RR_DEGENERATE = -2,
RR_PARALLEL = -1,
RR_NO_INTERSECTION = 0,
RR_INTERSECTION = 1
};
enum LineIntersectionClass {
COLINEAR = -1,
NO_INTERSECTION = 0,
INTERSECTION_LL = 1,
INTERSECTION_PL = 2,
INTERSECTION_LP = 3,
INTERSECTION_PP = 4
};
enum PointClass {
POINT_UNK = -2,
POINT_OUT = -1,
POINT_ON = 0,
POINT_IN = 1,
POINT_VERTEX = 2,
POINT_EDGE = 3
};
enum IntersectionClass {
INTERSECT_BAD = -1,
INTERSECT_NONE = 0,
INTERSECT_FACE = 1,
INTERSECT_VERTEX = 2,
INTERSECT_EDGE = 3,
INTERSECT_PLANE = 4,
};
extern double EPSILON;
extern double EPSILON2;
static inline void setEpsilon(double ep) { EPSILON = ep; EPSILON2 = ep * ep; }
template<typename T>
struct identity_t {
typedef T argument_type;
typedef T result_type;
const T &operator()(const T &t) const { return t; }
};
template<typename iter_t>
inline bool is_sorted(iter_t first, iter_t last) {
if (first == last) return true;
iter_t iter = first;
iter_t next = first; ++next;
for (; next != last; iter = next, ++next) {
if (*next < *iter) {
return false;
}
}
return true;
}
template<typename iter_t,
typename pred_t>
inline bool is_sorted(iter_t first, iter_t last, pred_t pred) {
if (first == last) return true;
iter_t iter = first;
iter_t next = first; ++next;
for (; next != last; iter = next, ++next) {
if (pred(*next, *iter)) {
return false;
}
}
return true;
}
inline double rangeSeparation(const std::pair<double, double> &a,
const std::pair<double, double> &b) {
if (a.second < b.first) {
return b.first - a.second;
} else if (b.second < a.first) {
return a.first - b.second;
} else {
return 0.0;
}
}
}
#if defined(_MSC_VER)
# define MACRO_BEGIN do {
# define MACRO_END __pragma(warning(push)) __pragma(warning(disable:4127)) } while(0) __pragma(warning(pop))
#else
# define MACRO_BEGIN do {
# define MACRO_END } while(0)
#endif
#if !defined(CARVE_NODEBUG)
# define CARVE_ASSERT(x) MACRO_BEGIN if (!(x)) throw carve::exception() << __FILE__ << ":" << __LINE__ << " " << #x; MACRO_END
#else
# define CARVE_ASSERT(X)
#endif
#define CARVE_FAIL(x) MACRO_BEGIN throw carve::exception() << __FILE__ << ":" << __LINE__ << " " << #x; MACRO_END

View File

@@ -1,93 +0,0 @@
// N.B. only appropriate for IEEE doubles.
// Cube root implementation obtained from code with the following notice:
/* @(#)s_cbrt.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
/* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly
but these catch some common cases. */
#if defined(i386) || defined(i486) || \
defined(intel) || defined(x86) || defined(i86pc) || \
defined(__alpha) || defined(__osf__)
#define __LITTLE_ENDIAN
#endif
#ifdef __LITTLE_ENDIAN
#define __HI(x) *(1+(int*)&x)
#define __LO(x) *(int*)&x
#define __HIp(x) *(1+(int*)x)
#define __LOp(x) *(int*)x
#else
#define __HI(x) *(int*)&x
#define __LO(x) *(1+(int*)&x)
#define __HIp(x) *(int*)x
#define __LOp(x) *(1+(int*)x)
#endif
/* cbrt(x)
* Return cube root of x
*/
inline double cbrt(double x) {
static const unsigned
B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */
B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */
static const double
C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */
D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */
E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */
F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */
G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */
int hx;
double r,s,t=0.0,w;
unsigned sign;
hx = __HI(x); /* high word of x */
sign=hx&0x80000000; /* sign= sign(x) */
hx ^=sign;
if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */
if((hx|__LO(x))==0)
return(x); /* cbrt(0) is itself */
__HI(x) = hx; /* x <- |x| */
/* rough cbrt to 5 bits */
if(hx<0x00100000) /* subnormal number */
{__HI(t)=0x43500000; /* set t= 2**54 */
t*=x; __HI(t)=__HI(t)/3+B2;
}
else
__HI(t)=hx/3+B1;
/* new cbrt to 23 bits, may be implemented in single precision */
r=t*t/x;
s=C+r*t;
t*=G+F/(s+E+D/s);
/* chopped to 20 bits and make it larger than cbrt(x) */
__LO(t)=0; __HI(t)+=0x00000001;
/* one step newton iteration to 53 bits with error less than 0.667 ulps */
s=t*t; /* t*t is exact */
r=x/s;
w=t+t;
r=(r-t)/(w+r); /* r-s is exact */
t=t+t*r;
/* retore the sign bit */
__HI(t) |= sign;
return(t);
}

View File

@@ -1,115 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/collection_types.hpp>
namespace carve {
namespace csg {
enum FaceClass {
FACE_UNCLASSIFIED = -3,
FACE_ON_ORIENT_OUT = -2,
FACE_OUT = -1,
FACE_ON = 0,
FACE_IN = +1,
FACE_ON_ORIENT_IN = +2
};
enum FaceClassBit {
FACE_ON_ORIENT_OUT_BIT = 0x01,
FACE_OUT_BIT = 0x02,
FACE_IN_BIT = 0x04,
FACE_ON_ORIENT_IN_BIT = 0x08,
FACE_ANY_BIT = 0x0f,
FACE_ON_BIT = 0x09,
FACE_NOT_ON_BIT = 0x06
};
static inline FaceClass class_bit_to_class(unsigned i) {
if (i & FACE_ON_ORIENT_OUT_BIT) return FACE_ON_ORIENT_OUT;
if (i & FACE_OUT_BIT) return FACE_OUT;
if (i & FACE_IN_BIT) return FACE_IN;
if (i & FACE_ON_ORIENT_IN_BIT) return FACE_ON_ORIENT_IN;
return FACE_UNCLASSIFIED;
}
static inline unsigned class_to_class_bit(FaceClass f) {
switch (f) {
case FACE_ON_ORIENT_OUT: return FACE_ON_ORIENT_OUT_BIT;
case FACE_OUT: return FACE_OUT_BIT;
case FACE_ON: return FACE_ON_BIT;
case FACE_IN: return FACE_IN_BIT;
case FACE_ON_ORIENT_IN: return FACE_ON_ORIENT_IN_BIT;
case FACE_UNCLASSIFIED: return FACE_ANY_BIT;
default: return 0;
}
}
enum EdgeClass {
EDGE_UNK = -2,
EDGE_OUT = -1,
EDGE_ON = 0,
EDGE_IN = 1
};
const char *ENUM(FaceClass f);
const char *ENUM(PointClass p);
struct ClassificationInfo {
const carve::mesh::Mesh<3> *intersected_mesh;
FaceClass classification;
ClassificationInfo() : intersected_mesh(NULL), classification(FACE_UNCLASSIFIED) { }
ClassificationInfo(const carve::mesh::Mesh<3> *_intersected_mesh,
FaceClass _classification) :
intersected_mesh(_intersected_mesh),
classification(_classification) {
}
bool intersectedMeshIsClosed() const {
return intersected_mesh->isClosed();
}
};
struct EC2 {
EdgeClass cls[2];
EC2() { cls[0] = cls[1] = EDGE_UNK; }
EC2(EdgeClass a, EdgeClass b) { cls[0] = a; cls[1] = b; }
};
struct PC2 {
PointClass cls[2];
PC2() { cls[0] = cls[1] = POINT_UNK; }
PC2(PointClass a, PointClass b) { cls[0] = a; cls[1] = b; }
};
typedef std::unordered_map<std::pair<const carve::mesh::MeshSet<3>::vertex_t *, const carve::mesh::MeshSet<3>::vertex_t *>,
EC2> EdgeClassification;
typedef std::unordered_map<const carve::mesh::Vertex<3> *, PC2> VertexClassification;
}
}

View File

@@ -1,51 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/collection/unordered.hpp>
namespace carve {
template<typename set_t>
class set_insert_iterator : public std::iterator<std::output_iterator_tag, void, void, void, void> {
protected:
set_t *set;
public:
set_insert_iterator(set_t &s) : set(&s) {
}
set_insert_iterator &
operator=(typename set_t::const_reference value) {
set->insert(value);
return *this;
}
set_insert_iterator &operator*() { return *this; }
set_insert_iterator &operator++() { return *this; }
set_insert_iterator &operator++(int) { return *this; }
};
template<typename set_t>
inline set_insert_iterator<set_t>
set_inserter(set_t &s) {
return set_insert_iterator<set_t>(s);
}
}

View File

@@ -1,43 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#if defined(HAVE_STD_UNORDERED_COLLECTIONS)
# include <carve/collection/unordered/std_impl.hpp>
#elif defined(HAVE_TR1_UNORDERED_COLLECTIONS)
# include <carve/collection/unordered/tr1_impl.hpp>
#elif defined(HAVE_BOOST_UNORDERED_COLLECTIONS)
# include <carve/collection/unordered/boost_impl.hpp>
#elif defined(HAVE_LIBSTDCPP_UNORDERED_COLLECTIONS)
# include <carve/collection/unordered/libstdcpp_impl.hpp>
#elif defined(_MSC_VER) && _MSC_VER >= 1300
# include <carve/collection/unordered/vcpp_impl.hpp>
#else
# include <carve/collection/unordered/fallback_impl.hpp>
#endif

View File

@@ -1,45 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include BOOST_INCLUDE(unordered_set.hpp)
#include BOOST_INCLUDE(unordered_map.hpp)
#include <functional>
namespace std {
template <typename Key, typename T, typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key> >
class unordered_map : public boost::unordered_map<Key, T, Hash, Pred> {
public:
typedef T data_type;
};
template <typename Key, typename T, typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key> >
class unordered_multimap : public boost::unordered_multimap<Key, T, Hash, Pred> {
};
template <typename Value, typename Hash = boost::hash<Value>,
typename Pred = std::equal_to<Value> >
class unordered_set : public boost::unordered_set<Value, Hash, Pred> {
};
}
#undef UNORDERED_COLLECTIONS_SUPPORT_RESIZE

View File

@@ -1,40 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <set>
#include <map>
namespace std {
template<typename K, typename T, typename H = int>
class unordered_map : public std::map<K, T> {
typedef std::map<K, T> super;
public:
typedef T data_type;
};
template<typename K, typename H = int>
class unordered_set : public std::set<K> {
typedef std::set<K> super;
public:
};
}
#undef UNORDERED_COLLECTIONS_SUPPORT_RESIZE

View File

@@ -1,61 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <ext/hash_map>
#include <ext/hash_set>
namespace __gnu_cxx {
template <typename T>
struct hash<T *> : public std::unary_function<T *, size_t> {
size_t operator()(T *v) const {
size_t x = (size_t)(v);
return x + (x>>3);
}
};
template <typename A, typename B>
struct hash<std::pair<A, B> > : public std::unary_function<std::pair<A, B>, size_t> {
size_t operator()(const std::pair<A, B> &v) const {
std::size_t seed = 0;
seed ^= hash<A>()(v.first);
seed ^= hash<B>()(v.second) + (seed<<6) + (seed>>2);
return seed;
}
};
}
namespace std {
template<typename K, typename V, typename H = __gnu_cxx::hash<K> >
class unordered_map : public __gnu_cxx::hash_map<K, V, H> {
typedef __gnu_cxx::hash_map<K, V, H> super;
public:
typedef typename super::mapped_type data_type;
};
template<typename K, typename H = __gnu_cxx::hash<K> >
class unordered_set : public __gnu_cxx::hash_set<K, H> {
typedef __gnu_cxx::hash_set<K, H> super;
public:
};
}
#define UNORDERED_COLLECTIONS_SUPPORT_RESIZE 1

View File

@@ -1,23 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <unordered_map>
#include <unordered_set>
#undef UNORDERED_COLLECTIONS_SUPPORT_RESIZE

View File

@@ -1,58 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <tr1/functional>
namespace std {
namespace tr1 {
template <typename A, typename B>
struct hash<std::pair<A, B> > : public std::unary_function<std::pair<A, B>, size_t> {
size_t operator()(const std::pair<A, B> &v) const {
std::size_t seed = 0;
seed ^= hash<A>()(v.first);
seed ^= hash<B>()(v.second) + (seed<<6) + (seed>>2);
return seed;
}
};
}
template <typename Key, typename T,
typename Hash = tr1::hash<Key>,
typename Pred = std::equal_to<Key> >
class unordered_map : public std::tr1::unordered_map<Key, T, Hash, Pred> {
public:
typedef T data_type;
};
template <typename Value,
typename Hash = tr1::hash<Value>,
typename Pred = std::equal_to<Value> >
class unordered_set : public std::tr1::unordered_set<Value, Hash, Pred> {
public:
};
}
#undef UNORDERED_COLLECTIONS_SUPPORT_RESIZE

View File

@@ -1,65 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <hash_map>
#include <hash_set>
namespace std {
namespace {
template<class Value, class Hash> class hash_traits {
Hash hash_value;
std::less<Value> comp;
public:
enum {
bucket_size = 4,
min_buckets = 8
};
// hash _Keyval to size_t value
size_t operator()(const Value& v) const {
return ((size_t)hash_value(v));
}
// test if _Keyval1 ordered before _Keyval2
bool operator()(const Value& v1, const Value& v2) const {
return (comp(v1, v2));
}
};
}
template <typename Key, typename T, typename Hash = stdext::hash_compare<Key, less<Key> >, typename Pred = std::equal_to<Key> >
class unordered_map
: public stdext::hash_map<Key, T, hash_traits<Key, Hash> > {
typedef stdext::hash_map<Key, T, hash_traits<Key, Hash> > super;
public:
unordered_map() : super() {}
};
template <typename Value, typename Hash = stdext::hash_compare<Key, less<Key> >, typename Pred = std::equal_to<Value> >
class unordered_set
: public stdext::hash_set<Value, hash_traits<Value, Hash> > {
typedef stdext::hash_set<Value, hash_traits<Value, Hash> > super;
public:
unordered_set() : super() {}
};
}
#undef UNORDERED_COLLECTIONS_SUPPORT_RESIZE

View File

@@ -1,63 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/mesh.hpp>
namespace carve {
namespace csg {
typedef std::pair<
carve::mesh::MeshSet<3>::vertex_t *,
carve::mesh::MeshSet<3>::vertex_t *> V2;
typedef std::pair<
carve::mesh::MeshSet<3>::face_t *,
carve::mesh::MeshSet<3>::face_t *> F2;
static inline V2 ordered_edge(
carve::mesh::MeshSet<3>::vertex_t *a,
carve::mesh::MeshSet<3>::vertex_t *b) {
return V2(std::min(a, b), std::max(a, b));
}
static inline V2 flip(const V2 &v) {
return V2(v.second, v.first);
}
// include/carve/csg.hpp include/carve/faceloop.hpp
// lib/intersect.cpp lib/intersect_classify_common_impl.hpp
// lib/intersect_classify_edge.cpp
// lib/intersect_classify_group.cpp
// lib/intersect_classify_simple.cpp
// lib/intersect_face_division.cpp lib/intersect_group.cpp
// lib/intersect_half_classify_group.cpp
typedef std::unordered_set<V2> V2Set;
// include/carve/csg.hpp include/carve/polyhedron_decl.hpp
// lib/csg_collector.cpp lib/intersect.cpp
// lib/intersect_common.hpp lib/intersect_face_division.cpp
// lib/polyhedron.cpp
typedef std::unordered_map<
carve::mesh::MeshSet<3>::vertex_t *,
carve::mesh::MeshSet<3>::vertex_t *> VVMap;
}
}

View File

@@ -1,47 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom.hpp>
namespace carve {
namespace colour {
static inline void HSV2RGB(float H, float S, float V, float &r, float &g, float &b) {
H = 6.0f * H;
if (S < 5.0e-6) {
r = g = b = V; return;
} else {
int i = (int)H;
float f = H - i;
float p1 = V * (1.0f - S);
float p2 = V * (1.0f - S * f);
float p3 = V * (1.0f - S * (1.0f - f));
switch (i) {
case 0: r = V; g = p3; b = p1; return;
case 1: r = p2; g = V; b = p1; return;
case 2: r = p1; g = V; b = p3; return;
case 3: r = p1; g = p2; b = V; return;
case 4: r = p3; g = p1; b = V; return;
case 5: r = V; g = p1; b = p2; return;
}
}
r = g = b = 0.0;
}
}
}

View File

@@ -1,30 +0,0 @@
#define CARVE_VERSION "2.0.0a"
#undef CARVE_DEBUG
#undef CARVE_DEBUG_WRITE_PLY_DATA
#if defined(__GNUC__)
# if !defined(HAVE_BOOST_UNORDERED_COLLECTIONS)
# define HAVE_TR1_UNORDERED_COLLECTIONS
# endif
# define HAVE_STDINT_H
#endif
// Support for latest Clang/LLVM on FreeBSD which does have different libcxx.
//
// TODO(sergey): Move it some some more generic header with platform-specific
// declarations.
// Indicates whether __is_heap is available
#undef HAVE_IS_HEAP
#ifdef __GNUC__
// NeyBSD doesn't have __is_heap
# ifndef __NetBSD__
# define HAVE_IS_HEAP
# ifdef _LIBCPP_VERSION
# define __is_heap is_heap
# endif // _LIBCPP_VERSION
# endif // !__NetBSD__
#endif // __GNUC__

View File

@@ -1,52 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <list>
#include <vector>
#include <algorithm>
#include <carve/carve.hpp>
#include <carve/geom2d.hpp>
namespace carve {
namespace geom {
std::vector<int> convexHull(const std::vector<carve::geom2d::P2> &points);
template<typename project_t, typename polygon_container_t>
std::vector<int> convexHull(const project_t &project, const polygon_container_t &points) {
std::vector<carve::geom2d::P2> proj;
proj.reserve(points.size());
for (typename polygon_container_t::const_iterator i = points.begin(); i != points.end(); ++i) {
proj.push_back(project(*i));
}
return convexHull(proj);
}
template<typename project_t, typename iter_t>
std::vector<int> convexHull(const project_t &project, iter_t beg, iter_t end, size_t size_hint = 0) {
std::vector<carve::geom2d::P2> proj;
if (size_hint) proj.reserve(size_hint);
for (; beg != end; ++beg) {
proj.push_back(project(*beg));
}
return convexHull(proj);
}
}
}

View File

@@ -1,510 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <list>
#include <vector>
#include <algorithm>
#include <carve/carve.hpp>
#include <carve/geom3d.hpp>
#include <carve/mesh.hpp>
#include <carve/collection_types.hpp>
#include <carve/classification.hpp>
#include <carve/iobj.hpp>
#include <carve/faceloop.hpp>
#include <carve/intersection.hpp>
#include <carve/rtree.hpp>
namespace carve {
namespace csg {
class VertexPool {
typedef carve::mesh::MeshSet<3>::vertex_t vertex_t;
const static unsigned blocksize = 1024;
typedef std::list<std::vector<vertex_t> > pool_t;
pool_t pool;
public:
void reset();
vertex_t *get(const vertex_t::vector_t &v = vertex_t::vector_t::ZERO());
bool inPool(vertex_t *v) const;
VertexPool();
~VertexPool();
};
namespace detail {
struct Data;
class LoopEdges;
}
/**
* \class CSG
* \brief The class responsible for the computation of CSG operations.
*
*/
class CSG {
private:
public:
typedef carve::mesh::MeshSet<3> meshset_t;
struct Hook {
/**
* \class Hook
* \brief Provides API access to intermediate steps in CSG calculation.
*
*/
virtual void intersectionVertex(const meshset_t::vertex_t * /* vertex */,
const IObjPairSet & /* intersections */) {
}
virtual void processOutputFace(std::vector<meshset_t::face_t *> & /* faces */,
const meshset_t::face_t * /* orig_face */,
bool /* flipped */) {
}
virtual void resultFace(const meshset_t::face_t * /* new_face */,
const meshset_t::face_t * /* orig_face */,
bool /* flipped */) {
}
virtual void edgeDivision(const meshset_t::edge_t * /* orig_edge */,
size_t /* orig_edge_idx */,
const meshset_t::vertex_t * /* v1 */,
const meshset_t::vertex_t * /* v2 */) {
}
virtual ~Hook() {
}
};
/**
* \class Hooks
* \brief Management of API hooks.
*
*/
class Hooks {
public:
enum {
RESULT_FACE_HOOK = 0,
PROCESS_OUTPUT_FACE_HOOK = 1,
INTERSECTION_VERTEX_HOOK = 2,
EDGE_DIVISION_HOOK = 3,
HOOK_MAX = 4,
RESULT_FACE_BIT = 0x0001,
PROCESS_OUTPUT_FACE_BIT = 0x0002,
INTERSECTION_VERTEX_BIT = 0x0004,
EDGE_DIVISION_BIT = 0x0008
};
std::vector<std::list<Hook *> > hooks;
bool hasHook(unsigned hook_num);
void intersectionVertex(const meshset_t::vertex_t *vertex,
const IObjPairSet &intersections);
void processOutputFace(std::vector<meshset_t::face_t *> &faces,
const meshset_t::face_t *orig_face,
bool flipped);
void resultFace(const meshset_t::face_t *new_face,
const meshset_t::face_t *orig_face,
bool flipped);
void edgeDivision(const meshset_t::edge_t *orig_edge,
size_t orig_edge_idx,
const meshset_t::vertex_t *v1,
const meshset_t::vertex_t *v2);
void registerHook(Hook *hook, unsigned hook_bits);
void unregisterHook(Hook *hook);
void reset();
Hooks();
~Hooks();
};
/**
* \class Collector
* \brief Base class for objects responsible for selecting result from which form the result polyhedron.
*
*/
class Collector {
Collector(const Collector &);
Collector &operator=(const Collector &);
protected:
public:
virtual void collect(FaceLoopGroup *group, CSG::Hooks &) =0;
virtual meshset_t *done(CSG::Hooks &) =0;
Collector() {}
virtual ~Collector() {}
};
private:
typedef carve::geom::RTreeNode<3, carve::mesh::Face<3> *> face_rtree_t;
typedef std::unordered_map<carve::mesh::Face<3> *, std::vector<carve::mesh::Face<3> *> > face_pairs_t;
/// The computed intersection data.
Intersections intersections;
/// A map from intersection point to a set of intersections
/// represented by pairs of intersection objects.
VertexIntersections vertex_intersections;
/// A pool from which temporary vertices are allocated. Also
/// provides testing for pool membership.
VertexPool vertex_pool;
void init();
void makeVertexIntersections();
void groupIntersections();
void _generateVertexVertexIntersections(meshset_t::vertex_t *va,
meshset_t::edge_t *eb);
void generateVertexVertexIntersections(meshset_t::face_t *a,
const std::vector<meshset_t::face_t *> &b);
void _generateVertexEdgeIntersections(meshset_t::vertex_t *va,
meshset_t::edge_t *eb);
void generateVertexEdgeIntersections(meshset_t::face_t *a,
const std::vector<meshset_t::face_t *> &b);
void _generateEdgeEdgeIntersections(meshset_t::edge_t *ea,
meshset_t::edge_t *eb);
void generateEdgeEdgeIntersections(meshset_t::face_t *a,
const std::vector<meshset_t::face_t *> &b);
void _generateVertexFaceIntersections(meshset_t::face_t *fa,
meshset_t::edge_t *eb);
void generateVertexFaceIntersections(meshset_t::face_t *a,
const std::vector<meshset_t::face_t *> &b);
void _generateEdgeFaceIntersections(meshset_t::face_t *fa,
meshset_t::edge_t *eb);
void generateEdgeFaceIntersections(meshset_t::face_t *a,
const std::vector<meshset_t::face_t *> &b);
void generateIntersectionCandidates(meshset_t *a,
const face_rtree_t *a_node,
meshset_t *b,
const face_rtree_t *b_node,
face_pairs_t &face_pairs,
bool descend_a = true);
/**
* \brief Compute all points of intersection between poly \a a and poly \a b
*
* @param a Polyhedron a.
* @param b Polyhedron b.
*/
void generateIntersections(meshset_t *a,
const face_rtree_t *a_node,
meshset_t *b,
const face_rtree_t *b_node,
detail::Data &data);
/**
* \brief Generate tables of intersecting pairs of faces.
*
* @param[out] data Internal data-structure holding intersection info.
*/
void intersectingFacePairs(detail::Data &data);
/**
* \brief Divide edges in \a edges that are intersected by polyhedron \a poly
*
* @param edges The edges to divide.
* @param[in] poly The polyhedron to divide against.
* @param[in,out] data Intersection information.
*/
void divideEdges(
const std::vector<meshset_t::edge_t> &edges,
meshset_t *poly,
detail::Data &data);
void divideIntersectedEdges(detail::Data &data);
/**
* \brief From the intersection points of pairs of intersecting faces, compute intersection edges.
*
* @param[out] eclass Classification information about created edges.
* @param[in,out] data Intersection information.
*/
void makeFaceEdges(
EdgeClassification &eclass,
detail::Data &data);
friend void classifyEasyFaces(
FaceLoopList &face_loops,
VertexClassification &vclass,
meshset_t *other_poly,
int other_poly_num,
CSG &csg,
CSG::Collector &collector);
size_t generateFaceLoops(
meshset_t *poly,
const detail::Data &data,
FaceLoopList &face_loops_out);
// intersect_group.cpp
/**
* \brief Build a loop edge mapping from a list of face loops.
*
* @param[in] loops A list of face loops.
* @param[in] edge_count A hint as to the number of edges in \a loops.
* @param[out] edge_map The calculated map of edges to loops.
*/
void makeEdgeMap(
const FaceLoopList &loops,
size_t edge_count,
detail::LoopEdges &edge_map);
/**
* \brief Divide a list of face loops into groups that are connected by at least one edge not present in \a no_cross.
*
* @param[in] src The source mesh from which these loops derive.
* @param[in,out] face_loops The list of loops (will be emptied as a side effect)
* @param[in] loop_edges A loop edge map used for traversing connected loops.
* @param[in] no_cross A set of edges not to cross.
* @param[out] out_loops A list of grouped face loops.
*/
void groupFaceLoops(
meshset_t *src,
FaceLoopList &face_loops,
const detail::LoopEdges &loop_edges,
const V2Set &no_cross,
FLGroupList &out_loops);
/**
* \brief Find the set of edges shared between two edge maps.
*
* @param[in] edge_map_a The first edge map.
* @param[in] edge_map_b The second edge map.
* @param[out] shared_edges The resulting set of common edges.
*/
void findSharedEdges(
const detail::LoopEdges &edge_map_a,
const detail::LoopEdges &edge_map_b,
V2Set &shared_edges);
// intersect_classify_edge.cpp
/**
*
*
* @param shared_edges
* @param vclass
* @param poly_a
* @param a_loops_grouped
* @param a_edge_map
* @param poly_b
* @param b_loops_grouped
* @param b_edge_map
* @param collector
*/
void classifyFaceGroupsEdge(
const V2Set &shared_edges,
VertexClassification &vclass,
meshset_t *poly_a,
const face_rtree_t *poly_a_rtree,
FLGroupList &a_loops_grouped,
const detail::LoopEdges &a_edge_map,
meshset_t *poly_b,
const face_rtree_t *poly_b_rtree,
FLGroupList &b_loops_grouped,
const detail::LoopEdges &b_edge_map,
CSG::Collector &collector);
// intersect_classify_group.cpp
/**
*
*
* @param shared_edges
* @param vclass
* @param poly_a
* @param a_loops_grouped
* @param a_edge_map
* @param poly_b
* @param b_loops_grouped
* @param b_edge_map
* @param collector
*/
void classifyFaceGroups(
const V2Set &shared_edges,
VertexClassification &vclass,
meshset_t *poly_a,
const face_rtree_t *poly_a_rtree,
FLGroupList &a_loops_grouped,
const detail::LoopEdges &a_edge_map,
meshset_t *poly_b,
const face_rtree_t *poly_b_rtree,
FLGroupList &b_loops_grouped,
const detail::LoopEdges &b_edge_map,
CSG::Collector &collector);
// intersect_half_classify_group.cpp
/**
*
*
* @param shared_edges
* @param vclass
* @param poly_a
* @param a_loops_grouped
* @param a_edge_map
* @param poly_b
* @param b_loops_grouped
* @param b_edge_map
* @param FaceClass
* @param b_out
*/
void halfClassifyFaceGroups(
const V2Set &shared_edges,
VertexClassification &vclass,
meshset_t *poly_a,
const face_rtree_t *poly_a_rtree,
FLGroupList &a_loops_grouped,
const detail::LoopEdges &a_edge_map,
meshset_t *poly_b,
const face_rtree_t *poly_b_rtree,
FLGroupList &b_loops_grouped,
const detail::LoopEdges &b_edge_map,
std::list<std::pair<FaceClass, meshset_t *> > &b_out);
// intersect.cpp
/**
* \brief The main calculation method for CSG.
*
* @param[in] a Polyhedron a
* @param[in] b Polyhedron b
* @param[out] vclass
* @param[out] eclass
* @param[out] a_face_loops
* @param[out] b_face_loops
* @param[out] a_edge_count
* @param[out] b_edge_count
*/
void calc(
meshset_t *a,
const face_rtree_t *a_rtree,
meshset_t *b,
const face_rtree_t *b_rtree,
VertexClassification &vclass,
EdgeClassification &eclass,
FaceLoopList &a_face_loops,
FaceLoopList &b_face_loops,
size_t &a_edge_count,
size_t &b_edge_count);
public:
/**
* \enum OP
* \brief Enumeration of the supported CSG operations.
*/
enum OP {
UNION, /**< in a or b. */
INTERSECTION, /**< in a and b. */
A_MINUS_B, /**< in a, but not b. */
B_MINUS_A, /**< in b, but not a. */
SYMMETRIC_DIFFERENCE, /**< in a or b, but not both. */
ALL /**< all split faces from a and b */
};
/**
* \enum CLASSIFY_TYPE
* \brief The type of classification algorithm to use.
*/
enum CLASSIFY_TYPE {
CLASSIFY_NORMAL, /**< Normal (group) classifier. */
CLASSIFY_EDGE /**< Edge classifier. */
};
CSG::Hooks hooks; /**< The manager for calculation hooks. */
CSG();
~CSG();
/**
* \brief Compute a CSG operation between two polyhedra, \a a and \a b.
*
* @param a Polyhedron a
* @param b Polyhedron b
* @param collector The collector (determines the CSG operation performed)
* @param shared_edges A pointer to a set that will be populated with shared edges (if not NULL).
* @param classify_type The type of classifier to use.
*
* @return
*/
meshset_t *compute(
meshset_t *a,
meshset_t *b,
CSG::Collector &collector,
V2Set *shared_edges = NULL,
CLASSIFY_TYPE classify_type = CLASSIFY_NORMAL);
/**
* \brief Compute a CSG operation between two closed polyhedra, \a a and \a b.
*
* @param a Polyhedron a
* @param b Polyhedron b
* @param op The CSG operation (A collector is created automatically).
* @param shared_edges A pointer to a set that will be populated with shared edges (if not NULL).
* @param classify_type The type of classifier to use.
*
* @return
*/
meshset_t *compute(
meshset_t *a,
meshset_t *b,
OP op,
V2Set *shared_edges = NULL,
CLASSIFY_TYPE classify_type = CLASSIFY_NORMAL);
void slice(
meshset_t *a,
meshset_t *b,
std::list<meshset_t *> &a_sliced,
std::list<meshset_t *> &b_sliced,
V2Set *shared_edges = NULL);
bool sliceAndClassify(
meshset_t *closed,
meshset_t *open,
std::list<std::pair<FaceClass, meshset_t *> > &result,
V2Set *shared_edges = NULL);
};
}
}

View File

@@ -1,435 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#include <carve/csg.hpp>
#include <carve/tag.hpp>
#include <carve/poly.hpp>
#include <carve/triangulator.hpp>
#include <deque>
namespace carve {
namespace csg {
namespace detail {
template<bool with_improvement>
class CarveTriangulator : public csg::CSG::Hook {
public:
CarveTriangulator() {
}
virtual ~CarveTriangulator() {
}
virtual void processOutputFace(std::vector<carve::mesh::MeshSet<3>::face_t *> &faces,
const carve::mesh::MeshSet<3>::face_t *orig,
bool flipped) {
std::vector<carve::mesh::MeshSet<3>::face_t *> out_faces;
size_t n_tris = 0;
for (size_t f = 0; f < faces.size(); ++f) {
CARVE_ASSERT(faces[f]->nVertices() >= 3);
n_tris += faces[f]->nVertices() - 2;
}
out_faces.reserve(n_tris);
for (size_t f = 0; f < faces.size(); ++f) {
carve::mesh::MeshSet<3>::face_t *face = faces[f];
if (face->nVertices() == 3) {
out_faces.push_back(face);
continue;
}
std::vector<triangulate::tri_idx> result;
std::vector<carve::mesh::MeshSet<3>::vertex_t *> vloop;
face->getVertices(vloop);
triangulate::triangulate(
carve::mesh::MeshSet<3>::face_t::projection_mapping(face->project),
vloop,
result);
if (with_improvement) {
triangulate::improve(
carve::mesh::MeshSet<3>::face_t::projection_mapping(face->project),
vloop,
carve::mesh::vertex_distance(),
result);
}
std::vector<carve::mesh::MeshSet<3>::vertex_t *> fv;
fv.resize(3);
for (size_t i = 0; i < result.size(); ++i) {
fv[0] = vloop[result[i].a];
fv[1] = vloop[result[i].b];
fv[2] = vloop[result[i].c];
out_faces.push_back(face->create(fv.begin(), fv.end(), false));
}
delete face;
}
std::swap(faces, out_faces);
}
};
}
typedef detail::CarveTriangulator<false> CarveTriangulator;
typedef detail::CarveTriangulator<true> CarveTriangulatorWithImprovement;
class CarveTriangulationImprover : public csg::CSG::Hook {
public:
CarveTriangulationImprover() {
}
virtual ~CarveTriangulationImprover() {
}
virtual void processOutputFace(std::vector<carve::mesh::MeshSet<3>::face_t *> &faces,
const carve::mesh::MeshSet<3>::face_t *orig,
bool flipped) {
if (faces.size() == 1) return;
// doing improvement as a separate hook is much messier than
// just incorporating it into the triangulation hook.
typedef std::map<carve::mesh::MeshSet<3>::vertex_t *, size_t> vert_map_t;
std::vector<carve::mesh::MeshSet<3>::face_t *> out_faces;
vert_map_t vert_map;
out_faces.reserve(faces.size());
carve::mesh::MeshSet<3>::face_t::projection_mapping projector(faces[0]->project);
std::vector<triangulate::tri_idx> result;
for (size_t f = 0; f < faces.size(); ++f) {
carve::mesh::MeshSet<3>::face_t *face = faces[f];
if (face->nVertices() != 3) {
out_faces.push_back(face);
} else {
triangulate::tri_idx tri;
for (carve::mesh::MeshSet<3>::face_t::edge_iter_t i = face->begin(); i != face->end(); ++i) {
size_t v = 0;
vert_map_t::iterator j = vert_map.find(i->vert);
if (j == vert_map.end()) {
v = vert_map.size();
vert_map[i->vert] = v;
} else {
v = (*j).second;
}
tri.v[i.idx()] = v;
}
result.push_back(tri);
delete face;
}
}
std::vector<carve::mesh::MeshSet<3>::vertex_t *> verts;
verts.resize(vert_map.size());
for (vert_map_t::iterator i = vert_map.begin(); i != vert_map.end(); ++i) {
verts[(*i).second] = (*i).first;
}
triangulate::improve(projector, verts, carve::mesh::vertex_distance(), result);
std::vector<carve::mesh::MeshSet<3>::vertex_t *> fv;
fv.resize(3);
for (size_t i = 0; i < result.size(); ++i) {
fv[0] = verts[result[i].a];
fv[1] = verts[result[i].b];
fv[2] = verts[result[i].c];
out_faces.push_back(orig->create(fv.begin(), fv.end(), false));
}
std::swap(faces, out_faces);
}
};
class CarveTriangulationQuadMerger : public csg::CSG::Hook {
// this code is incomplete.
typedef std::map<V2, F2> edge_map_t;
public:
CarveTriangulationQuadMerger() {
}
virtual ~CarveTriangulationQuadMerger() {
}
double scoreQuad(edge_map_t::iterator i, edge_map_t &edge_map) {
if (!(*i).second.first || !(*i).second.second) return -1;
return -1;
}
carve::mesh::MeshSet<3>::face_t *mergeQuad(edge_map_t::iterator i, edge_map_t &edge_map) {
return NULL;
}
void recordEdge(carve::mesh::MeshSet<3>::vertex_t *v1,
carve::mesh::MeshSet<3>::vertex_t *v2,
carve::mesh::MeshSet<3>::face_t *f,
edge_map_t &edge_map) {
if (v1 < v2) {
edge_map[V2(v1, v2)].first = f;
} else {
edge_map[V2(v2, v1)].second = f;
}
}
virtual void processOutputFace(std::vector<carve::mesh::MeshSet<3>::face_t *> &faces,
const carve::mesh::MeshSet<3>::face_t *orig,
bool flipped) {
if (faces.size() == 1) return;
std::vector<carve::mesh::MeshSet<3>::face_t *> out_faces;
edge_map_t edge_map;
out_faces.reserve(faces.size());
poly::p2_adapt_project<3> projector(faces[0]->project);
for (size_t f = 0; f < faces.size(); ++f) {
carve::mesh::MeshSet<3>::face_t *face = faces[f];
if (face->nVertices() != 3) {
out_faces.push_back(face);
} else {
carve::mesh::MeshSet<3>::face_t::vertex_t *v1, *v2, *v3;
v1 = face->edge->vert;
v2 = face->edge->next->vert;
v3 = face->edge->next->next->vert;
recordEdge(v1, v2, face, edge_map);
recordEdge(v2, v3, face, edge_map);
recordEdge(v3, v1, face, edge_map);
}
}
for (edge_map_t::iterator i = edge_map.begin(); i != edge_map.end();) {
if ((*i).second.first && (*i).second.second) {
++i;
} else {
edge_map.erase(i++);
}
}
while (edge_map.size()) {
edge_map_t::iterator i = edge_map.begin();
edge_map_t::iterator best = i;
double best_score = scoreQuad(i, edge_map);
for (++i; i != edge_map.end(); ++i) {
double score = scoreQuad(i, edge_map);
if (score > best_score) best = i;
}
if (best_score < 0) break;
out_faces.push_back(mergeQuad(best, edge_map));
}
if (edge_map.size()) {
tagable::tag_begin();
for (edge_map_t::iterator i = edge_map.begin(); i != edge_map.end(); ++i) {
carve::mesh::MeshSet<3>::face_t *a = const_cast<carve::mesh::MeshSet<3>::face_t *>((*i).second.first);
carve::mesh::MeshSet<3>::face_t *b = const_cast<carve::mesh::MeshSet<3>::face_t *>((*i).second.first);
if (a && a->tag_once()) out_faces.push_back(a);
if (b && b->tag_once()) out_faces.push_back(b);
}
}
std::swap(faces, out_faces);
}
};
class CarveHoleResolver : public csg::CSG::Hook {
public:
CarveHoleResolver() {
}
virtual ~CarveHoleResolver() {
}
bool findRepeatedEdges(const std::vector<carve::mesh::MeshSet<3>::vertex_t *> &vertices,
std::list<std::pair<size_t, size_t> > &edge_pos) {
std::map<V2, size_t> edges;
for (size_t i = 0; i < vertices.size() - 1; ++i) {
edges[std::make_pair(vertices[i], vertices[i+1])] = i;
}
edges[std::make_pair(vertices[vertices.size()-1], vertices[0])] = vertices.size() - 1;
for (std::map<V2, size_t>::iterator i = edges.begin(); i != edges.end(); ++i) {
V2 rev = V2((*i).first.second, (*i).first.first);
std::map<V2, size_t>::iterator j = edges.find(rev);
if (j != edges.end()) {
edge_pos.push_back(std::make_pair((*i).second, (*j).second));
}
}
return edge_pos.size() > 0;
}
void flood(size_t t1,
size_t t2,
size_t old_grp,
size_t new_grp_1,
size_t new_grp_2,
std::vector<size_t> &grp,
const std::vector<triangulate::tri_idx> &tris,
const std::map<std::pair<size_t, size_t>, size_t> &tri_edge) {
grp[t1] = new_grp_1;
grp[t2] = new_grp_2;
std::deque<size_t> to_visit;
to_visit.push_back(t1);
to_visit.push_back(t2);
std::vector<std::pair<size_t, size_t> > rev;
rev.resize(3);
while (to_visit.size()) {
size_t curr = to_visit.front();
to_visit.pop_front();
triangulate::tri_idx ct = tris[curr];
rev[0] = std::make_pair(ct.b, ct.a);
rev[1] = std::make_pair(ct.c, ct.b);
rev[2] = std::make_pair(ct.a, ct.c);
for (size_t i = 0; i < 3; ++i) {
std::map<std::pair<size_t, size_t>, size_t>::const_iterator adj = tri_edge.find(rev[i]);
if (adj == tri_edge.end()) continue;
size_t next = (*adj).second;
if (grp[next] != old_grp) continue;
grp[next] = grp[curr];
to_visit.push_back(next);
}
}
}
void findPerimeter(const std::vector<triangulate::tri_idx> &tris,
const std::vector<carve::mesh::MeshSet<3>::vertex_t *> &verts,
std::vector<carve::mesh::MeshSet<3>::vertex_t *> &out) {
std::map<std::pair<size_t, size_t>, size_t> edges;
for (size_t i = 0; i < tris.size(); ++i) {
edges[std::make_pair(tris[i].a, tris[i].b)] = i;
edges[std::make_pair(tris[i].b, tris[i].c)] = i;
edges[std::make_pair(tris[i].c, tris[i].a)] = i;
}
std::map<size_t, size_t> unpaired;
for (std::map<std::pair<size_t, size_t>, size_t>::iterator i = edges.begin(); i != edges.end(); ++i) {
if (edges.find(std::make_pair((*i).first.second, (*i).first.first)) == edges.end()) {
CARVE_ASSERT(unpaired.find((*i).first.first) == unpaired.end());
unpaired[(*i).first.first] = (*i).first.second;
}
}
out.clear();
out.reserve(unpaired.size());
size_t start = (*unpaired.begin()).first;
size_t vert = start;
do {
out.push_back(verts[vert]);
CARVE_ASSERT(unpaired.find(vert) != unpaired.end());
vert = unpaired[vert];
} while (vert != start);
}
virtual void processOutputFace(std::vector<carve::mesh::MeshSet<3>::face_t *> &faces,
const carve::mesh::MeshSet<3>::face_t *orig,
bool flipped) {
std::vector<carve::mesh::MeshSet<3>::face_t *> out_faces;
for (size_t f = 0; f < faces.size(); ++f) {
carve::mesh::MeshSet<3>::face_t *face = faces[f];
if (face->nVertices() == 3) {
out_faces.push_back(face);
continue;
}
std::vector<carve::mesh::MeshSet<3>::vertex_t *> vloop;
face->getVertices(vloop);
std::list<std::pair<size_t, size_t> > rep_edges;
if (!findRepeatedEdges(vloop, rep_edges)) {
out_faces.push_back(face);
continue;
}
std::vector<triangulate::tri_idx> result;
triangulate::triangulate(
carve::mesh::MeshSet<3>::face_t::projection_mapping(face->project),
vloop,
result);
std::map<std::pair<size_t, size_t>, size_t> tri_edge;
for (size_t i = 0; i < result.size(); ++i) {
tri_edge[std::make_pair(result[i].a, result[i].b)] = i;
tri_edge[std::make_pair(result[i].b, result[i].c)] = i;
tri_edge[std::make_pair(result[i].c, result[i].a)] = i;
}
std::vector<size_t> grp;
grp.resize(result.size(), 0);
size_t grp_max = 0;
while (rep_edges.size()) {
std::pair<size_t, size_t> e1, e2;
e1.first = rep_edges.front().first;
e1.second = (e1.first + 1) % vloop.size();
e2.first = rep_edges.front().second;
e2.second = (e2.first + 1) % vloop.size();
rep_edges.pop_front();
CARVE_ASSERT(tri_edge.find(e1) != tri_edge.end());
size_t t1 = tri_edge[e1];
CARVE_ASSERT(tri_edge.find(e2) != tri_edge.end());
size_t t2 = tri_edge[e2];
if (grp[t1] != grp[t2]) {
continue;
}
size_t t1g = ++grp_max;
size_t t2g = ++grp_max;
flood(t1, t2, grp[t1], t1g, t2g, grp, result, tri_edge);
}
std::set<size_t> groups;
std::copy(grp.begin(), grp.end(), std::inserter(groups, groups.begin()));
// now construct perimeters for each group.
std::vector<triangulate::tri_idx> grp_tris;
grp_tris.reserve(result.size());
for (std::set<size_t>::iterator i = groups.begin(); i != groups.end(); ++i) {
size_t grp_id = *i;
grp_tris.clear();
for (size_t j = 0; j < grp.size(); ++j) {
if (grp[j] == grp_id) {
grp_tris.push_back(result[j]);
}
}
std::vector<carve::mesh::MeshSet<3>::vertex_t *> grp_perim;
findPerimeter(grp_tris, vloop, grp_perim);
out_faces.push_back(face->create(grp_perim.begin(), grp_perim.end(), false));
}
delete face;
}
std::swap(faces, out_faces);
}
};
}
}

View File

@@ -1,97 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/vector.hpp>
#include <carve/geom3d.hpp>
#include <carve/csg.hpp>
#include <iomanip>
template<typename MAP>
void map_histogram(std::ostream &out, const MAP &map) {
std::vector<int> hist;
for (typename MAP::const_iterator i = map.begin(); i != map.end(); ++i) {
size_t n = (*i).second.size();
if (hist.size() <= n) {
hist.resize(n + 1);
}
hist[n]++;
}
int total = (int)map.size();
std::string bar(50, '*');
for (size_t i = 0; i < hist.size(); i++) {
if (hist[i] > 0) {
out << std::setw(5) << i << " : " << std::setw(5) << hist[i] << " " << bar.substr((size_t)(50 - hist[i] * 50 / total)) << std::endl;
}
}
}
namespace carve {
namespace csg {
class IntersectDebugHooks {
public:
virtual void drawIntersections(const VertexIntersections & /* vint */) {
}
virtual void drawPoint(const carve::mesh::MeshSet<3>::vertex_t * /* v */,
float /* r */,
float /* g */,
float /* b */,
float /* a */,
float /* rad */) {
}
virtual void drawEdge(const carve::mesh::MeshSet<3>::vertex_t * /* v1 */,
const carve::mesh::MeshSet<3>::vertex_t * /* v2 */,
float /* rA */, float /* gA */, float /* bA */, float /* aA */,
float /* rB */, float /* gB */, float /* bB */, float /* aB */,
float /* thickness */ = 1.0) {
}
virtual void drawFaceLoopWireframe(const std::vector<carve::mesh::MeshSet<3>::vertex_t *> & /* face_loop */,
const carve::mesh::MeshSet<3>::vertex_t & /* normal */,
float /* r */, float /* g */, float /* b */, float /* a */,
bool /* inset */ = true) {
}
virtual void drawFaceLoop(const std::vector<carve::mesh::MeshSet<3>::vertex_t *> & /* face_loop */,
const carve::mesh::MeshSet<3>::vertex_t & /* normal */,
float /* r */, float /* g */, float /* b */, float /* a */,
bool /* offset */ = true,
bool /* lit */ = true) {
}
virtual void drawFaceLoop2(const std::vector<carve::mesh::MeshSet<3>::vertex_t *> & /* face_loop */,
const carve::mesh::MeshSet<3>::vertex_t & /* normal */,
float /* rF */, float /* gF */, float /* bF */, float /* aF */,
float /* rB */, float /* gB */, float /* bB */, float /* aB */,
bool /* offset */ = true,
bool /* lit */ = true) {
}
virtual ~IntersectDebugHooks() {
}
};
IntersectDebugHooks *intersect_installDebugHooks(IntersectDebugHooks *hooks);
bool intersect_debugEnabled();
}
}

View File

@@ -1,134 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <vector>
namespace carve {
namespace djset {
class djset {
protected:
struct elem {
size_t parent, rank;
elem(size_t p, size_t r) : parent(p), rank(r) {}
elem() {}
};
std::vector<elem> set;
size_t n_sets;
public:
djset() : set(), n_sets(0) {
}
djset(size_t N) {
n_sets = N;
set.reserve(N);
for (size_t i = 0; i < N; ++i) {
set.push_back(elem(i,0));
}
}
void init(size_t N) {
if (N == set.size()) {
for (size_t i = 0; i < N; ++i) {
set[i] = elem(i,0);
}
n_sets = N;
} else {
djset temp(N);
std::swap(set, temp.set);
std::swap(n_sets, temp.n_sets);
}
}
size_t count() const {
return n_sets;
}
size_t find_set_head(size_t a) {
if (a == set[a].parent) return a;
size_t a_head = a;
while (set[a_head].parent != a_head) a_head = set[a_head].parent;
set[a].parent = a_head;
return a_head;
}
bool same_set(size_t a, size_t b) {
return find_set_head(a) == find_set_head(b);
}
void merge_sets(size_t a, size_t b) {
a = find_set_head(a);
b = find_set_head(b);
if (a != b) {
n_sets--;
if (set[a].rank < set[b].rank) {
set[a].parent = b;
} else if (set[b].rank < set[a].rank) {
set[b].parent = a;
} else {
set[a].rank++;
set[b].parent = a;
}
}
}
void get_index_to_set(std::vector<size_t> &index_set, std::vector<size_t> &set_size) {
index_set.clear();
index_set.resize(set.size(), n_sets);
set_size.clear();
set_size.resize(n_sets, 0);
size_t c = 0;
for (size_t i = 0; i < set.size(); ++i) {
size_t s = find_set_head(i);
if (index_set[s] == n_sets) index_set[s] = c++;
index_set[i] = index_set[s];
set_size[index_set[s]]++;
}
}
template<typename in_iter_t, typename out_collection_t>
void collate(in_iter_t in, out_collection_t &out) {
std::vector<size_t> set_id(set.size(), n_sets);
out.clear();
out.resize(n_sets);
size_t c = 0;
for (size_t i = 0; i < set.size(); ++i) {
size_t s = find_set_head(i);
if (set_id[s] == n_sets) set_id[s] = c++;
s = set_id[s];
std::insert_iterator<typename out_collection_t::value_type> j(out[s], out[s].end());
*j = *in++;
}
}
};
}
}

View File

@@ -1,68 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/vector.hpp>
#include <carve/tag.hpp>
#include <vector>
#include <list>
namespace carve {
namespace poly {
struct Object;
template<unsigned ndim>
class Edge : public tagable {
public:
typedef Vertex<ndim> vertex_t;
typedef typename Vertex<ndim>::vector_t vector_t;
typedef Object obj_t;
const vertex_t *v1, *v2;
const obj_t *owner;
Edge(const vertex_t *_v1, const vertex_t *_v2, const obj_t *_owner) :
tagable(), v1(_v1), v2(_v2), owner(_owner) {
}
~Edge() {
}
};
struct hash_edge_ptr {
template<unsigned ndim>
size_t operator()(const Edge<ndim> * const &e) const {
return (size_t)e;
}
};
}
}

View File

@@ -1,23 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
namespace carve {
namespace poly {
}
}

View File

@@ -1,704 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <vector>
#include <numeric>
#include <algorithm>
namespace carve {
namespace exact {
class exact_t : public std::vector<double> {
typedef std::vector<double> super;
public:
exact_t() : super() {
}
exact_t(double v, size_t sz = 1) : super(sz, v) {
}
template<typename iter_t>
exact_t(iter_t a, iter_t b) : super(a, b) {
}
exact_t(double a, double b) : super() {
reserve(2);
push_back(a);
push_back(b);
}
exact_t(double a, double b, double c) : super() {
reserve(3);
push_back(a);
push_back(b);
push_back(c);
}
exact_t(double a, double b, double c, double d) : super() {
reserve(4);
push_back(a);
push_back(b);
push_back(c);
push_back(d);
}
exact_t(double a, double b, double c, double d, double e) : super() {
reserve(5);
push_back(a);
push_back(b);
push_back(c);
push_back(d);
push_back(e);
}
exact_t(double a, double b, double c, double d, double e, double f) : super() {
reserve(6);
push_back(a);
push_back(b);
push_back(c);
push_back(d);
push_back(e);
push_back(f);
}
exact_t(double a, double b, double c, double d, double e, double f, double g) : super() {
reserve(7);
push_back(a);
push_back(b);
push_back(c);
push_back(d);
push_back(e);
push_back(f);
push_back(g);
}
exact_t(double a, double b, double c, double d, double e, double f, double g, double h) : super() {
reserve(8);
push_back(a);
push_back(b);
push_back(c);
push_back(d);
push_back(e);
push_back(f);
push_back(g);
push_back(h);
}
void compress();
exact_t compressed() const {
exact_t result(*this);
result.compress();
return result;
}
operator double() const {
return std::accumulate(begin(), end(), 0.0);
}
void removeZeroes() {
erase(std::remove(begin(), end(), 0.0), end());
}
};
inline std::ostream &operator<<(std::ostream &out, const exact_t &p) {
out << '{';
out << p[0];
for (size_t i = 1; i < p.size(); ++i) out << ';' << p[i];
out << '}';
return out;
}
namespace detail {
const struct constants_t {
double splitter; /* = 2^ceiling(p / 2) + 1. Used to split floats in half. */
double epsilon; /* = 2^(-p). Used to estimate roundoff errors. */
/* A set of coefficients used to calculate maximum roundoff errors. */
double resulterrbound;
double ccwerrboundA, ccwerrboundB, ccwerrboundC;
double o3derrboundA, o3derrboundB, o3derrboundC;
double iccerrboundA, iccerrboundB, iccerrboundC;
double isperrboundA, isperrboundB, isperrboundC;
constants_t() {
double half;
double check, lastcheck;
int every_other;
every_other = 1;
half = 0.5;
epsilon = 1.0;
splitter = 1.0;
check = 1.0;
/* Repeatedly divide `epsilon' by two until it is too small to add to */
/* one without causing roundoff. (Also check if the sum is equal to */
/* the previous sum, for machines that round up instead of using exact */
/* rounding. Not that this library will work on such machines anyway. */
do {
lastcheck = check;
epsilon *= half;
if (every_other) {
splitter *= 2.0;
}
every_other = !every_other;
check = 1.0 + epsilon;
} while ((check != 1.0) && (check != lastcheck));
splitter += 1.0;
/* Error bounds for orientation and incircle tests. */
resulterrbound = (3.0 + 8.0 * epsilon) * epsilon;
ccwerrboundA = (3.0 + 16.0 * epsilon) * epsilon;
ccwerrboundB = (2.0 + 12.0 * epsilon) * epsilon;
ccwerrboundC = (9.0 + 64.0 * epsilon) * epsilon * epsilon;
o3derrboundA = (7.0 + 56.0 * epsilon) * epsilon;
o3derrboundB = (3.0 + 28.0 * epsilon) * epsilon;
o3derrboundC = (26.0 + 288.0 * epsilon) * epsilon * epsilon;
iccerrboundA = (10.0 + 96.0 * epsilon) * epsilon;
iccerrboundB = (4.0 + 48.0 * epsilon) * epsilon;
iccerrboundC = (44.0 + 576.0 * epsilon) * epsilon * epsilon;
isperrboundA = (16.0 + 224.0 * epsilon) * epsilon;
isperrboundB = (5.0 + 72.0 * epsilon) * epsilon;
isperrboundC = (71.0 + 1408.0 * epsilon) * epsilon * epsilon;
}
} constants;
template<unsigned U, unsigned V>
struct op {
enum {
Vlo = V / 2,
Vhi = V - Vlo
};
static inline void add(const double *a, const double *b, double *r) {
double t[U + Vlo];
op<U, Vlo>::add(a, b, t);
for (size_t i = 0; i < Vlo; ++i) r[i] = t[i];
op<U, Vhi>::add(t + Vlo, b + Vlo, r + Vlo);
}
static inline void sub(const double *a, const double *b, double *r) {
double t[U + Vlo];
op<U, Vlo>::sub(a, b, t);
for (size_t i = 0; i < Vlo; ++i) r[i] = t[i];
op<U, Vhi>::sub(t + Vlo, b + Vlo, r + Vlo);
}
};
template<unsigned U>
struct op<U, 1> {
enum {
Ulo = U / 2,
Uhi = U - Ulo
};
static void add(const double *a, const double *b, double *r) {
double t[Ulo + 1];
op<Ulo, 1>::add(a, b, t);
for (size_t i = 0; i < Ulo; ++i) r[i] = t[i];
op<Uhi, 1>::add(a + Ulo, t + Ulo, r + Ulo);
}
static void sub(const double *a, const double *b, double *r) {
double t[Ulo + 1];
op<Ulo, 1>::sub(a, b, t);
for (size_t i = 0; i < Ulo; ++i) r[i] = t[i];
op<Uhi, 1>::add(a + Ulo, t + Ulo, r + Ulo);
}
};
template<>
struct op<1, 1> {
static void add_fast(const double *a, const double *b, double *r) {
assert(fabs(a[0]) >= fabs(b[0]));
volatile double sum = a[0] + b[0];
volatile double bvirt = sum - a[0];
r[0] = b[0] - bvirt;
r[1] = sum;
}
static void sub_fast(const double *a, const double *b, double *r) {
assert(fabs(a[0]) >= fabs(b[0]));
volatile double diff = a[0] - b[0];
volatile double bvirt = a[0] - diff;
r[0] = bvirt - b[0];
r[1] = diff;
}
static void add(const double *a, const double *b, double *r) {
volatile double sum = a[0] + b[0];
volatile double bvirt = sum - a[0];
double avirt = sum - bvirt;
double bround = b[0] - bvirt;
double around = a[0] - avirt;
r[0] = around + bround;
r[1] = sum;
}
static void sub(const double *a, const double *b, double *r) {
volatile double diff = a[0] - b[0];
volatile double bvirt = a[0] - diff;
double avirt = diff + bvirt;
double bround = bvirt - b[0];
double around = a[0] - avirt;
r[0] = around + bround;
r[1] = diff;
}
};
template<unsigned U, unsigned V>
static exact_t add(const double *a, const double *b) {
exact_t result;
result.resize(U + V);
op<U,V>::add(a, b, &result[0]);
return result;
}
template<unsigned U, unsigned V>
static exact_t sub(const double *a, const double *b) {
exact_t result;
result.resize(U + V);
op<U,V>::sub(a, b, &result[0]);
return result;
}
template<unsigned U, unsigned V>
static exact_t add(const exact_t &a, const exact_t &b) {
assert(a.size() == U);
assert(b.size() == V);
exact_t result;
result.resize(U + V);
std::fill(result.begin(), result.end(), std::numeric_limits<double>::quiet_NaN());
op<U,V>::add(&a[0], &b[0], &result[0]);
return result;
}
template<unsigned U, unsigned V>
static exact_t add(const exact_t &a, const double *b) {
assert(a.size() == U);
exact_t result;
result.resize(U + V);
std::fill(result.begin(), result.end(), std::numeric_limits<double>::quiet_NaN());
op<U,V>::add(&a[0], b, &result[0]);
return result;
}
template<unsigned U, unsigned V>
static exact_t sub(const exact_t &a, const exact_t &b) {
assert(a.size() == U);
assert(b.size() == V);
exact_t result;
result.resize(U + V);
std::fill(result.begin(), result.end(), std::numeric_limits<double>::quiet_NaN());
op<U,V>::sub(&a[0], &b[0], &result[0]);
return result;
}
template<unsigned U, unsigned V>
static exact_t sub(const exact_t &a, const double *b) {
assert(a.size() == U);
exact_t result;
result.resize(U + V);
std::fill(result.begin(), result.end(), std::numeric_limits<double>::quiet_NaN());
op<U,V>::sub(&a[0], &b[0], &result[0]);
return result;
}
static inline void split(const double a, double *r) {
volatile double c = constants.splitter * a;
volatile double abig = c - a;
r[1] = c - abig;
r[0] = a - r[1];
}
static inline void prod_1_1(const double *a, const double *b, double *r) {
r[1] = a[0] * b[0];
double a_sp[2]; split(a[0], a_sp);
double b_sp[2]; split(b[0], b_sp);
double err1 = r[1] - a_sp[1] * b_sp[1];
double err2 = err1 - a_sp[0] * b_sp[1];
double err3 = err2 - a_sp[1] * b_sp[0];
r[0] = a_sp[0] * b_sp[0] - err3;
}
static inline void prod_1_1s(const double *a, const double *b, const double *b_sp, double *r) {
r[1] = a[0] * b[0];
double a_sp[2]; split(a[0], a_sp);
double err1 = r[1] - a_sp[1] * b_sp[1];
double err2 = err1 - a_sp[0] * b_sp[1];
double err3 = err2 - a_sp[1] * b_sp[0];
r[0] = a_sp[0] * b_sp[0] - err3;
}
static inline void prod_1s_1s(const double *a, const double *a_sp, const double *b, const double *b_sp, double *r) {
r[1] = a[0] * b[0];
double err1 = r[1] - a_sp[1] * b_sp[1];
double err2 = err1 - a_sp[0] * b_sp[1];
double err3 = err2 - a_sp[1] * b_sp[0];
r[0] = a_sp[0] * b_sp[0] - err3;
}
static inline void prod_2_1(const double *a, const double *b, double *r) {
double b_sp[2]; split(b[0], b_sp);
double t1[2]; prod_1_1s(a+0, b, b_sp, t1);
r[0] = t1[0];
double t2[2]; prod_1_1s(a+1, b, b_sp, t2);
double t3[2]; op<1,1>::add(t1+1, t2, t3);
r[1] = t3[0];
double t4[2]; op<1,1>::add_fast(t2+1, t3+1, r + 2);
}
static inline void prod_1_2(const double *a, const double *b, double *r) {
prod_2_1(b, a, r);
}
static inline void prod_4_1(const double *a, const double *b, double *r) {
double b_sp[2]; split(b[0], b_sp);
double t1[2]; prod_1_1s(a+0, b, b_sp, t1);
r[0] = t1[0];
double t2[2]; prod_1_1s(a+1, b, b_sp, t2);
double t3[2]; op<1,1>::add(t1+1, t2, t3);
r[1] = t3[0];
double t4[2]; op<1,1>::add_fast(t2+1, t3+1, t4);
r[2] = t4[0];
double t5[2]; prod_1_1s(a+2, b, b_sp, t5);
double t6[2]; op<1,1>::add(t4+1, t5, t6);
r[3] = t6[0];
double t7[2]; op<1,1>::add_fast(t5+1, t6+1, t7);
r[4] = t7[0];
double t8[2]; prod_1_1s(a+3, b, b_sp, t8);
double t9[2]; op<1,1>::add(t7+1, t8, t9);
r[5] = t9[0];
op<1,1>::add_fast(t8+1, t9+1, r + 6);
}
static inline void prod_1_4(const double *a, const double *b, double *r) {
prod_4_1(b, a, r);
}
static inline void prod_2_2(const double *a, const double *b, double *r) {
double a1_sp[2]; split(a[1], a1_sp);
double a0_sp[2]; split(a[0], a0_sp);
double b1_sp[2]; split(b[1], b1_sp);
double b0_sp[2]; split(b[0], b0_sp);
double t1[2]; prod_1s_1s(a+0, a0_sp, b+0, b0_sp, t1);
r[0] = t1[0];
double t2[2]; prod_1s_1s(a+1, a1_sp, b+0, b0_sp, t2);
double t3[2]; op<1,1>::add(t1+1, t2, t3);
double t4[2]; op<1,1>::add_fast(t2+1, t3+1, t4);
double t5[2]; prod_1s_1s(a+0, a0_sp, b+1, b1_sp, t5);
double t6[2]; op<1,1>::add(t3, t5, t6);
r[1] = t6[0];
double t7[2]; op<1,1>::add(t4, t6+1, t7);
double t8[2]; op<1,1>::add(t4+1, t7+1, t8);
double t9[2]; prod_1s_1s(a+1, a1_sp, b+1, b1_sp, t9);
double t10[2]; op<1,1>::add(t5+1, t9, t10);
double t11[2]; op<1,1>::add(t7, t10, t11);
r[2] = t11[0];
double t12[2]; op<1,1>::add(t8, t11+1, t12);
double t13[2]; op<1,1>::add(t8+1, t12+1, t13);
double t14[2]; op<1,1>::add(t9+1, t10+1, t14);
double t15[2]; op<1,1>::add(t12, t14, t15);
r[3] = t15[0];
double t16[2]; op<1,1>::add(t13, t15+1, t16);
double t17[2]; op<1,1>::add(t13+1, t16+1, t17);
double t18[2]; op<1,1>::add(t16, t14+1, t18);
r[4] = t18[0];
double t19[2]; op<1,1>::add(t17, t18+1, t19);
r[5] = t19[0];
double t20[2]; op<1,1>::add(t17+1, t19+1, t20);
r[6] = t20[0];
r[7] = t20[1];
}
static inline void square(const double a, double *r) {
r[1] = a * a;
double a_sp[2]; split(a, a_sp);
double err1 = r[1] - (a_sp[1] * a_sp[1]);
double err3 = err1 - ((a_sp[1] + a_sp[1]) * a_sp[0]);
r[0] = a_sp[0] * a_sp[0] - err3;
}
static inline void square_2(const double *a, double *r) {
double t1[2]; square(a[0], t1);
r[0] = t1[0];
double t2 = a[0] + a[0];
double t3[2]; prod_1_1(a+1, &t2, t3);
double t4[3]; op<2,1>::add(t3, t1 + 1, t4);
r[1] = t4[0];
double t5[2]; square(a[1], t5);
double t6[4]; op<2,2>::add(t5, t4 + 1, r + 2);
}
}
void exact_t::compress() {
double sum[2];
int j = size() - 1;
double Q = (*this)[j];
for (int i = (int)size()-2; i >= 0; --i) {
detail::op<1,1>::add_fast(&Q, &(*this)[i], sum);
if (sum[0] != 0) {
(*this)[j--] = sum[1];
Q = sum[0];
} else {
Q = sum[1];
}
}
int j2 = 0;
for (int i = j + 1; i < (int)size(); ++i) {
detail::op<1,1>::add_fast(&(*this)[i], &Q, sum);
if (sum[0] != 0) {
(*this)[j2++] = sum[0];
}
Q = sum[1];
}
(*this)[j2++] = Q;
erase(begin() + j2, end());
}
template<typename iter_t>
void negate(iter_t begin, iter_t end) {
while (begin != end) { *begin = -*begin; ++begin; }
}
void negate(exact_t &e) {
negate(&e[0], &e[e.size()]);
}
template<typename iter_t>
void scale_zeroelim(iter_t ebegin,
iter_t eend,
double b,
exact_t &h) {
double Q;
h.clear();
double b_sp[2]; detail::split(b, b_sp);
double prod[2], sum[2];
detail::prod_1_1s((double *)ebegin++, &b, b_sp, prod);
Q = prod[1];
if (prod[0] != 0.0) {
h.push_back(prod[0]);
}
while (ebegin != eend) {
double enow = *ebegin++;
detail::prod_1_1s(&enow, &b, b_sp, prod);
detail::op<1,1>::add(&Q, prod, sum);
if (sum[0] != 0) {
h.push_back(sum[0]);
}
detail::op<1,1>::add_fast(prod+1, sum+1, sum);
Q = sum[1];
if (sum[0] != 0) {
h.push_back(sum[0]);
}
}
if ((Q != 0.0) || (h.size() == 0)) {
h.push_back(Q);
}
}
void scale_zeroelim(const exact_t &e,
double b,
exact_t &h) {
scale_zeroelim(&e[0], &e[e.size()], b, h);
}
template<typename iter_t>
void sum_zeroelim(iter_t ebegin,
iter_t eend,
iter_t fbegin,
iter_t fend,
exact_t &h) {
double Q;
double enow, fnow;
double sum[2];
enow = *ebegin;
fnow = *fbegin;
h.clear();
if ((fnow > enow) == (fnow > -enow)) {
Q = enow;
enow = *++ebegin;
} else {
Q = fnow;
fnow = *++fbegin;
}
if (ebegin != eend && fbegin != fend) {
if ((fnow > enow) == (fnow > -enow)) {
detail::op<1,1>::add_fast(&enow, &Q, sum);
enow = *++ebegin;
} else {
detail::op<1,1>::add_fast(&fnow, &Q, sum);
fnow = *++fbegin;
}
Q = sum[1];
if (sum[0] != 0.0) {
h.push_back(sum[0]);
}
while (ebegin != eend && fbegin != fend) {
if ((fnow > enow) == (fnow > -enow)) {
detail::op<1,1>::add(&Q, &enow, sum);
enow = *++ebegin;
} else {
detail::op<1,1>::add(&Q, &fnow, sum);
fnow = *++fbegin;
}
Q = sum[1];
if (sum[0] != 0.0) {
h.push_back(sum[0]);
}
}
}
while (ebegin != eend) {
detail::op<1,1>::add(&Q, &enow, sum);
enow = *++ebegin;
Q = sum[1];
if (sum[0] != 0.0) {
h.push_back(sum[0]);
}
}
while (fbegin != fend) {
detail::op<1,1>::add(&Q, &fnow, sum);
fnow = *++fbegin;
Q = sum[1];
if (sum[0] != 0.0) {
h.push_back(sum[0]);
}
}
if (Q != 0.0 || !h.size()) {
h.push_back(Q);
}
}
void sum_zeroelim(const exact_t &e,
const exact_t &f,
exact_t &h) {
sum_zeroelim(&e[0], &e[e.size()], &f[0], &f[f.size()], h);
}
void sum_zeroelim(const double *ebegin,
const double *eend,
const exact_t &f,
exact_t &h) {
sum_zeroelim(ebegin, eend, &f[0], &f[f.size()], h);
}
void sum_zeroelim(const exact_t &e,
const double *fbegin,
const double *fend,
exact_t &h) {
sum_zeroelim(&e[0], &e[e.size()], fbegin, fend, h);
}
exact_t operator+(const exact_t &a, const exact_t &b) {
exact_t r;
sum_zeroelim(a, b, r);
return r;
}
void diffprod(const double a, const double b, const double c, const double d, double *r) {
// return ab - cd;
double ab[2], cd[2];
detail::prod_1_1(&a, &b, ab);
detail::prod_1_1(&c, &d, cd);
detail::op<2,2>::sub(ab, cd, r);
}
double orient3dexact(const double *pa,
const double *pb,
const double *pc,
const double *pd) {
using namespace detail;
double ab[4]; diffprod(pa[0], pb[1], pb[0], pa[1], ab);
double bc[4]; diffprod(pb[0], pc[1], pc[0], pb[1], bc);
double cd[4]; diffprod(pc[0], pd[1], pd[0], pc[1], cd);
double da[4]; diffprod(pd[0], pa[1], pa[0], pd[1], da);
double ac[4]; diffprod(pa[0], pc[1], pc[0], pa[1], ac);
double bd[4]; diffprod(pb[0], pd[1], pd[0], pb[1], bd);
exact_t temp;
exact_t cda, dab, abc, bcd;
exact_t adet, bdet, cdet, ddet, abdet, cddet, det;
sum_zeroelim(cd, cd + 4, da, da + 4, temp);
sum_zeroelim(temp, ac, ac + 4, cda);
sum_zeroelim(da, da + 4, ab, ab + 4, temp);
sum_zeroelim(temp, bd, bd + 4, dab);
negate(bd, bd + 4);
negate(ac, bd + 4);
sum_zeroelim(ab, ab + 4, bc, bc + 4, temp);
sum_zeroelim(temp, ac, ac + 4, abc);
sum_zeroelim(bc, bc + 4, cd, cd + 4, temp);
sum_zeroelim(temp, bd, bd + 4, bcd);
scale_zeroelim(bcd, +pa[2], adet);
scale_zeroelim(cda, -pb[2], bdet);
scale_zeroelim(dab, +pc[2], cdet);
scale_zeroelim(abc, -pd[2], ddet);
sum_zeroelim(adet, bdet, abdet);
sum_zeroelim(cdet, ddet, cddet);
sum_zeroelim(abdet, cddet, det);
return det[det.size() - 1];
}
}
}

View File

@@ -1,208 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom2d.hpp>
#include <carve/vector.hpp>
#include <carve/matrix.hpp>
#include <carve/geom3d.hpp>
#include <carve/aabb.hpp>
#include <carve/tag.hpp>
#include <vector>
#include <list>
#include <map>
namespace carve {
namespace poly {
struct Object;
template<unsigned ndim>
class Edge;
template<unsigned ndim>
struct p2_adapt_project {
typedef carve::geom2d::P2 (*proj_t)(const carve::geom::vector<ndim> &);
proj_t proj;
p2_adapt_project(proj_t _proj) : proj(_proj) { }
carve::geom2d::P2 operator()(const carve::geom::vector<ndim> &v) const { return proj(v); }
carve::geom2d::P2 operator()(const carve::geom::vector<ndim> *v) const { return proj(*v); }
carve::geom2d::P2 operator()(const Vertex<ndim> &v) const { return proj(v.v); }
carve::geom2d::P2 operator()(const Vertex<ndim> *v) const { return proj(v->v); }
};
template<unsigned ndim>
class Face : public tagable {
public:
typedef Vertex<ndim> vertex_t;
typedef typename Vertex<ndim>::vector_t vector_t;
typedef Edge<ndim> edge_t;
typedef Object obj_t;
typedef carve::geom::aabb<ndim> aabb_t;
typedef carve::geom::plane<ndim> plane_t;
typedef carve::geom2d::P2 (*project_t)(const vector_t &);
typedef vector_t (*unproject_t)(const carve::geom2d::P2 &, const plane_t &);
protected:
std::vector<const vertex_t *> vertices; // pointer into polyhedron.vertices
std::vector<const edge_t *> edges; // pointer into polyhedron.edges
project_t getProjector(bool positive_facing, int axis);
unproject_t getUnprojector(bool positive_facing, int axis);
public:
typedef typename std::vector<const vertex_t *>::iterator vertex_iter_t;
typedef typename std::vector<const vertex_t *>::const_iterator const_vertex_iter_t;
typedef typename std::vector<const edge_t *>::iterator edge_iter_t;
typedef typename std::vector<const edge_t *>::const_iterator const_edge_iter_t;
obj_t *owner;
aabb_t aabb;
plane_t plane_eqn;
int manifold_id;
int group_id;
project_t project;
unproject_t unproject;
Face(const std::vector<const vertex_t *> &_vertices, bool delay_recalc = false);
Face(const vertex_t *v1, const vertex_t *v2, const vertex_t *v3, bool delay_recalc = false);
Face(const vertex_t *v1, const vertex_t *v2, const vertex_t *v3, const vertex_t *v4, bool delay_recalc = false);
template <typename iter_t>
Face(const Face *base, iter_t vbegin, iter_t vend, bool flipped) {
init(base, vbegin, vend, flipped);
}
Face(const Face *base, const std::vector<const vertex_t *> &_vertices, bool flipped) {
init(base, _vertices, flipped);
}
Face() {}
~Face() {}
bool recalc();
template<typename iter_t>
Face *init(const Face *base, iter_t vbegin, iter_t vend, bool flipped);
Face *init(const Face *base, const std::vector<const vertex_t *> &_vertices, bool flipped);
template<typename iter_t>
Face *create(iter_t vbegin, iter_t vend, bool flipped) const;
Face *create(const std::vector<const vertex_t *> &_vertices, bool flipped) const;
Face *clone(bool flipped = false) const;
void invert();
void getVertexLoop(std::vector<const vertex_t *> &loop) const;
const vertex_t *&vertex(size_t idx);
const vertex_t *vertex(size_t idx) const;
size_t nVertices() const;
vertex_iter_t vbegin() { return vertices.begin(); }
vertex_iter_t vend() { return vertices.end(); }
const_vertex_iter_t vbegin() const { return vertices.begin(); }
const_vertex_iter_t vend() const { return vertices.end(); }
std::vector<carve::geom::vector<2> > projectedVertices() const;
const edge_t *&edge(size_t idx);
const edge_t *edge(size_t idx) const;
size_t nEdges() const;
edge_iter_t ebegin() { return edges.begin(); }
edge_iter_t eend() { return edges.end(); }
const_edge_iter_t ebegin() const { return edges.begin(); }
const_edge_iter_t eend() const { return edges.end(); }
bool containsPoint(const vector_t &p) const;
bool containsPointInProjection(const vector_t &p) const;
bool simpleLineSegmentIntersection(const carve::geom::linesegment<ndim> &line,
vector_t &intersection) const;
IntersectionClass lineSegmentIntersection(const carve::geom::linesegment<ndim> &line,
vector_t &intersection) const;
vector_t centroid() const;
p2_adapt_project<ndim> projector() const {
return p2_adapt_project<ndim>(project);
}
void swap(Face<ndim> &other);
};
struct hash_face_ptr {
template<unsigned ndim>
size_t operator()(const Face<ndim> * const &f) const {
return (size_t)f;
}
};
namespace face {
template<unsigned ndim>
static inline carve::geom2d::P2 project(const Face<ndim> *f, const typename Face<ndim>::vector_t &v) {
return f->project(v);
}
template<unsigned ndim>
static inline carve::geom2d::P2 project(const Face<ndim> &f, const typename Face<ndim>::vector_t &v) {
return f.project(v);
}
template<unsigned ndim>
static inline typename Face<ndim>::vector_t unproject(const Face<ndim> *f, const carve::geom2d::P2 &p) {
return f->unproject(p, f->plane_eqn);
}
template<unsigned ndim>
static inline typename Face<ndim>::vector_t unproject(const Face<ndim> &f, const carve::geom2d::P2 &p) {
return f.unproject(p, f.plane_eqn);
}
}
}
}

View File

@@ -1,142 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
namespace std {
template<unsigned ndim>
inline void swap(carve::poly::Face<ndim> &a, carve::poly::Face<ndim> &b) {
a.swap(b);
}
}
namespace carve {
namespace poly {
template<unsigned ndim>
void Face<ndim>::swap(Face<ndim> &other) {
std::swap(vertices, other.vertices);
std::swap(edges, other.edges);
std::swap(owner, other.owner);
std::swap(aabb, other.aabb);
std::swap(plane_eqn, other.plane_eqn);
std::swap(manifold_id, other.manifold_id);
std::swap(group_id, other.group_id);
std::swap(project, other.project);
std::swap(unproject, other.unproject);
}
template<unsigned ndim>
template<typename iter_t>
Face<ndim> *Face<ndim>::init(const Face<ndim> *base, iter_t vbegin, iter_t vend, bool flipped) {
CARVE_ASSERT(vbegin < vend);
vertices.reserve((size_t)std::distance(vbegin, vend));
if (flipped) {
std::reverse_copy(vbegin, vend, std::back_inserter(vertices));
plane_eqn = -base->plane_eqn;
} else {
std::copy(vbegin, vend, std::back_inserter(vertices));
plane_eqn = base->plane_eqn;
}
edges.clear();
edges.resize(nVertices(), NULL);
aabb.fit(vertices.begin(), vertices.end(), vec_adapt_vertex_ptr());
untag();
int da = carve::geom::largestAxis(plane_eqn.N);
project = getProjector(plane_eqn.N.v[da] > 0, da);
unproject = getUnprojector(plane_eqn.N.v[da] > 0, da);
return this;
}
template<unsigned ndim>
template<typename iter_t>
Face<ndim> *Face<ndim>::create(iter_t vbegin, iter_t vend, bool flipped) const {
return (new Face)->init(this, vbegin, vend, flipped);
}
template<unsigned ndim>
Face<ndim> *Face<ndim>::create(const std::vector<const vertex_t *> &_vertices, bool flipped) const {
return (new Face)->init(this, _vertices.begin(), _vertices.end(), flipped);
}
template<unsigned ndim>
Face<ndim> *Face<ndim>::clone(bool flipped) const {
return (new Face)->init(this, vertices, flipped);
}
template<unsigned ndim>
void Face<ndim>::getVertexLoop(std::vector<const vertex_t *> &loop) const {
loop.resize(nVertices(), NULL);
std::copy(vbegin(), vend(), loop.begin());
}
template<unsigned ndim>
const typename Face<ndim>::edge_t *&Face<ndim>::edge(size_t idx) {
return edges[idx];
}
template<unsigned ndim>
const typename Face<ndim>::edge_t *Face<ndim>::edge(size_t idx) const {
return edges[idx];
}
template<unsigned ndim>
size_t Face<ndim>::nEdges() const {
return edges.size();
}
template<unsigned ndim>
const typename Face<ndim>::vertex_t *&Face<ndim>::vertex(size_t idx) {
return vertices[idx];
}
template<unsigned ndim>
const typename Face<ndim>::vertex_t *Face<ndim>::vertex(size_t idx) const {
return vertices[idx];
}
template<unsigned ndim>
size_t Face<ndim>::nVertices() const {
return vertices.size();
}
template<unsigned ndim>
typename Face<ndim>::vector_t Face<ndim>::centroid() const {
vector_t c;
carve::geom::centroid(vertices.begin(), vertices.end(), vec_adapt_vertex_ptr(), c);
return c;
}
template<unsigned ndim>
std::vector<carve::geom::vector<2> > Face<ndim>::projectedVertices() const {
p2_adapt_project<ndim> proj = projector();
std::vector<carve::geom::vector<2> > result;
result.reserve(nVertices());
for (size_t i = 0; i < nVertices(); ++i) {
result.push_back(proj(vertex(i)->v));
}
return result;
}
}
}

View File

@@ -1,103 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/classification.hpp>
#include <carve/collection_types.hpp>
namespace carve {
namespace csg {
struct FaceLoopGroup;
struct FaceLoop {
FaceLoop *next, *prev;
const carve::mesh::MeshSet<3>::face_t *orig_face;
std::vector<carve::mesh::MeshSet<3>::vertex_t *> vertices;
FaceLoopGroup *group;
FaceLoop(const carve::mesh::MeshSet<3>::face_t *f, const std::vector<carve::mesh::MeshSet<3>::vertex_t *> &v) : next(NULL), prev(NULL), orig_face(f), vertices(v), group(NULL) {}
};
struct FaceLoopList {
FaceLoop *head, *tail;
unsigned count;
FaceLoopList() : head(NULL), tail(NULL), count(0) { }
void append(FaceLoop *f) {
f->prev = tail;
f->next = NULL;
if (tail) tail->next = f;
tail = f;
if (!head) head = f;
count++;
}
void prepend(FaceLoop *f) {
f->next = head;
f->prev = NULL;
if (head) head->prev = f;
head = f;
if (!tail) tail = f;
count++;
}
unsigned size() const {
return count;
}
FaceLoop *remove(FaceLoop *f) {
FaceLoop *r = f->next;
if (f->prev) { f->prev->next = f->next; } else { head = f->next; }
if (f->next) { f->next->prev = f->prev; } else { tail = f->prev; }
f->next = f->prev = NULL;
count--;
return r;
}
~FaceLoopList() {
FaceLoop *a = head, *b;
while (a) {
b = a;
a = a->next;
delete b;
}
}
};
struct FaceLoopGroup {
const carve::mesh::MeshSet<3> *src;
FaceLoopList face_loops;
V2Set perimeter;
std::list<ClassificationInfo> classification;
FaceLoopGroup(const carve::mesh::MeshSet<3> *_src) : src(_src) {
}
FaceClass classificationAgainst(const carve::mesh::MeshSet<3>::mesh_t *mesh) const;
};
typedef std::list<FaceLoopGroup> FLGroupList;
}
}

View File

@@ -1,367 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <vector>
namespace carve {
namespace geom {
template<unsigned ndim> struct aabb;
// ========================================================================
struct _uninitialized { };
template<unsigned ndim>
struct base {
double v[ndim];
};
template<> struct base<2> {union { double v[2]; struct { double x, y; }; }; };
template<> struct base<3> {union { double v[3]; struct { double x, y, z; }; }; };
template<> struct base<4> {union { double v[4]; struct { double x, y, z, w; }; }; };
template<unsigned ndim>
struct vector : public base<ndim> {
enum { __ndim = ndim };
static vector ZERO();
double length2() const;
double length() const;
vector<ndim> &normalize();
vector<ndim> normalized() const;
bool exactlyZero() const;
bool isZero(double epsilon = EPSILON) const;
void setZero();
void fill(double val);
vector<ndim> &scaleBy(double d);
vector<ndim> &invscaleBy(double d);
vector<ndim> scaled(double d) const;
vector<ndim> invscaled(double d) const;
vector<ndim> &negate();
vector<ndim> negated() const;
double &operator[](unsigned i);
const double &operator[](unsigned i) const;
template<typename assign_t>
vector<ndim> &operator=(const assign_t &t);
std::string asStr() const;
aabb<ndim> getAABB() const;
vector() { setZero(); }
vector(noinit_t) { }
};
template<unsigned ndim>
vector<ndim> vector<ndim>::ZERO() { vector<ndim> r; r.setZero(); return r; }
static inline vector<2> VECTOR(double x, double y) { vector<2> r; r.x = x; r.y = y; return r; }
static inline vector<3> VECTOR(double x, double y, double z) { vector<3> r; r.x = x; r.y = y; r.z = z; return r; }
static inline vector<4> VECTOR(double x, double y, double z, double w) { vector<4> r; r.x = x; r.y = y; r.z = z; r.w = w; return r; }
template<unsigned ndim> vector<ndim> operator+(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> vector<ndim> operator+(const vector<ndim> &a, double b);
template<unsigned ndim, typename val_t> vector<ndim> operator+(const vector<ndim> &a, const val_t &b);
template<unsigned ndim, typename val_t> vector<ndim> operator+(const val_t &a, const vector<ndim> &b);
template<unsigned ndim> vector<ndim> &operator+=(vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> vector<ndim> &operator+=(vector<ndim> &a, double b);
template<unsigned ndim, typename val_t> vector<ndim> &operator+=(vector<ndim> &a, const val_t &b);
template<unsigned ndim> vector<ndim> operator-(const vector<ndim> &a);
template<unsigned ndim> vector<ndim> operator-(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> vector<ndim> operator-(const vector<ndim> &a, double b);
template<unsigned ndim, typename val_t> vector<ndim> operator-(const vector<ndim> &a, const val_t &b);
template<unsigned ndim, typename val_t> vector<ndim> operator-(const val_t &a, const vector<ndim> &b);
template<unsigned ndim> vector<ndim> &operator-=(vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> vector<ndim> &operator-=(vector<ndim> &a, double b);
template<unsigned ndim, typename val_t> vector<ndim> &operator-=(vector<ndim> &a, const val_t &b);
template<unsigned ndim> vector<ndim> operator*(const vector<ndim> &a, double s);
template<unsigned ndim> vector<ndim> operator*(double s, const vector<ndim> &a);
template<unsigned ndim> vector<ndim> &operator*=(vector<ndim> &a, double s);
template<unsigned ndim> vector<ndim> operator/(const vector<ndim> &a, double s);
template<unsigned ndim> vector<ndim> &operator/=(vector<ndim> &a, double s);
template<unsigned ndim> bool operator==(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> bool operator!=(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> bool operator<(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> bool operator<=(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> bool operator>(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> bool operator>=(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> vector<ndim> abs(const vector<ndim> &a);
template<unsigned ndim> double distance2(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> double distance(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> bool equal(const vector<ndim> &a, const vector<ndim> &b);
template<unsigned ndim> int smallestAxis(const vector<ndim> &a);
template<unsigned ndim> int largestAxis(const vector<ndim> &a);
template<unsigned ndim> vector<2> select(const vector<ndim> &a, int a1, int a2);
template<unsigned ndim> vector<3> select(const vector<ndim> &a, int a1, int a2, int a3);
template<unsigned ndim, typename assign_t, typename oper_t>
vector<ndim> &assign_op(vector<ndim> &a, const assign_t &t, oper_t op);
template<unsigned ndim, typename assign1_t, typename assign2_t, typename oper_t>
vector<ndim> &assign_op(vector<ndim> &a, const assign1_t &t1, const assign2_t &t2, oper_t op);
template<unsigned ndim, typename iter_t>
void bounds(iter_t begin, iter_t end, vector<ndim> &min, vector<ndim> &max);
template<unsigned ndim, typename iter_t, typename adapt_t>
void bounds(iter_t begin, iter_t end, adapt_t adapt, vector<ndim> &min, vector<ndim> &max);
template<unsigned ndim, typename iter_t>
void centroid(iter_t begin, iter_t end, vector<ndim> &c);
template<unsigned ndim, typename iter_t, typename adapt_t>
void centroid(iter_t begin, iter_t end, adapt_t adapt, vector<ndim> &c);
template<unsigned ndim, typename val_t> double dot(const vector<ndim> &a, const val_t &b);
static inline vector<3> cross(const vector<3> &a, const vector<3> &b);
static inline double cross(const vector<2> &a, const vector<2> &b);
static inline double dotcross(const vector<3> &a, const vector<3> &b, const vector<3> &c);
// ========================================================================
struct axis_pos {
int axis;
double pos;
axis_pos(int _axis, double _pos) : axis(_axis), pos(_pos) { }
};
template<unsigned ndim>
double distance(const axis_pos &a, const vector<ndim> &b);
template<unsigned ndim>
double distance2(const axis_pos &a, const vector<ndim> &b);
template<unsigned ndim> bool operator<(const axis_pos &a, const vector<ndim> &b);
template<unsigned ndim> bool operator<(const vector<ndim> &a, const axis_pos &b);
template<unsigned ndim> bool operator<=(const axis_pos &a, const vector<ndim> &b);
template<unsigned ndim> bool operator<=(const vector<ndim> &a, const axis_pos &b);
template<unsigned ndim> bool operator>(const axis_pos &a, const vector<ndim> &b);
template<unsigned ndim> bool operator>(const vector<ndim> &a, const axis_pos &b);
template<unsigned ndim> bool operator>=(const axis_pos &a, const vector<ndim> &b);
template<unsigned ndim> bool operator>=(const vector<ndim> &a, const axis_pos &b);
template<unsigned ndim> bool operator==(const axis_pos &a, const vector<ndim> &b);
template<unsigned ndim> bool operator==(const vector<ndim> &a, const axis_pos &b);
template<unsigned ndim> bool operator!=(const axis_pos &a, const vector<ndim> &b);
template<unsigned ndim> bool operator!=(const vector<ndim> &a, const axis_pos &b);
// ========================================================================
template<unsigned ndim>
struct ray {
typedef vector<ndim> vector_t;
vector_t D, v;
bool OK() const;
ray() { }
ray(vector_t _D, vector_t _v) : D(_D), v(_v) { }
};
template<unsigned ndim>
ray<ndim> rayThrough(const vector<ndim> &a, const vector<ndim> &b);
static inline double distance2(const ray<3> &r, const vector<3> &v);
static inline double distance(const ray<3> &r, const vector<3> &v);
static inline double distance2(const ray<2> &r, const vector<2> &v);
static inline double distance(const ray<2> &r, const vector<2> &v);
// ========================================================================
template<unsigned ndim>
struct linesegment {
typedef vector<ndim> vector_t;
vector_t v1;
vector_t v2;
vector_t midpoint;
vector_t half_length;
void update();
bool OK() const;
void flip();
aabb<ndim> getAABB() const;
linesegment(const vector_t &_v1, const vector_t &_v2);
};
template<unsigned ndim>
double distance2(const linesegment<ndim> &l, const vector<ndim> &v);
template<unsigned ndim>
double distance(const linesegment<ndim> &l, const vector<ndim> &v);
// ========================================================================
template<unsigned ndim>
struct plane {
typedef vector<ndim> vector_t;
vector_t N;
double d;
void negate();
plane();
plane(const vector_t &_N, vector_t _p);
plane(const vector_t &_N, double _d);
};
template<unsigned ndim>
inline plane<ndim> operator-(const plane<ndim> &p);
template<unsigned ndim, typename val_t>
double distance(const plane<ndim> &plane, const val_t &point);
template<unsigned ndim, typename val_t>
double distance2(const plane<ndim> &plane, const val_t &point);
template<unsigned ndim>
static inline vector<ndim> closestPoint(const plane<ndim> &p, const vector<ndim> &v);
// ========================================================================
template<unsigned ndim>
struct sphere {
typedef vector<ndim> vector_t;
vector_t C;
double r;
aabb<ndim> getAABB() const;
sphere();
sphere(const vector_t &_C, double _r);
};
template<unsigned ndim, typename val_t>
double distance(const sphere<ndim> &sphere, const val_t &point);
template<unsigned ndim, typename val_t>
double distance2(const sphere<ndim> &sphere, const val_t &point);
template<unsigned ndim>
static inline vector<ndim> closestPoint(const sphere<ndim> &sphere, const vector<ndim> &point);
// ========================================================================
template<unsigned ndim>
struct tri {
typedef vector<ndim> vector_t;
vector_t v[3];
aabb<ndim> getAABB() const;
tri() { }
tri(vector_t _v[3]);
tri(const vector_t &a, const vector_t &b, const vector_t &c);
vector_t normal() const {
return cross(v[1] - v[0], v[2] - v[1]).normalized();
}
};
template<unsigned ndim> std::ostream &operator<<(std::ostream &o, const vector<ndim> &v);
template<unsigned ndim> std::ostream &operator<<(std::ostream &o, const carve::geom::plane<ndim> &p);
template<unsigned ndim> std::ostream &operator<<(std::ostream &o, const carve::geom::sphere<ndim> &sphere);
template<unsigned ndim> std::ostream &operator<<(std::ostream &o, const carve::geom::tri<ndim> &tri);
template<unsigned ndim> vector<ndim> closestPoint(const tri<ndim> &tri, const vector<ndim> &pt);
template<unsigned ndim> double distance(const tri<ndim> &tri, const vector<ndim> &pt);
template<unsigned ndim> double distance2(const tri<ndim> &tri, const vector<ndim> &pt);
// ========================================================================
struct distance_functor {
template<typename obj1_t, typename obj2_t>
double operator()(const obj1_t &o1, const obj2_t &o2) {
return distance(o1, o2);
}
};
// ========================================================================
template<int base, int power> struct __pow__ { enum { val = __pow__<base, (power >> 1)>::val * __pow__<base, power - (power >> 1)>::val }; };
template<int base> struct __pow__<base, 1> { enum { val = base }; };
template<int base> struct __pow__<base, 0> { enum { val = 1 }; };
template<unsigned base, unsigned ndigits>
struct quantize {
typedef __pow__<base, ndigits> fac;
double operator()(double in) {
return round(in * fac::val) / fac::val;
}
template<unsigned ndim>
vector<ndim> operator()(const vector<ndim> &in) {
vector<ndim> r(NOINIT);
assign_op(r, in, *this);
return r;
}
};
}
}
#include <carve/geom_impl.hpp>

View File

@@ -1,403 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/math.hpp>
#include <carve/math_constants.hpp>
#include <carve/geom.hpp>
#include <vector>
#include <algorithm>
#include <math.h>
#if defined(CARVE_DEBUG)
# include <iostream>
#endif
#if defined CARVE_USE_EXACT_PREDICATES
# include <carve/shewchuk_predicates.hpp>
#endif
namespace carve {
namespace geom2d {
typedef carve::geom::vector<2> P2;
typedef carve::geom::ray<2> Ray2;
typedef carve::geom::linesegment<2> LineSegment2;
struct p2_adapt_ident {
P2 &operator()(P2 &p) const { return p; }
const P2 &operator()(const P2 &p) const { return p; }
};
typedef std::vector<P2> P2Vector;
/**
* \brief Return the orientation of c with respect to the ray defined by a->b.
*
* (Can be implemented exactly)
*
* @param[in] a
* @param[in] b
* @param[in] c
*
* @return positive, if c to the left of a->b.
* zero, if c is colinear with a->b.
* negative, if c to the right of a->b.
*/
#if defined CARVE_USE_EXACT_PREDICATES
inline double orient2d(const P2 &a, const P2 &b, const P2 &c) {
return shewchuk::orient2d(a.v, b.v, c.v);
}
#else
inline double orient2d(const P2 &a, const P2 &b, const P2 &c) {
double acx = a.x - c.x;
double bcx = b.x - c.x;
double acy = a.y - c.y;
double bcy = b.y - c.y;
return acx * bcy - acy * bcx;
}
#endif
/**
* \brief Determine whether p is internal to the anticlockwise
* angle abc, where b is the apex of the angle.
*
* @param[in] a
* @param[in] b
* @param[in] c
* @param[in] p
*
* @return true, if p is contained in the anticlockwise angle from
* b->a to b->c. Reflex angles contain p if p lies
* on b->a or on b->c. Acute angles do not contain p
* if p lies on b->a or on b->c. This is so that
* internalToAngle(a,b,c,p) = !internalToAngle(c,b,a,p)
*/
inline bool internalToAngle(const P2 &a,
const P2 &b,
const P2 &c,
const P2 &p) {
bool reflex = (a < c) ? orient2d(b, a, c) <= 0.0 : orient2d(b, c, a) > 0.0;
double d1 = orient2d(b, a, p);
double d2 = orient2d(b, c, p);
if (reflex) {
return d1 >= 0.0 || d2 <= 0.0;
} else {
return d1 > 0.0 && d2 < 0.0;
}
}
/**
* \brief Determine whether p is internal to the anticlockwise
* angle ac, with apex at (0,0).
*
* @param[in] a
* @param[in] c
* @param[in] p
*
* @return true, if p is contained in a0c.
*/
inline bool internalToAngle(const P2 &a,
const P2 &c,
const P2 &p) {
return internalToAngle(a, P2::ZERO(), c, p);
}
template<typename P2vec>
bool isAnticlockwise(const P2vec &tri) {
return orient2d(tri[0], tri[1], tri[2]) > 0.0;
}
template<typename P2vec>
bool pointIntersectsTriangle(const P2 &p, const P2vec &tri) {
int orient = isAnticlockwise(tri) ? +1 : -1;
if (orient2d(tri[0], tri[1], p) * orient < 0) return false;
if (orient2d(tri[1], tri[2], p) * orient < 0) return false;
if (orient2d(tri[2], tri[0], p) * orient < 0) return false;
return true;
}
template<typename P2vec>
bool lineIntersectsTriangle(const P2 &p1, const P2 &p2, const P2vec &tri) {
double s[3];
// does tri lie on one side or the other of p1-p2?
s[0] = orient2d(p1, p2, tri[0]);
s[1] = orient2d(p1, p2, tri[1]);
s[2] = orient2d(p1, p2, tri[2]);
if (*std::max_element(s, s+3) < 0) return false;
if (*std::min_element(s, s+3) > 0) return false;
// does line lie entirely to the right of a triangle edge?
int orient = isAnticlockwise(tri) ? +1 : -1;
if (orient2d(tri[0], tri[1], p1) * orient < 0 && orient2d(tri[0], tri[1], p2) * orient < 0) return false;
if (orient2d(tri[1], tri[2], p1) * orient < 0 && orient2d(tri[1], tri[2], p2) * orient < 0) return false;
if (orient2d(tri[2], tri[0], p1) * orient < 0 && orient2d(tri[2], tri[0], p2) * orient < 0) return false;
return true;
}
template<typename P2vec>
int triangleLineOrientation(const P2 &p1, const P2 &p2, const P2vec &tri) {
double lo, hi, tmp;
lo = hi = orient2d(p1, p2, tri[0]);
tmp = orient2d(p1, p2, tri[1]); lo = std::min(lo, tmp); hi = std::max(hi, tmp);
tmp = orient2d(p1, p2, tri[2]); lo = std::min(lo, tmp); hi = std::max(hi, tmp);
if (hi < 0.0) return -1;
if (lo > 0.0) return +1;
return 0;
}
template<typename P2vec>
bool triangleIntersectsTriangle(const P2vec &tri_b, const P2vec &tri_a) {
int orient_a = isAnticlockwise(tri_a) ? +1 : -1;
if (triangleLineOrientation(tri_a[0], tri_a[1], tri_b) * orient_a < 0) return false;
if (triangleLineOrientation(tri_a[1], tri_a[2], tri_b) * orient_a < 0) return false;
if (triangleLineOrientation(tri_a[2], tri_a[0], tri_b) * orient_a < 0) return false;
int orient_b = isAnticlockwise(tri_b) ? +1 : -1;
if (triangleLineOrientation(tri_b[0], tri_b[1], tri_a) * orient_b < 0) return false;
if (triangleLineOrientation(tri_b[1], tri_b[2], tri_a) * orient_b < 0) return false;
if (triangleLineOrientation(tri_b[2], tri_b[0], tri_a) * orient_b < 0) return false;
return true;
}
static inline double atan2(const P2 &p) {
return ::atan2(p.y, p.x);
}
struct LineIntersectionInfo {
LineIntersectionClass iclass;
P2 ipoint;
int p1, p2;
LineIntersectionInfo(LineIntersectionClass _iclass,
P2 _ipoint = P2::ZERO(),
int _p1 = -1,
int _p2 = -1) :
iclass(_iclass), ipoint(_ipoint), p1(_p1), p2(_p2) {
}
};
struct PolyInclusionInfo {
PointClass iclass;
int iobjnum;
PolyInclusionInfo(PointClass _iclass,
int _iobjnum = -1) :
iclass(_iclass), iobjnum(_iobjnum) {
}
};
struct PolyIntersectionInfo {
IntersectionClass iclass;
P2 ipoint;
size_t iobjnum;
PolyIntersectionInfo(IntersectionClass _iclass,
const P2 &_ipoint,
size_t _iobjnum) :
iclass(_iclass), ipoint(_ipoint), iobjnum(_iobjnum) {
}
};
bool lineSegmentIntersection_simple(const P2 &l1v1, const P2 &l1v2,
const P2 &l2v1, const P2 &l2v2);
bool lineSegmentIntersection_simple(const LineSegment2 &l1,
const LineSegment2 &l2);
LineIntersectionInfo lineSegmentIntersection(const P2 &l1v1, const P2 &l1v2,
const P2 &l2v1, const P2 &l2v2);
LineIntersectionInfo lineSegmentIntersection(const LineSegment2 &l1,
const LineSegment2 &l2);
int lineSegmentPolyIntersections(const std::vector<P2> &points,
LineSegment2 line,
std::vector<PolyInclusionInfo> &out);
int sortedLineSegmentPolyIntersections(const std::vector<P2> &points,
LineSegment2 line,
std::vector<PolyInclusionInfo> &out);
static inline bool quadIsConvex(const P2 &a, const P2 &b, const P2 &c, const P2 &d) {
double s_1, s_2;
s_1 = carve::geom2d::orient2d(a, c, b);
s_2 = carve::geom2d::orient2d(a, c, d);
if ((s_1 < 0.0 && s_2 < 0.0) || (s_1 > 0.0 && s_2 > 0.0)) return false;
s_1 = carve::geom2d::orient2d(b, d, a);
s_2 = carve::geom2d::orient2d(b, d, c);
if ((s_1 < 0.0 && s_2 < 0.0) || (s_1 > 0.0 && s_2 > 0.0)) return false;
return true;
}
template<typename T, typename adapt_t>
inline bool quadIsConvex(const T &a, const T &b, const T &c, const T &d, adapt_t adapt) {
return quadIsConvex(adapt(a), adapt(b), adapt(c), adapt(d));
}
double signedArea(const std::vector<P2> &points);
static inline double signedArea(const P2 &a, const P2 &b, const P2 &c) {
return ((b.y + a.y) * (b.x - a.x) + (c.y + b.y) * (c.x - b.x) + (a.y + c.y) * (a.x - c.x)) / 2.0;
}
template<typename T, typename adapt_t>
double signedArea(const std::vector<T> &points, adapt_t adapt) {
P2Vector::size_type l = points.size();
double A = 0.0;
for (P2Vector::size_type i = 0; i < l - 1; i++) {
A += (adapt(points[i + 1]).y + adapt(points[i]).y) * (adapt(points[i + 1]).x - adapt(points[i]).x);
}
A += (adapt(points[0]).y + adapt(points[l - 1]).y) * (adapt(points[0]).x - adapt(points[l - 1]).x);
return A / 2.0;
}
template<typename iter_t, typename adapt_t>
double signedArea(iter_t begin, iter_t end, adapt_t adapt) {
double A = 0.0;
P2 p, n;
if (begin == end) return 0.0;
p = adapt(*begin);
for (iter_t c = begin; ++c != end; ) {
P2 n = adapt(*c);
A += (n.y + p.y) * (n.x - p.x);
p = n;
}
n = adapt(*begin);
A += (n.y + p.y) * (n.x - p.x);
return A / 2.0;
}
bool pointInPolySimple(const std::vector<P2> &points, const P2 &p);
template<typename T, typename adapt_t>
bool pointInPolySimple(const std::vector<T> &points, adapt_t adapt, const P2 &p) {
CARVE_ASSERT(points.size() > 0);
P2Vector::size_type l = points.size();
double s = 0.0;
double rp, r0, d;
rp = r0 = atan2(adapt(points[0]) - p);
for (P2Vector::size_type i = 1; i < l; i++) {
double r = atan2(adapt(points[i]) - p);
d = r - rp;
if (d > M_PI) d -= M_TWOPI;
if (d < -M_PI) d += M_TWOPI;
s = s + d;
rp = r;
}
d = r0 - rp;
if (d > M_PI) d -= M_TWOPI;
if (d < -M_PI) d += M_TWOPI;
s = s + d;
return !carve::math::ZERO(s);
}
PolyInclusionInfo pointInPoly(const std::vector<P2> &points, const P2 &p);
template<typename T, typename adapt_t>
PolyInclusionInfo pointInPoly(const std::vector<T> &points, adapt_t adapt, const P2 &p) {
P2Vector::size_type l = points.size();
for (unsigned i = 0; i < l; i++) {
if (equal(adapt(points[i]), p)) return PolyInclusionInfo(POINT_VERTEX, (int)i);
}
for (unsigned i = 0; i < l; i++) {
unsigned j = (i + 1) % l;
if (std::min(adapt(points[i]).x, adapt(points[j]).x) - EPSILON < p.x &&
std::max(adapt(points[i]).x, adapt(points[j]).x) + EPSILON > p.x &&
std::min(adapt(points[i]).y, adapt(points[j]).y) - EPSILON < p.y &&
std::max(adapt(points[i]).y, adapt(points[j]).y) + EPSILON > p.y &&
distance2(carve::geom::rayThrough(adapt(points[i]), adapt(points[j])), p) < EPSILON2) {
return PolyInclusionInfo(POINT_EDGE, (int)i);
}
}
if (pointInPolySimple(points, adapt, p)) {
return PolyInclusionInfo(POINT_IN);
}
return PolyInclusionInfo(POINT_OUT);
}
bool pickContainedPoint(const std::vector<P2> &poly, P2 &result);
template<typename T, typename adapt_t>
bool pickContainedPoint(const std::vector<T> &poly, adapt_t adapt, P2 &result) {
#if defined(CARVE_DEBUG)
std::cerr << "pickContainedPoint ";
for (unsigned i = 0; i < poly.size(); ++i) std::cerr << " " << adapt(poly[i]);
std::cerr << std::endl;
#endif
const size_t S = poly.size();
P2 a, b, c;
for (unsigned i = 0; i < S; ++i) {
a = adapt(poly[i]);
b = adapt(poly[(i + 1) % S]);
c = adapt(poly[(i + 2) % S]);
if (cross(a - b, c - b) < 0) {
P2 p = (a + b + c) / 3;
if (pointInPolySimple(poly, adapt, p)) {
result = p;
return true;
}
}
}
return false;
}
}
}

View File

@@ -1,324 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom.hpp>
#include <math.h>
#include <carve/math_constants.hpp>
#include <vector>
#include <list>
#include <map>
#if defined(CARVE_DEBUG)
# include <iostream>
#endif
#if defined CARVE_USE_EXACT_PREDICATES
# include <carve/shewchuk_predicates.hpp>
#endif
namespace carve {
namespace geom3d {
typedef carve::geom::plane<3> Plane;
typedef carve::geom::ray<3> Ray;
typedef carve::geom::linesegment<3> LineSegment;
typedef carve::geom::vector<3> Vector;
template<typename iter_t, typename adapt_t>
bool fitPlane(iter_t begin, iter_t end, adapt_t adapt, Plane &plane) {
std::vector<Vector> p;
for (; begin != end; ++begin) {
p.push_back(adapt(*begin));
}
if (p.size() < 3) {
return false;
}
Vector C;
carve::geom::centroid(p.begin(), p.end(), C);
Vector n;
if (p.size() == 3) {
n = cross(p[1] - p[0], p[2] - p[0]);
} else {
const size_t N = p.size();
n = cross(p[N-1] - C, p[0] - C);
if (n < Vector::ZERO()) n.negate();
for (size_t i = 1; i < p.size(); ++i) {
Vector v = cross(p[i] - C, p[i-1] - C);
if (v < Vector::ZERO()) v.negate();
n += v;
}
}
double l = n.length();
if (l == 0.0) {
n.x = 1.0;
n.y = 0.0;
n.z = 0.0;
} else {
n.normalize();
}
plane.N = n;
plane.d = -dot(n, C);
#if defined(CARVE_DEBUG)
if (p.size() > 3) {
std::cerr << "N-gon with " << p.size() << " vertices: fitted distance:";
for (size_t i = 0; i < p.size(); ++i) {
std::cerr << " {" << p[i] << "} " << distance(plane, p[i]);
}
std::cerr << std::endl;
}
#endif
return true;
}
bool planeIntersection(const Plane &a, const Plane &b, Ray &r);
IntersectionClass rayPlaneIntersection(const Plane &p,
const Vector &v1,
const Vector &v2,
Vector &v,
double &t);
IntersectionClass lineSegmentPlaneIntersection(const Plane &p,
const LineSegment &line,
Vector &v);
RayIntersectionClass rayRayIntersection(const Ray &r1,
const Ray &r2,
Vector &v1,
Vector &v2,
double &mu1,
double &mu2);
// test whether point d is above, below or on the plane formed by the triangle a,b,c.
// return: +ve = d is below a,b,c
// -ve = d is above a,b,c
// 0 = d is on a,b,c
#if defined CARVE_USE_EXACT_PREDICATES
inline double orient3d(const Vector &a,
const Vector &b,
const Vector &c,
const Vector &d) {
return shewchuk::orient3d(a.v, b.v, c.v, d.v);
}
#else
inline double orient3d(const Vector &a,
const Vector &b,
const Vector &c,
const Vector &d) {
return dotcross((a - d), (b - d), (c - d));
}
#endif
// Volume of a tetrahedron described by 4 points. Will be
// positive if the anticlockwise normal of a,b,c is oriented out
// of the tetrahedron.
//
// see: http://mathworld.wolfram.com/Tetrahedron.html
inline double tetrahedronVolume(const Vector &a,
const Vector &b,
const Vector &c,
const Vector &d) {
return dotcross((a - d), (b - d), (c - d)) / 6.0;
}
/**
* \brief Determine whether p is internal to the wedge defined by
* the area between the planes defined by a,b,c and a,b,d
* angle abc, where ab is the apex of the angle.
*
* @param[in] a
* @param[in] b
* @param[in] c
* @param[in] d
* @param[in] p
*
* @return true, if p is contained in the wedge defined by the
* area between the planes defined by a,b,c and
* a,b,d. If the wedge is reflex, p is considered to
* be contained if it lies on either plane. Acute
* wdges do not contain p if p lies on either
* plane. This is so that internalToWedge(a,b,c,d,p) =
* !internalToWedge(a,b,d,c,p)
*/
inline bool internalToWedge(const Vector &a,
const Vector &b,
const Vector &c,
const Vector &d,
const Vector &p) {
bool reflex = (c < d) ?
orient3d(a, b, c, d) >= 0.0 :
orient3d(a, b, d, c) < 0.0;
double d1 = orient3d(a, b, c, p);
double d2 = orient3d(a, b, d, p);
if (reflex) {
// above a,b,c or below a,b,d (or coplanar with either)
return d1 <= 0.0 || d2 >= 0.0;
} else {
// above a,b,c and below a,b,d
return d1 < 0.0 && d2 > 0.0;
}
}
/**
* \brief Determine the ordering relationship of a and b, when
* rotating around direction, starting from base.
*
* @param[in] adirection
* @param[in] base
* @param[in] a
* @param[in] b
*
* @return
* * -1, if a is ordered before b around, rotating about direction.
* * 0, if a and b are equal in angle.
* * +1, if a is ordered after b around, rotating about direction.
*/
inline int compareAngles(const Vector &direction, const Vector &base, const Vector &a, const Vector &b) {
// double d1 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, a, b);
// double d2 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, a);
// double d3 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, b);
#if defined(CARVE_USE_EXACT_PREDICATES)
// which is equivalent to the following (which eliminates a
// vector subtraction):
double d1 = carve::geom3d::orient3d(direction, b, a, carve::geom::VECTOR(0,0,0));
double d2 = carve::geom3d::orient3d(direction, a, base, carve::geom::VECTOR(0,0,0));
double d3 = carve::geom3d::orient3d(direction, b, base, carve::geom::VECTOR(0,0,0));
#else
// dotcross = a . (b x c)
double d1 = carve::geom::dotcross(direction, b, a );
double d2 = carve::geom::dotcross(direction, a, base);
double d3 = carve::geom::dotcross(direction, b, base);
#endif
// CASE: a and b are coplanar wrt. direction.
if (d1 == 0.0) {
// a and b point in the same direction.
if (dot(a, b) > 0.0) {
// Neither is less than the other.
return 0;
}
// a and b point in opposite directions.
// * if d2 < 0.0, a is above plane(direction, base) and is less
// than b.
// * if d2 == 0.0 a is coplanar with plane(direction, base) and is
// less than b if it points in the same direction as base.
// * if d2 > 0.0, a is below plane(direction, base) and is greater
// than b.
if (d2 == 0.0) { return dot(a, base) > 0.0 ? -1 : +1; }
if (d3 == 0.0) { return dot(b, base) > 0.0 ? +1 : -1; }
if (d2 < 0.0 && d3 > 0.0) return -1;
if (d2 > 0.0 && d3 < 0.0) return +1;
// both a and b are to one side of plane(direction, base) -
// rounding error (if a and b are truly coplanar with
// direction, one should be above, and one should be below any
// other plane that is not itself coplanar with
// plane(direction, a|b) - which would imply d2 and d3 == 0.0).
// If both are below plane(direction, base) then the one that
// points in the same direction as base is greater.
// If both are above plane(direction, base) then the one that
// points in the same direction as base is lesser.
if (d2 > 0.0) { return dot(a, base) > 0.0 ? +1 : -1; }
else { return dot(a, base) > 0.0 ? -1 : +1; }
}
// CASE: a and b are not coplanar wrt. direction
if (d2 < 0.0) {
// if a is above plane(direction,base), then a is less than b if
// b is below plane(direction,base) or b is above plane(direction,a)
return (d3 > 0.0 || d1 < 0.0) ? -1 : +1;
} else if (d2 == 0.0) {
// if a is on plane(direction,base) then a is less than b if a
// points in the same direction as base, or b is below
// plane(direction,base)
return (dot(a, base) > 0.0 || d3 > 0.0) ? -1 : +1;
} else {
// if a is below plane(direction,base), then a is less than b if b
// is below plane(direction,base) and b is above plane(direction,a)
return (d3 > 0.0 && d1 < 0.0) ? -1 : +1;
}
}
// The anticlockwise angle from vector "from" to vector "to", oriented around the vector "orient".
static inline double antiClockwiseAngle(const Vector &from, const Vector &to, const Vector &orient) {
double dp = dot(from, to);
Vector cp = cross(from, to);
if (cp.isZero()) {
if (dp < 0) {
return M_PI;
} else {
return 0.0;
}
} else {
if (dot(cp, orient) > 0.0) {
return acos(dp);
} else {
return M_TWOPI - acos(dp);
}
}
}
static inline double antiClockwiseOrdering(const Vector &from, const Vector &to, const Vector &orient) {
double dp = dot(from, to);
Vector cp = cross(from, to);
if (cp.isZero()) {
if (dp < 0) {
return 2.0;
} else {
return 0.0;
}
} else {
if (dot(cp, orient) > 0.0) {
// 1..-1 -> 0..2
return 1.0 - dp;
} else {
// -1..1 -> 2..4
return dp + 1.0;
}
}
}
}
}

View File

@@ -1,672 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/math.hpp>
namespace carve {
namespace geom {
template<unsigned ndim>
double vector<ndim>::length2() const { return dot(*this, *this); }
template<unsigned ndim>
double vector<ndim>::length() const { return sqrt(dot(*this, *this)); }
template<unsigned ndim>
vector<ndim> &vector<ndim>::normalize() {
#if defined(CARVE_DEBUG)
CARVE_ASSERT(length() > 0.0);
#endif
*this /= length();
return *this;
}
template<unsigned ndim>
vector<ndim> vector<ndim>::normalized() const {
#if defined(CARVE_DEBUG)
CARVE_ASSERT(length() > 0.0);
#endif
return *this / length();
}
template<unsigned ndim>
bool vector<ndim>::exactlyZero() const {
for (unsigned i = 0; i < ndim; ++i) if (this->v[i]) return false;
return true;
}
template<unsigned ndim>
bool vector<ndim>::isZero(double epsilon) const {
return length2() < epsilon * epsilon;
}
template<unsigned ndim>
void vector<ndim>::setZero() { for (size_t i = 0; i < ndim; ++i) this->v[i] = 0.0; }
template<unsigned ndim>
void vector<ndim>::fill(double val) { for (size_t i = 0; i < ndim; ++i) this->v[i] = val; }
template<unsigned ndim>
vector<ndim> &vector<ndim>::scaleBy(double d) { for (unsigned i = 0; i < ndim; ++i) this->v[i] *= d; return *this; }
template<unsigned ndim>
vector<ndim> &vector<ndim>::invscaleBy(double d) { for (unsigned i = 0; i < ndim; ++i) this->v[i] /= d; return *this; }
template<unsigned ndim>
vector<ndim> vector<ndim>::scaled(double d) const { return *this * d; }
template<unsigned ndim>
vector<ndim> vector<ndim>::invscaled(double d) const { return *this / d; }
template<unsigned ndim>
vector<ndim> &vector<ndim>::negate() { for (unsigned i = 0; i < ndim; ++i) this->v[i] = -this->v[i]; return *this; }
template<unsigned ndim>
vector<ndim> vector<ndim>::negated() const { return -*this; }
template<unsigned ndim>
double &vector<ndim>::operator[](unsigned i) { return this->v[i]; }
template<unsigned ndim>
const double &vector<ndim>::operator[](unsigned i) const { return this->v[i]; }
template<unsigned ndim>
template<typename assign_t>
vector<ndim> &vector<ndim>::operator=(const assign_t &t) {
for (unsigned i = 0; i < ndim; ++i) this->v[i] = t[i];
return *this;
}
template<unsigned ndim>
std::string vector<ndim>::asStr() const {
std::ostringstream out;
out << '<';
out << std::setprecision(24);
for (unsigned i = 0; i < ndim; ++i) { if (i) out << ','; out << this->v[i]; }
out << '>';
return out.str();
}
template<unsigned ndim>
vector<ndim> operator+(const vector<ndim> &a, const vector<ndim> &b) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] + b[i];
return c;
}
template<unsigned ndim>
vector<ndim> operator+(const vector<ndim> &a, double b) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] + b;
return c;
}
template<unsigned ndim, typename val_t>
vector<ndim> operator+(const vector<ndim> &a, const val_t &b) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] + b[i];
return c;
}
template<unsigned ndim, typename val_t>
vector<ndim> operator+(const val_t &a, const vector<ndim> &b) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] + b[i];
return c;
}
template<unsigned ndim>
vector<ndim> &operator+=(vector<ndim> &a, const vector<ndim> &b) {
for (unsigned i = 0; i < ndim; ++i) a[i] += b[i];
return a;
}
template<unsigned ndim>
vector<ndim> &operator+=(vector<ndim> &a, double b) {
for (unsigned i = 0; i < ndim; ++i) a[i] += b;
return a;
}
template<unsigned ndim, typename val_t>
vector<ndim> &operator+=(vector<ndim> &a, const val_t &b) {
for (unsigned i = 0; i < ndim; ++i) a[i] += b[i];
return a;
}
template<unsigned ndim>
vector<ndim> operator-(const vector<ndim> &a) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = -a[i];
return c;
}
template<unsigned ndim>
vector<ndim> operator-(const vector<ndim> &a, double b) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] - b;
return c;
}
template<unsigned ndim>
vector<ndim> operator-(const vector<ndim> &a, const vector<ndim> &b) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] - b[i];
return c;
}
template<unsigned ndim, typename val_t>
vector<ndim> operator-(const vector<ndim> &a, const val_t &b) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] - b[i];
return c;
}
template<unsigned ndim, typename val_t>
vector<ndim> operator-(const val_t &a, const vector<ndim> &b) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] - b[i];
return c;
}
template<unsigned ndim>
vector<ndim> &operator-=(vector<ndim> &a, const vector<ndim> &b) {
for (unsigned i = 0; i < ndim; ++i) a[i] -= b[i];
return a;
}
template<unsigned ndim>
vector<ndim> &operator-=(vector<ndim> &a, double b) {
for (unsigned i = 0; i < ndim; ++i) a[i] -= b;
return a;
}
template<unsigned ndim, typename val_t>
vector<ndim> &operator-=(vector<ndim> &a, const val_t &b) {
for (unsigned i = 0; i < ndim; ++i) a[i] -= b[i];
return a;
}
template<unsigned ndim>
vector<ndim> operator*(const vector<ndim> &a, double s) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] * s;
return c;
}
template<unsigned ndim>
vector<ndim> operator*(double s, const vector<ndim> &a) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] * s;
return c;
}
template<unsigned ndim>
vector<ndim> &operator*=(vector<ndim> &a, double s) {
for (unsigned i = 0; i < ndim; ++i) a[i] *= s;
return a;
}
template<unsigned ndim>
vector<ndim> operator/(const vector<ndim> &a, double s) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = a[i] / s;
return c;
}
template<unsigned ndim>
vector<ndim> &operator/=(vector<ndim> &a, double s) {
for (unsigned i = 0; i < ndim; ++i) a[i] /= s;
return a;
}
template<unsigned ndim>
bool operator==(const vector<ndim> &a, const vector<ndim> &b) {
for (unsigned i = 0; i < ndim; ++i) { if (a[i] != b[i]) return false; }
return true;
}
template<unsigned ndim>
bool operator!=(const vector<ndim> &a, const vector<ndim> &b) {
return !(a == b);
}
template<unsigned ndim>
bool operator<(const vector<ndim> &a, const vector<ndim> &b) {
for (unsigned i = 0; i < ndim; ++i) { if (a[i] < b[i]) return true; if (a[i] > b[i]) return false; }
return false;
}
template<unsigned ndim>
bool operator<=(const vector<ndim> &a, const vector<ndim> &b) {
return !(b < a);
}
template<unsigned ndim>
bool operator>(const vector<ndim> &a, const vector<ndim> &b) {
return b < a;
}
template<unsigned ndim>
bool operator>=(const vector<ndim> &a, const vector<ndim> &b) {
return !(a < b);
}
template<unsigned ndim>
vector<ndim> abs(const vector<ndim> &a) {
vector<ndim> c(NOINIT);
for (unsigned i = 0; i < ndim; ++i) c[i] = fabs(a[i]);
return c;
}
template<unsigned ndim>
double distance2(const vector<ndim> &a, const vector<ndim> &b) {
return (b - a).length2();
}
template<unsigned ndim>
double distance(const vector<ndim> &a, const vector<ndim> &b) {
return (b - a).length();
}
template<unsigned ndim>
bool equal(const vector<ndim> &a, const vector<ndim> &b) {
return (b - a).isZero();
}
template<unsigned ndim>
int smallestAxis(const vector<ndim> &a) {
int idx = 0;
double lo = fabs(a[0]);
for (unsigned i = 1; i < ndim; ++i) {
double val = fabs(a[i]);
if (val <= lo) { lo = val; idx = (int)i; }
}
return idx;
}
template<unsigned ndim>
int largestAxis(const vector<ndim> &a) {
int idx = 0;
double hi = fabs(a[0]);
for (unsigned i = 1; i < ndim; ++i) {
double val = fabs(a[i]);
if (val > hi) { hi = val; idx = (int)i; }
}
return idx;
}
template<unsigned ndim>
vector<2> select(const vector<ndim> &a, int a1, int a2) {
vector<2> r(NOINIT);
r.v[0] = a.v[a1]; r.v[1] = a.v[a2];
return r;
}
template<unsigned ndim>
vector<3> select(const vector<ndim> &a, int a1, int a2, int a3) {
vector<3> r(NOINIT);
r.v[0] = a.v[a1]; r.v[1] = a.v[a2]; r.v[2] = a.v[a3];
return r;
}
template<unsigned ndim, typename assign_t, typename oper_t>
vector<ndim> &assign_op(vector<ndim> &a, const assign_t &t, oper_t op) {
for (unsigned i = 0; i < ndim; ++i) a[i] = op(t[i]);
return a;
}
template<unsigned ndim, typename assign1_t, typename assign2_t, typename oper_t>
vector<ndim> &assign_op(vector<ndim> &a, const assign1_t &t1, const assign2_t &t2, oper_t op) {
for (unsigned i = 0; i < ndim; ++i) a[i] = op(t1[i], t2[i]);
return a;
}
template<unsigned ndim, typename iter_t>
void bounds(iter_t begin, iter_t end, vector<ndim> &min, vector<ndim> &max) {
if (begin == end) {
min.setZero();
max.setZero();
} else {
min = max = *begin;
while (++begin != end) {
vector<ndim> v = *begin;
assign_op(min, min, v, carve::util::min_functor());
assign_op(max, max, v, carve::util::max_functor());
}
}
}
template<unsigned ndim, typename iter_t, typename adapt_t>
void bounds(iter_t begin, iter_t end, adapt_t adapt, vector<ndim> &min, vector<ndim> &max) {
if (begin == end) {
min.setZero();
max.setZero();
} else {
min = max = adapt(*begin);
while (++begin != end) {
vector<ndim> v = adapt(*begin);
assign_op(min, min, v, carve::util::min_functor());
assign_op(max, max, v, carve::util::max_functor());
}
}
}
template<unsigned ndim, typename iter_t>
void centroid(iter_t begin, iter_t end, vector<ndim> &c) {
c.setZero();
int n = 0;
for (; begin != end; ++begin, ++n) { c += *begin; }
c /= double(n);
}
template<unsigned ndim, typename iter_t, typename adapt_t>
void centroid(iter_t begin, iter_t end, adapt_t adapt, vector<ndim> &c) {
c.setZero();
int n = 0;
for (; begin != end; ++begin, ++n) { c += adapt(*begin); }
c /= double(n);
}
template<unsigned ndim, typename val_t>
double dot(const vector<ndim> &a, const val_t &b) {
double r = 0.0;
for (unsigned i = 0; i < ndim; ++i) r += a[i] * b[i];
return r;
}
static inline vector<3> cross(const vector<3> &a, const vector<3> &b) {
// Compute a x b
return VECTOR(+(a.y * b.z - a.z * b.y),
-(a.x * b.z - a.z * b.x),
+(a.x * b.y - a.y * b.x));
}
static inline double cross(const vector<2> &a, const vector<2> &b) {
// Compute a x b
return a.x * b.y - b.x * a.y;
}
static inline double dotcross(const vector<3> &a, const vector<3> &b, const vector<3> &c) {
// Compute a . (b x c)
return
(a.x * b.y * c.z + a.y * b.z * c.x + a.z * b.x * c.y) -
(a.x * c.y * b.z + a.y * c.z * b.x + a.z * c.x * b.y);
}
template<unsigned ndim>
double distance(const axis_pos &a, const vector<ndim> &b) {
return fabs(b[a.axis] - a.pos);
}
template<unsigned ndim>
double distance2(const axis_pos &a, const vector<ndim> &b) {
double r = fabs(b[a.axis] - a.pos);
return r * r;
}
template<unsigned ndim> bool operator<(const axis_pos &a, const vector<ndim> &b) { return a.pos < b[a.axis]; }
template<unsigned ndim> bool operator<(const vector<ndim> &a, const axis_pos &b) { return a[b.axis] < b.pos; }
template<unsigned ndim> bool operator<=(const axis_pos &a, const vector<ndim> &b) { return a.pos <= b[a.axis]; }
template<unsigned ndim> bool operator<=(const vector<ndim> &a, const axis_pos &b) { return a[b.axis] <= b.pos; }
template<unsigned ndim> bool operator>(const axis_pos &a, const vector<ndim> &b) { return a.pos > b[a.axis]; }
template<unsigned ndim> bool operator>(const vector<ndim> &a, const axis_pos &b) { return a[b.axis] > b.pos; }
template<unsigned ndim> bool operator>=(const axis_pos &a, const vector<ndim> &b) { return a.pos >= b[a.axis]; }
template<unsigned ndim> bool operator>=(const vector<ndim> &a, const axis_pos &b) { return a[b.axis] >= b.pos; }
template<unsigned ndim> bool operator==(const axis_pos &a, const vector<ndim> &b) { return a.pos == b[a.axis]; }
template<unsigned ndim> bool operator==(const vector<ndim> &a, const axis_pos &b) { return a[b.axis] == b.pos; }
template<unsigned ndim> bool operator!=(const axis_pos &a, const vector<ndim> &b) { return a.pos != b[a.axis]; }
template<unsigned ndim> bool operator!=(const vector<ndim> &a, const axis_pos &b) { return a[b.axis] != b.pos; }
template<unsigned ndim>
bool ray<ndim>::OK() const {
return !D.isZero();
}
template<unsigned ndim>
ray<ndim> rayThrough(const vector<ndim> &a, const vector<ndim> &b) {
return ray<ndim>(b - a, a);
}
static inline double distance2(const ray<3> &r, const vector<3> &v) {
return cross(r.D, v - r.v).length2() / r.D.length2();
}
static inline double distance(const ray<3> &r, const vector<3> &v) {
return sqrt(distance2(r, v));
}
static inline double distance2(const ray<2> &r, const vector<2> &v) {
double t = cross(r.D, v - r.v);
return (t * t) / r.D.length2();
}
static inline double distance(const ray<2> &r, const vector<2> &v) {
return sqrt(distance2(r, v));
}
template<unsigned ndim>
void linesegment<ndim>::update() {
midpoint = (v2 + v1) / 2.0;
half_length = (v2 - v1) / 2.0;
}
template<unsigned ndim>
bool linesegment<ndim>::OK() const {
return !half_length.isZero();
}
template<unsigned ndim>
void linesegment<ndim>::flip() {
std::swap(v1, v2);
half_length = (v2 - v1) / 2.0;
}
template<unsigned ndim>
aabb<ndim> linesegment<ndim>::getAABB() const {
aabb<ndim> r;
r.fit(v1, v2);
return r;
}
template<unsigned ndim>
linesegment<ndim>::linesegment(const vector_t &_v1, const vector_t &_v2) : v1(_v1), v2(_v2) {
update();
}
template<unsigned ndim>
double distance2(const linesegment<ndim> &l, const vector<ndim> &v) {
vector<ndim> D = l.v2 - l.v1;
double t = dot(v - l.v1, D) / dot(D, D);
if (t <= 0.0) return (v - l.v1).length2();
if (t >= 1.0) return (v - l.v2).length2();
vector<ndim> vc = D * t + l.v1;
return (v - vc).length2();
}
template<unsigned ndim>
double distance(const linesegment<ndim> &l, const vector<ndim> &v) {
return sqrt(distance2(l, v));
}
template<unsigned ndim>
void plane<ndim>::negate() {
N.negate();
d = -d;
}
template<unsigned ndim>
plane<ndim>::plane() {
N.setZero();
N[0] = 1.0;
d= 0.0;
}
template<unsigned ndim>
plane<ndim>::plane(const vector_t &_N, vector_t _p) : N(_N), d(-dot(_p, _N)) {
}
template<unsigned ndim>
plane<ndim>::plane(const vector_t &_N, double _d) : N(_N), d(_d) {
}
template<unsigned ndim>
plane<ndim> operator-(const plane<ndim> &p) {
return plane<ndim>(-p.N, -p.d);
}
template<unsigned ndim, typename val_t>
double distance(const plane<ndim> &plane, const val_t &point) {
return dot(plane.N, point) + plane.d;
}
template<unsigned ndim, typename val_t>
double distance2(const plane<ndim> &plane, const val_t &point) {
double d = distance(plane, point);
return d * d;
}
template<unsigned ndim>
vector<ndim> closestPoint(const plane<ndim> &p, const vector<ndim> &v) {
return v - p.N * (p.d + dot(p.N, v)) / dot(p.N, p.N);
}
template<unsigned ndim>
aabb<ndim> sphere<ndim>::getAABB() const {
aabb<ndim> r;
r.fit(C - r, C + r);
}
template<unsigned ndim>
sphere<ndim>::sphere() {
C.setZero();
r = 1.0;
}
template<unsigned ndim>
sphere<ndim>::sphere(const vector_t &_C, double _r) : C(_C), r(_r) {
}
template<unsigned ndim, typename val_t>
double distance(const sphere<ndim> &sphere, const val_t &point) {
return std::max(0.0, distance(sphere.C, point) - sphere.r);
}
template<unsigned ndim, typename val_t>
double distance2(const sphere<ndim> &sphere, const val_t &point) {
return std::max(0.0, distance2(sphere.C, point) - sphere.r * sphere.r);
}
template<unsigned ndim>
vector<ndim> closestPoint(const sphere<ndim> &sphere, const vector<ndim> &point) {
return (point - sphere.C).normalized() * sphere.r;
}
template<unsigned ndim>
aabb<ndim> tri<ndim>::getAABB() const {
aabb<ndim> aabb;
aabb.fit(v[0], v[1], v[2]);
return aabb;
}
template<unsigned ndim>
tri<ndim>::tri(vector_t _v[3]) {
std::copy(v, v+3, _v);
}
template<unsigned ndim>
tri<ndim>::tri(const vector_t &a, const vector_t &b, const vector_t &c) {
v[0] = a;
v[1] = b;
v[2] = c;
}
template<unsigned ndim>
std::ostream &operator<<(std::ostream &o, const vector<ndim> &v) {
o << v.asStr();
return o;
}
template<unsigned ndim>
std::ostream &operator<<(std::ostream &o, const carve::geom::plane<ndim> &p) {
o << p.N << ";" << p.d;
return o;
}
template<unsigned ndim>
std::ostream &operator<<(std::ostream &o, const carve::geom::sphere<ndim> &sphere) {
o << "{sphere " << sphere.C << ";" << sphere.r << "}";
return o;
}
template<unsigned ndim>
std::ostream &operator<<(std::ostream &o, const carve::geom::tri<ndim> &tri) {
o << "{tri " << tri.v[0] << ";" << tri.v[1] << ";" << tri.v[2] << "}";
return o;
}
template<unsigned ndim>
double distance(const tri<ndim> &tri, const vector<ndim> &pt) {
return distance(closestPoint(tri, pt), pt);
}
template<unsigned ndim>
double distance2(const tri<ndim> &tri, const vector<ndim> &pt) {
return distance2(closestPoint(tri, pt), pt);
}
}
}

View File

@@ -1,4 +0,0 @@
// Copyright 2006 Tobias Sargeant (toby@permuted.net)
// All rights reserved.
#pragma once

View File

@@ -1,425 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
namespace carve {
namespace heap {
namespace detail {
struct ignore_position_t {
template<typename value_t>
void operator()(value_t &val, size_t idx) const {}
};
template<typename random_access_iter_t,
typename distance_t,
typename value_t,
typename pred_t,
typename pos_notifier_t>
void _adjust_heap(random_access_iter_t begin,
distance_t pos,
distance_t len,
value_t val,
pred_t pred,
pos_notifier_t notify) {
const distance_t top = pos;
distance_t child = pos * 2 + 2;
while (child < len) {
if (pred(begin[child], begin[child - 1])) child--;
begin[pos] = begin[child];
notify(begin[pos], pos);
pos = child;
child = pos * 2 + 2;
}
if (child == len) {
child--;
begin[pos] = begin[child];
notify(begin[pos], pos);
pos = child;
}
distance_t parent = (pos - 1) / 2;
while (pos > top && pred(begin[parent], val)) {
begin[pos] = begin[parent];
notify(begin[pos], pos);
pos = parent;
parent = (pos - 1) / 2;
}
begin[pos] = val;
notify(begin[pos], pos);
}
template<typename random_access_iter_t,
typename distance_t,
typename value_t,
typename pred_t,
typename pos_notifier_t>
void _push_heap(random_access_iter_t begin,
distance_t pos,
value_t val,
pred_t pred,
pos_notifier_t notify) {
distance_t parent = (pos - 1) / 2;
while (pos > 0 && pred(begin[parent], val)) {
begin[pos] = begin[parent];
notify(begin[pos], pos);
pos = parent;
parent = (pos - 1) / 2;
}
begin[pos] = val;
notify(begin[pos], pos);
}
template<typename random_access_iter_t,
typename distance_t,
typename pred_t,
typename pos_notifier_t>
void _remove_heap(random_access_iter_t begin,
distance_t pos,
distance_t len,
pred_t pred,
pos_notifier_t notify) {
--len;
if (pos != len) {
typedef typename std::iterator_traits<random_access_iter_t>::value_type value_t;
value_t removed = begin[pos];
_adjust_heap(begin, pos, len, begin[len], pred, notify);
begin[len] = removed;
notify(begin[len], len);
}
}
template<typename random_access_iter_t,
typename distance_t,
typename pred_t,
typename pos_notifier_t>
void _make_heap(random_access_iter_t begin,
distance_t len,
pred_t pred,
pos_notifier_t notify) {
for (distance_t pos = len / 2; pos > 0; ) {
--pos;
_adjust_heap(begin, pos, len, begin[pos], pred, ignore_position_t());
}
for (distance_t pos = 0; pos < len; ++pos) {
notify(begin[pos], pos);
}
}
template<typename random_access_iter_t,
typename distance_t,
typename pred_t>
void _make_heap(random_access_iter_t begin,
distance_t len,
pred_t pred,
ignore_position_t) {
for (distance_t pos = len / 2; pos > 0; ) {
--pos;
_adjust_heap(begin, pos, len, begin[pos], pred, ignore_position_t());
}
}
template<typename random_access_iter_t,
typename distance_t,
typename pred_t>
bool _is_heap(random_access_iter_t begin,
distance_t len,
pred_t pred) {
distance_t parent = 0;
for (distance_t child = 1; child < len; ++child) {
if (pred(begin[parent], begin[child])) {
return false;
}
if (++child == len) break;
if (pred(begin[parent], begin[child])) {
return false;
}
++parent;
}
return true;
}
}
template<typename random_access_iter_t>
void adjust_heap(random_access_iter_t begin,
random_access_iter_t end,
random_access_iter_t pos) {
typedef typename std::iterator_traits<random_access_iter_t>::value_type value_t;
detail::_adjust_heap(begin, pos - begin, end - begin, *pos, std::less<value_t>());
}
template<typename random_access_iter_t,
typename pred_t>
void adjust_heap(random_access_iter_t begin,
random_access_iter_t end,
random_access_iter_t pos,
pred_t pred) {
detail::_adjust_heap(begin, pos - begin, end - begin, *pos, pred);
}
template<typename random_access_iter_t,
typename pred_t,
typename pos_notifier_t>
void adjust_heap(random_access_iter_t begin,
random_access_iter_t end,
random_access_iter_t pos,
pred_t pred,
pos_notifier_t notify) {
detail::_adjust_heap(begin, pos - begin, end - begin, *pos, pred, notify);
}
template<typename random_access_iter_t>
void remove_heap(random_access_iter_t begin,
random_access_iter_t end,
random_access_iter_t pos) {
typedef typename std::iterator_traits<random_access_iter_t>::value_type value_t;
detail::_remove_heap(begin, pos - begin, end - begin, std::less<value_t>(), detail::ignore_position_t());
}
template<typename random_access_iter_t,
typename pred_t>
void remove_heap(random_access_iter_t begin,
random_access_iter_t end,
random_access_iter_t pos,
pred_t pred) {
detail::_remove_heap(begin, pos - begin, end - begin, pred, detail::ignore_position_t());
}
template<typename random_access_iter_t,
typename pred_t,
typename pos_notifier_t>
void remove_heap(random_access_iter_t begin,
random_access_iter_t end,
random_access_iter_t pos,
pred_t pred,
pos_notifier_t notify) {
detail::_remove_heap(begin, pos - begin, end - begin, pred, notify);
}
template<typename random_access_iter_t>
void pop_heap(random_access_iter_t begin,
random_access_iter_t end) {
typedef typename std::iterator_traits<random_access_iter_t>::value_type value_t;
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
detail::_remove_heap(begin, distance_t(0), end - begin, std::less<value_t>(), detail::ignore_position_t());
}
template<typename random_access_iter_t,
typename pred_t>
void pop_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred) {
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
detail::_remove_heap(begin, distance_t(0), end - begin, pred, detail::ignore_position_t());
}
template<typename random_access_iter_t,
typename pred_t,
typename pos_notifier_t>
void pop_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred,
pos_notifier_t notify) {
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
detail::_remove_heap(begin, distance_t(0), end - begin, pred, notify);
}
template<typename random_access_iter_t>
void push_heap(random_access_iter_t begin,
random_access_iter_t end) {
typedef typename std::iterator_traits<random_access_iter_t>::value_type value_t;
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
distance_t pos = end - begin - 1;
detail::_push_heap(begin, pos, begin[pos], std::less<value_t>(), detail::ignore_position_t());
}
template<typename random_access_iter_t,
typename pred_t>
void push_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred) {
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
distance_t pos = end - begin - 1;
detail::_push_heap(begin, pos, begin[pos], pred, detail::ignore_position_t());
}
template<typename random_access_iter_t,
typename pred_t,
typename pos_notifier_t>
void push_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred,
pos_notifier_t notify) {
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
distance_t pos = end - begin - 1;
detail::_push_heap(begin, pos, begin[pos], pred, notify);
}
template<typename random_access_iter_t>
void make_heap(random_access_iter_t begin,
random_access_iter_t end) {
typedef typename std::iterator_traits<random_access_iter_t>::value_type value_t;
detail::_make_heap(begin, end - begin, std::less<value_t>(), detail::ignore_position_t());
}
template<typename random_access_iter_t,
typename pred_t>
void make_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred) {
detail::_make_heap(begin, end - begin, pred, detail::ignore_position_t());
}
template<typename random_access_iter_t,
typename pred_t,
typename pos_notifier_t>
void make_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred,
pos_notifier_t notify) {
detail::_make_heap(begin, end - begin, pred, notify);
}
template<typename random_access_iter_t>
bool is_heap(random_access_iter_t begin,
random_access_iter_t end) {
typedef typename std::iterator_traits<random_access_iter_t>::value_type value_t;
return detail::_is_heap(begin, end - begin, std::less<value_t>());
}
template<typename random_access_iter_t, typename pred_t>
bool is_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred) {
return detail::_is_heap(begin, end - begin, pred);
}
template<typename random_access_iter_t>
void sort_heap(random_access_iter_t begin,
random_access_iter_t end) {
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
typedef typename std::iterator_traits<random_access_iter_t>::value_type value_t;
for (distance_t len = end - begin; len > 1; --len) {
detail::_remove_heap(begin, distance_t(0), len, std::less<value_t>(), detail::ignore_position_t());
}
}
template<typename random_access_iter_t,
typename pred_t>
void sort_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred) {
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
for (distance_t len = end - begin; len > 1; --len) {
detail::_remove_heap(begin, distance_t(0), len, pred, detail::ignore_position_t());
}
}
template<typename random_access_iter_t,
typename pred_t,
typename pos_notifier_t>
void sort_heap(random_access_iter_t begin,
random_access_iter_t end,
pred_t pred,
pos_notifier_t notify) {
typedef typename std::iterator_traits<random_access_iter_t>::difference_type distance_t;
for (distance_t len = end - begin; len > 1; --len) {
detail::_remove_heap(begin, distance_t(0), len, pred, detail::ignore_position_t());
notify(begin[len], len);
}
notify(begin[0], 0);
}
}
}

View File

@@ -1,304 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <map>
#include <string>
#include <carve/carve.hpp>
#include <carve/poly.hpp>
#include <carve/mesh.hpp>
#include <carve/polyline.hpp>
#include <carve/pointset.hpp>
namespace carve {
namespace input {
typedef std::map<std::string, std::string> Options;
static inline Options opts() {
return Options();
}
static inline Options opts(const char **kv) {
Options r;
for (size_t i = 0; kv[i] != NULL; i += 2) {
r[kv[i]] = kv[i+1];
}
return r;
}
static inline Options opts(const std::string &k1, const std::string &v1) {
Options r;
r[k1] = v1;
return r;
}
static inline Options opts(const std::string &k1, const std::string &v1,
const std::string &k2, const std::string &v2) {
Options r;
r[k1] = v1;
r[k2] = v2;
return r;
}
static inline Options opts(const std::string &k1, const std::string &v1,
const std::string &k2, const std::string &v2,
const std::string &k3, const std::string &v3) {
Options r;
r[k1] = v1;
r[k2] = v2;
r[k3] = v3;
return r;
}
static inline bool _bool(const std::string &str, bool _default = false) {
if (str == "true") return true;
if (str == "false") return false;
return _default;
}
struct Data {
Data() {
}
virtual ~Data() {
}
virtual void transform(const carve::math::Matrix & /* transform */) {
}
};
struct VertexData : public Data {
std::vector<carve::geom3d::Vector> points;
VertexData() : Data() {
}
virtual ~VertexData() {
}
virtual void transform(const carve::math::Matrix &transform) {
for (size_t i = 0; i < points.size(); ++i) {
points[i] *= transform;
}
}
size_t addVertex(carve::geom3d::Vector point) {
size_t index = points.size();
points.push_back(point);
return index;
}
inline void reserveVertices(int count) {
points.reserve(count);
}
size_t getVertexCount() const {
return points.size();
}
const carve::geom3d::Vector &getVertex(int index) const {
return points[index];
}
};
struct PolyhedronData : public VertexData {
std::vector<int> faceIndices;
int faceCount;
PolyhedronData() : VertexData(), faceIndices(), faceCount(0) {
}
virtual ~PolyhedronData() {
}
void reserveFaces(int count, int avgFaceSize) {
faceIndices.reserve(faceIndices.size() + count * (1 + avgFaceSize));
}
int getFaceCount() const {
return faceCount;
}
template <typename Iter>
void addFace(Iter begin, Iter end) {
size_t n = std::distance(begin, end);
faceIndices.reserve(faceIndices.size() + n + 1);
faceIndices.push_back(n);
std::copy(begin, end, std::back_inserter(faceIndices));
++faceCount;
}
void addFace(int a, int b, int c) {
faceIndices.push_back(3);
faceIndices.push_back(a);
faceIndices.push_back(b);
faceIndices.push_back(c);
++faceCount;
}
void addFace(int a, int b, int c, int d) {
faceIndices.push_back(4);
faceIndices.push_back(a);
faceIndices.push_back(b);
faceIndices.push_back(c);
faceIndices.push_back(d);
++faceCount;
}
void clearFaces() {
faceIndices.clear();
faceCount = 0;
}
carve::poly::Polyhedron *create(const Options &options) const {
return new carve::poly::Polyhedron(points, faceCount, faceIndices);
}
carve::mesh::MeshSet<3> *createMesh(const Options &options) const {
Options::const_iterator i;
carve::mesh::MeshOptions opts;
i = options.find("avoid_cavities");
if (i != options.end()) {
opts.avoid_cavities(_bool((*i).second));
}
return new carve::mesh::MeshSet<3>(points, faceCount, faceIndices, opts);
}
};
struct PolylineSetData : public VertexData {
typedef std::pair<bool, std::vector<int> > polyline_data_t;
std::list<polyline_data_t> polylines;
PolylineSetData() : VertexData(), polylines() {
}
virtual ~PolylineSetData() {
}
void beginPolyline(bool closed = false) {
polylines.push_back(std::make_pair(closed, std::vector<int>()));
}
void reservePolyline(size_t len) {
polylines.back().second.reserve(len);
}
void addPolylineIndex(int idx) {
polylines.back().second.push_back(idx);
}
carve::line::PolylineSet *create(const Options &options) const {
carve::line::PolylineSet *p = new carve::line::PolylineSet(points);
for (std::list<polyline_data_t>::const_iterator i = polylines.begin();
i != polylines.end();
++i) {
p->addPolyline((*i).first, (*i).second.begin(), (*i).second.end());
}
return p;
}
};
struct PointSetData : public VertexData {
PointSetData() : VertexData() {
}
virtual ~PointSetData() {
}
carve::point::PointSet *create(const Options &options) const {
carve::point::PointSet *p = new carve::point::PointSet(points);
return p;
}
};
class Input {
public:
std::list<Data *> input;
Input() {
}
~Input() {
for (std::list<Data *>::iterator i = input.begin(); i != input.end(); ++i) {
delete (*i);
}
}
void addDataBlock(Data *data) {
input.push_back(data);
}
void transform(const carve::math::Matrix &transform) {
if (transform == carve::math::Matrix::IDENT()) return;
for (std::list<Data *>::iterator i = input.begin(); i != input.end(); ++i) {
(*i)->transform(transform);
}
}
template<typename T>
static inline T *create(Data *d, const Options &options = Options()) {
return NULL;
}
};
template<>
inline carve::mesh::MeshSet<3> *Input::create(Data *d, const Options &options) {
PolyhedronData *p = dynamic_cast<PolyhedronData *>(d);
if (p == NULL) return NULL;
return p->createMesh(options);
}
template<>
inline carve::poly::Polyhedron *Input::create(Data *d, const Options &options) {
PolyhedronData *p = dynamic_cast<PolyhedronData *>(d);
if (p == NULL) return NULL;
return p->create(options);
}
template<>
inline carve::line::PolylineSet *Input::create(Data *d, const Options &options) {
PolylineSetData *p = dynamic_cast<PolylineSetData *>(d);
if (p == NULL) return NULL;
return p->create(options);
}
template<>
inline carve::point::PointSet *Input::create(Data *d, const Options &options) {
PointSetData *p = dynamic_cast<PointSetData *>(d);
if (p == NULL) return NULL;
return p->create(options);
}
}
}

View File

@@ -1,513 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom2d.hpp>
#include <carve/poly.hpp>
#include <carve/mesh.hpp>
#include <carve/csg.hpp>
namespace carve {
namespace interpolate {
static inline std::vector<double> polyInterpolate(const std::vector<carve::geom2d::P2> &s,
const carve::geom2d::P2 &v) {
// see hormann et al. 2006
const size_t SZ = s.size();
std::vector<double> r;
std::vector<double> A;
std::vector<double> D;
std::vector<double> result;
r.resize(SZ);
A.resize(SZ);
D.resize(SZ);
result.resize(SZ, 0.0);
for (size_t i = 0; i < SZ; ++i) {
size_t i2 = (i + 1) % SZ;
carve::geom2d::P2 si = s[i] - v;
carve::geom2d::P2 si2 = s[i2] - v;
r[i] = sqrt(dot(si, si));
A[i] = cross(si, si2) / 2.0;
D[i] = dot(si, si2);
if (fabs(r[i]) < 1e-16) {
result[i] = 1.0;
return result;
} else if (fabs(A[i]) < 1e-16 && D[i] < 0.0) {
double r2 = sqrt(dot(si2, si2));
result[i2] = r[i] / (r[i] + r2);
result[i] = r2 / (r[i] + r2);
return result;
}
}
double w_sum = 0.0;
for (size_t i = 0; i < SZ; ++i) {
size_t i_m = (i + SZ - 1) % SZ;
size_t i_p = (i + 1) % SZ;
double w = 0.0;
if (fabs(A[i_m]) > 1e-16)
w += (r[i_m] - D[i_m] / r[i]) / A[i_m];
if (fabs(A[i]) > 1e-16)
w += (r[i_p] - D[i] / r[i]) / A[i];
result[i] = w;
w_sum += w;
}
for (size_t i = 0; i < SZ; ++i) {
result[i] /= w_sum;
}
// carve::geom2d::P2 test;
// for (size_t i = 0; i < SZ; ++i) {
// test = test + result[i] * s[i];
// }
return result;
}
template<typename iter_t,
typename adapt_t,
typename val_t,
typename mod_t>
val_t interp(iter_t begin,
iter_t end,
adapt_t adapt,
const std::vector<val_t> &vals,
double x,
double y,
mod_t mod = mod_t()) {
std::vector<carve::geom2d::P2> s;
s.reserve(std::distance(begin, end));
std::transform(begin, end, std::back_inserter(s), adapt);
std::vector<double> weight = polyInterpolate(s, carve::geom::VECTOR(x, y));
val_t v;
for (size_t z = 0; z < weight.size(); z++) {
v += weight[z] * vals[z];
}
return mod(v);
}
template<typename iter_t,
typename adapt_t,
typename val_t>
val_t interp(iter_t begin,
iter_t end,
adapt_t adapt,
const std::vector<val_t> &vals,
double x,
double y) {
return interp(begin, end, adapt, vals, x, y, identity_t<val_t>());
}
template<typename vertex_t,
typename adapt_t,
typename val_t,
typename mod_t>
val_t interp(const std::vector<vertex_t> &poly,
adapt_t adapt,
const std::vector<val_t> &vals,
double x,
double y,
mod_t mod = mod_t()) {
return interp(poly.begin(), poly.end(), adapt, vals, x, y, mod);
}
template<typename vertex_t,
typename adapt_t,
typename val_t>
val_t interp(const std::vector<vertex_t> &poly,
adapt_t adapt,
const std::vector<val_t> &vals,
double x,
double y) {
return interp(poly.begin(), poly.end(), adapt, vals, x, y, identity_t<val_t>());
}
template<typename val_t,
typename mod_t>
val_t interp(const std::vector<carve::geom2d::P2> &poly,
const std::vector<val_t> &vals,
double x,
double y,
mod_t mod = mod_t()) {
std::vector<double> weight = polyInterpolate(poly, carve::geom::VECTOR(x, y));
val_t v;
for (size_t z = 0; z < weight.size(); z++) {
v += weight[z] * vals[z];
}
return mod(v);
}
template<typename val_t>
val_t interp(const std::vector<carve::geom2d::P2> &poly,
const std::vector<val_t> &vals,
double x,
double y) {
return interp(poly, vals, x, y, identity_t<val_t>());
}
class Interpolator {
public:
typedef carve::mesh::MeshSet<3> meshset_t;
protected:
friend struct Hook;
struct Hook : public carve::csg::CSG::Hook {
const carve::csg::CSG &csg;
Interpolator *interpolator;
virtual unsigned hookBits() const {
return carve::csg::CSG::Hooks::RESULT_FACE_BIT;
}
virtual void resultFace(const meshset_t::face_t *new_face,
const meshset_t::face_t *orig_face,
bool flipped) {
interpolator->resultFace(csg, new_face, orig_face, flipped);
}
virtual void processOutputFace(std::vector<carve::mesh::MeshSet<3>::face_t *> &new_faces,
const meshset_t::face_t *orig_face,
bool flipped) {
interpolator->processOutputFace(csg, new_faces, orig_face, flipped);
}
virtual void edgeDivision(const meshset_t::edge_t *orig_edge,
size_t orig_edge_idx,
const meshset_t::vertex_t *v1,
const meshset_t::vertex_t *v2) {
interpolator->edgeDivision(csg, orig_edge, orig_edge_idx, v1, v2);
}
Hook(Interpolator *_interpolator, const carve::csg::CSG &_csg) : csg(_csg), interpolator(_interpolator) {
}
virtual ~Hook() {
}
};
virtual Hook *makeHook(carve::csg::CSG &csg) {
return new Hook(this, csg);
}
virtual void resultFace(const carve::csg::CSG &csg,
const meshset_t::face_t *new_face,
const meshset_t::face_t *orig_face,
bool flipped) {
}
virtual void processOutputFace(const carve::csg::CSG &csg,
std::vector<carve::mesh::MeshSet<3>::face_t *> &new_faces,
const meshset_t::face_t *orig_face,
bool flipped) {
}
virtual void edgeDivision(const carve::csg::CSG &csg,
const meshset_t::edge_t *orig_edge,
size_t orig_edge_idx,
const meshset_t::vertex_t *v1,
const meshset_t::vertex_t *v2) {
}
public:
Interpolator() {
}
virtual ~Interpolator() {
}
void installHooks(carve::csg::CSG &csg) {
Hook *hook = makeHook(csg);
csg.hooks.registerHook(hook, hook->hookBits());
}
};
template<typename attr_t>
class FaceVertexAttr : public Interpolator {
public:
typedef std::pair<const meshset_t::face_t *, unsigned> key_t;
protected:
struct key_hash {
size_t operator()(const key_t &v) const {
return size_t(v.first) ^ size_t(v.second);
}
};
typedef std::unordered_map<const meshset_t::vertex_t *, attr_t> attrvmap_t;
typedef std::unordered_map<key_t, attr_t, key_hash> attrmap_t;
attrmap_t attrs;
virtual void resultFace(const carve::csg::CSG &csg,
const meshset_t::face_t *new_face,
const meshset_t::face_t *orig_face,
bool flipped) {
std::vector<attr_t> vertex_attrs;
attrvmap_t base_attrs;
vertex_attrs.reserve(orig_face->nVertices());
for (meshset_t::face_t::const_edge_iter_t e = orig_face->begin(); e != orig_face->end(); ++e) {
typename attrmap_t::const_iterator a = attrs.find(key_t(orig_face, e.idx()));
if (a == attrs.end()) return;
vertex_attrs.push_back((*a).second);
base_attrs[e->vert] = vertex_attrs.back();
}
for (meshset_t::face_t::const_edge_iter_t e = new_face->begin(); e != new_face->end(); ++e) {
const meshset_t::vertex_t *vertex = e->vert;
typename attrvmap_t::const_iterator b = base_attrs.find(vertex);
if (b != base_attrs.end()) {
attrs[key_t(new_face, e.idx())] = (*b).second;
} else {
carve::geom2d::P2 p = orig_face->project(e->vert->v);
attr_t attr = interp(orig_face->begin(),
orig_face->end(),
orig_face->projector(),
vertex_attrs,
p.x,
p.y);
attrs[key_t(new_face, e.idx())] = attr;
}
}
}
public:
bool hasAttribute(const meshset_t::face_t *f, unsigned v) {
return attrs.find(key_t(f, v)) != attrs.end();
}
attr_t getAttribute(const meshset_t::face_t *f, unsigned v, const attr_t &def = attr_t()) {
typename attrmap_t::const_iterator fv = attrs.find(key_t(f, v));
if (fv != attrs.end()) {
return (*fv).second;
}
return def;
}
void setAttribute(const meshset_t::face_t *f, unsigned v, const attr_t &attr) {
attrs[key_t(f, v)] = attr;
}
FaceVertexAttr() : Interpolator() {
}
virtual ~FaceVertexAttr() {
}
};
template<typename attr_t>
class FaceEdgeAttr : public Interpolator {
public:
typedef std::pair<const meshset_t::face_t *, unsigned> key_t;
protected:
typedef std::pair<const meshset_t::vertex_t *, const meshset_t::vertex_t *> vpair_t;
struct key_hash {
size_t operator()(const key_t &v) const {
return size_t(v.first) ^ size_t(v.second);
}
};
struct vpair_hash {
size_t operator()(const vpair_t &v) const {
return size_t(v.first) ^ size_t(v.second);
}
};
typedef std::unordered_map<key_t, attr_t, key_hash> attrmap_t;
typedef std::unordered_map<vpair_t, key_t, vpair_hash> edgedivmap_t;
attrmap_t attrs;
edgedivmap_t edgediv;
struct Hook : public Interpolator::Hook {
public:
virtual unsigned hookBits() const {
return
carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT |
carve::csg::CSG::Hooks::EDGE_DIVISION_BIT;
}
Hook(Interpolator *_interpolator, const carve::csg::CSG &_csg) : Interpolator::Hook(_interpolator, _csg) {
}
virtual ~Hook() {
}
};
virtual Interpolator::Hook *makeHook(carve::csg::CSG &csg) {
return new Hook(this, csg);
}
virtual void edgeDivision(const carve::csg::CSG &csg,
const meshset_t::edge_t *orig_edge,
size_t orig_edge_idx,
const meshset_t::vertex_t *v1,
const meshset_t::vertex_t *v2) {
key_t k(orig_edge->face, orig_edge_idx);
typename attrmap_t::const_iterator attr_i = attrs.find(k);
if (attr_i == attrs.end()) return;
edgediv[vpair_t(v1, v2)] = k;
}
virtual void processOutputFace(const carve::csg::CSG &csg,
std::vector<carve::mesh::MeshSet<3>::face_t *> &new_faces,
const meshset_t::face_t *orig_face,
bool flipped) {
edgedivmap_t undiv;
for (meshset_t::face_t::const_edge_iter_t e = orig_face->begin(); e != orig_face->end(); ++e) {
key_t k(orig_face, e.idx());
typename attrmap_t::const_iterator attr_i = attrs.find(k);
if (attr_i == attrs.end()) {
continue;
} else {
undiv[vpair_t(e->v1(), e->v2())] = k;
}
}
for (size_t fnum = 0; fnum < new_faces.size(); ++fnum) {
const carve::mesh::MeshSet<3>::face_t *new_face = new_faces[fnum];
for (meshset_t::face_t::const_edge_iter_t e = new_face->begin(); e != new_face->end(); ++e) {
key_t k(new_face, e.idx());
vpair_t vp;
if (!flipped) {
vp = vpair_t(e->v1(), e->v2());
} else {
vp = vpair_t(e->v2(), e->v1());
}
typename edgedivmap_t::const_iterator vp_i;
if ((vp_i = undiv.find(vp)) != undiv.end()) {
attrs[k] = attrs[vp_i->second];
} else if ((vp_i = edgediv.find(vp)) != edgediv.end()) {
attrs[k] = attrs[vp_i->second];
}
}
}
}
public:
bool hasAttribute(const meshset_t::face_t *f, unsigned e) {
return attrs.find(std::make_pair(f, e)) != attrs.end();
}
attr_t getAttribute(const meshset_t::face_t *f, unsigned e, const attr_t &def = attr_t()) {
typename attrmap_t::const_iterator fv = attrs.find(std::make_pair(f, e));
if (fv != attrs.end()) {
return (*fv).second;
}
return def;
}
void setAttribute(const meshset_t::face_t *f, unsigned e, const attr_t &attr) {
attrs[std::make_pair(f, e)] = attr;
}
FaceEdgeAttr() : Interpolator() {
}
virtual ~FaceEdgeAttr() {
}
};
template<typename attr_t>
class FaceAttr : public Interpolator {
public:
typedef const meshset_t::face_t *key_t;
protected:
struct key_hash {
size_t operator()(const key_t &f) const {
return size_t(f);
}
};
typedef std::unordered_map<key_t, attr_t, key_hash> attrmap_t;
attrmap_t attrs;
virtual void resultFace(const carve::csg::CSG &csg,
const meshset_t::face_t *new_face,
const meshset_t::face_t *orig_face,
bool flipped) {
typename attrmap_t::const_iterator i = attrs.find(key_t(orig_face));
if (i != attrs.end()) {
attrs[key_t(new_face)] = (*i).second;
}
}
public:
bool hasAttribute(const meshset_t::face_t *f) {
return attrs.find(key_t(f)) != attrs.end();
}
attr_t getAttribute(const meshset_t::face_t *f, const attr_t &def = attr_t()) {
typename attrmap_t::const_iterator i = attrs.find(key_t(f));
if (i != attrs.end()) {
return (*i).second;
}
return def;
}
void setAttribute(const meshset_t::face_t *f, const attr_t &attr) {
attrs[key_t(f)] = attr;
}
FaceAttr() : Interpolator() {
}
virtual ~FaceAttr() {
}
};
}
}

View File

@@ -1,267 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/collection_types.hpp>
#include <carve/iobj.hpp>
namespace carve {
namespace csg {
/**
* \class Intersections
* \brief Storage for computed intersections between vertices, edges and faces.
*
*/
struct Intersections : public std::unordered_map<IObj, IObjVMapSmall, IObj_hash> {
typedef carve::mesh::MeshSet<3>::vertex_t vertex_t;
typedef carve::mesh::MeshSet<3>::edge_t edge_t;
typedef carve::mesh::MeshSet<3>::face_t face_t;
typedef std::unordered_map<IObj, IObjVMapSmall, IObj_hash> super;
~Intersections() {
}
/**
* \brief Record the position of intersection between a pair of intersection objects.
*
* @param a The first intersecting object.
* @param b The second intersecting object.
* @param p The point of intersection.
*/
void record(IObj a, IObj b, vertex_t *p) {
if (a > b) std::swap(a, b);
(*this)[a][b] = p;
(*this)[b][a] = p;
}
/**
* \brief Test whether vertex \a v intersects face \a f.
*
* @param v The vertex to test.
* @param f The face to test.
*
* @return true, if \a v intersects \a f.
*/
bool intersectsFace(vertex_t *v, face_t *f) const;
/**
* \brief Collect sets of vertices, edges and faces that intersect \a obj
*
* @param[in] obj The intersection object to search for intersections.
* @param[out] collect_v A vector of vertices intersecting \a obj.
* @param[out] collect_e A vector of edges intersecting \a obj.
* @param[out] collect_f A vector of faces intersecting \a obj.
*/
void collect(const IObj &obj,
std::vector<vertex_t *> *collect_v,
std::vector<edge_t *> *collect_e,
std::vector<face_t *> *collect_f) const;
/**
* \brief Determine whether two intersection objects intersect.
*
* @param a The first intersection object.
* @param b The second intersection object.
*
* @return true, if \a a and \a b intersect.
*/
bool intersectsExactly(const IObj &a, const IObj &b) {
Intersections::const_iterator i = find(a);
if (i == end()) return false;
return i->second.find(b) != i->second.end();
}
/**
* \brief Determine whether an intersection object intersects a vertex.
*
* @param a The intersection object.
* @param v The vertex.
*
* @return true, if \a a and \a v intersect.
*/
bool intersects(const IObj &a, vertex_t *v) {
Intersections::const_iterator i = find(a);
if (i == end()) return false;
if (i->second.find(v) != i->second.end()) return true;
return false;
}
/**
* \brief Determine whether an intersection object intersects an edge.
*
* @param a The intersection object.
* @param e The edge.
*
* @return true, if \a a and \a e intersect (either on the edge,
* or at either endpoint).
*/
bool intersects(const IObj &a, edge_t *e) {
Intersections::const_iterator i = find(a);
if (i == end()) return false;
for (super::data_type::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
const IObj &obj = j->first;
switch (obj.obtype) {
case IObj::OBTYPE_VERTEX:
if (obj.vertex == e->v1() || obj.vertex == e->v2()) return true;
break;
case IObj::OBTYPE_EDGE:
if (obj.edge == e) return true;
break;
default:
break;
}
}
return false;
}
/**
* \brief Determine whether an intersection object intersects a face.
*
* @param a The intersection object.
* @param f The face.
*
* @return true, if \a a and \a f intersect (either on the face,
* or at any associated edge or vertex).
*/
bool intersects(const IObj &a, face_t *f) {
Intersections::const_iterator i = find(a);
if (i == end()) return false;
if (i->second.find(f) != i->second.end()) return true;
edge_t *e = f->edge;
do {
if (i->second.find(e) != i->second.end()) return true;
if (i->second.find(e->vert) != i->second.end()) return true;
e = e->next;
} while (e != f->edge);
return false;
}
/**
* \brief Determine whether an edge intersects another edge.
*
* @param e The edge.
* @param f The face.
*
* @return true, if \a e and \a f intersect.
*/
bool intersects(edge_t *e1, edge_t *e2) {
if (intersects(e1->v1(), e2) || intersects(e1->v2(), e2) || intersects(IObj(e1), e2)) return true;
return false;
}
/**
* \brief Determine whether an edge intersects a face.
*
* @param e The edge.
* @param f The face.
*
* @return true, if \a e and \a f intersect.
*/
bool intersects(edge_t *e, face_t *f) {
if (intersects(e->v1(), f) || intersects(e->v2(), f) || intersects(IObj(e), f)) return true;
return false;
}
/**
* \brief Determine the faces intersected by an edge.
*
* @tparam face_set_t A collection type holding face_t *
* @param[in] e The edge.
* @param[out] f The resulting set of faces.
*/
template<typename face_set_t>
void intersectedFaces(edge_t *e, face_set_t &f) const {
std::vector<face_t *> intersected_faces;
std::vector<edge_t *> intersected_edges;
std::vector<vertex_t *> intersected_vertices;
collect(e, &intersected_vertices, &intersected_edges, &intersected_faces);
for (unsigned i = 0; i < intersected_vertices.size(); ++i) {
facesForVertex(intersected_vertices[i], f);
}
for (unsigned i = 0; i < intersected_edges.size(); ++i) {
facesForEdge(intersected_edges[i], f);
}
f.insert(intersected_faces.begin(), intersected_faces.end());
}
/**
* \brief Determine the faces intersected by a vertex.
*
* @tparam face_set_t A collection type holding face_t *
* @param[in] v The vertex.
* @param[out] f The resulting set of faces.
*/
template<typename face_set_t>
void intersectedFaces(vertex_t *v, face_set_t &f) const {
std::vector<face_t *> intersected_faces;
std::vector<edge_t *> intersected_edges;
std::vector<vertex_t *> intersected_vertices;
collect(v, &intersected_vertices, &intersected_edges, &intersected_faces);
for (unsigned i = 0; i < intersected_vertices.size(); ++i) {
facesForVertex(intersected_vertices[i], f);
}
for (unsigned i = 0; i < intersected_edges.size(); ++i) {
facesForEdge(intersected_edges[i], f);
}
f.insert(intersected_faces.begin(), intersected_faces.end());
}
/**
* \brief Collect the set of faces that contain all vertices in \a verts.
*
* @tparam vertex_set_t A collection type holding vertex_t *
* @tparam face_set_t A collection type holding face_t *
* @param[in] verts A set of vertices.
* @param[out] result The resulting set of faces.
*/
template<typename vertex_set_t, typename face_set_t>
void commonFaces(const vertex_set_t &verts, face_set_t &result) {
std::set<face_t *> ifaces, temp, out;
typename vertex_set_t::const_iterator i = verts.begin();
if (i == verts.end()) return;
intersectedFaces((*i), ifaces);
while (++i != verts.end()) {
temp.clear();
intersectedFaces((*i), temp);
out.clear();
std::set_intersection(temp.begin(), temp.end(),
ifaces.begin(), ifaces.end(),
set_inserter(out));
ifaces.swap(out);
}
std::copy(ifaces.begin(), ifaces.end(), set_inserter(result));
}
void clear() {
super::clear();
}
};
}
}

View File

@@ -1,106 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
namespace carve {
namespace csg {
struct IObj {
enum {
OBTYPE_NONE = 0,
OBTYPE_VERTEX = 1,
OBTYPE_EDGE = 2,
OBTYPE_FACE = 4
} obtype;
union {
carve::mesh::MeshSet<3>::vertex_t *vertex;
carve::mesh::MeshSet<3>::edge_t *edge;
carve::mesh::MeshSet<3>::face_t *face;
intptr_t val;
};
IObj() : obtype(OBTYPE_NONE), val(0) { }
IObj(carve::mesh::MeshSet<3>::vertex_t *v) : obtype(OBTYPE_VERTEX), vertex(v) { }
IObj(carve::mesh::MeshSet<3>::edge_t *e) : obtype(OBTYPE_EDGE), edge(e) { }
IObj(carve::mesh::MeshSet<3>::face_t *f) : obtype(OBTYPE_FACE), face(f) { }
char typeChar() const { return "NVExF"[obtype]; }
};
struct IObj_hash {
inline size_t operator()(const IObj &i) const {
return (size_t)i.val;
}
inline size_t operator()(const std::pair<const IObj, const IObj> &i) const {
return (size_t)i.first.val ^ (size_t)i.second.val;
}
};
typedef std::unordered_set<std::pair<const IObj, const IObj>, IObj_hash> IObjPairSet;
typedef std::unordered_map<IObj, carve::mesh::MeshSet<3>::vertex_t *, IObj_hash> IObjVMap;
typedef std::map<IObj, carve::mesh::MeshSet<3>::vertex_t *> IObjVMapSmall;
class VertexIntersections :
public std::unordered_map<carve::mesh::MeshSet<3>::vertex_t *, IObjPairSet> {
};
static inline bool operator==(const carve::csg::IObj &a, const carve::csg::IObj &b) {
return a.obtype == b.obtype && a.val == b.val;
}
static inline bool operator!=(const carve::csg::IObj &a, const carve::csg::IObj &b) {
return a.obtype != b.obtype || a.val != b.val;
}
static inline bool operator<(const carve::csg::IObj &a, const carve::csg::IObj &b) {
return a.obtype < b.obtype || (a.obtype == b.obtype && a.val < b.val);
}
static inline bool operator<=(const carve::csg::IObj &a, const carve::csg::IObj &b) {
return a.obtype < b.obtype || (a.obtype == b.obtype && a.val <= b.val);
}
static inline bool operator>(const carve::csg::IObj &a, const carve::csg::IObj &b) {
return a.obtype > b.obtype || (a.obtype == b.obtype && a.val > b.val);
}
static inline bool operator>=(const carve::csg::IObj &a, const carve::csg::IObj &b) {
return a.obtype > b.obtype || (a.obtype == b.obtype && a.val >= b.val);
}
static inline std::ostream &operator<<(std::ostream &o, const carve::csg::IObj &a) {
switch (a.obtype) {
case carve::csg::IObj::OBTYPE_NONE: o << "NONE{}"; break;
case carve::csg::IObj::OBTYPE_VERTEX: o << "VERT{" << a.vertex << "}"; break;
case carve::csg::IObj::OBTYPE_EDGE: o << "EDGE{" << a.edge << "}"; break;
case carve::csg::IObj::OBTYPE_FACE: o << "FACE{" << a.face << "}"; break;
}
return o;
}
}
}

View File

@@ -1,308 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom.hpp>
#include <carve/aabb.hpp>
#include <queue>
#include <list>
#include <limits>
namespace carve {
namespace geom {
template<unsigned ndim,
typename data_t,
typename inserter_t,
typename aabb_calc_t>
class kd_node {
kd_node(const kd_node &);
kd_node &operator=(const kd_node &);
public:
kd_node *c_neg;
kd_node *c_pos;
kd_node *parent;
axis_pos splitpos;
typedef vector<ndim> vector_t;
typedef std::list<data_t> container_t;
container_t data;
kd_node(kd_node *_parent = NULL) : c_neg(NULL), c_pos(NULL), parent(_parent), splitpos(0, 0.0) {
}
~kd_node() {
if (c_neg) delete c_neg;
if (c_pos) delete c_pos;
}
template<typename visitor_t>
void closeNodes(const vector_t &p, double d, visitor_t &visit) const {
if (c_neg) {
double delta = splitpos.pos - p[splitpos.axis];
if (delta <= d) c_neg->closeNodes(p, d, visit);
if (delta >= -d) c_pos->closeNodes(p, d, visit);
} else {
visit(this);
}
}
void removeData(const data_t &d) {
typename container_t::iterator i = std::find(data.begin(), data.end(), d);
if (i != data.end()) {
data.erase(i);
}
}
void addData(const data_t &d) {
data.push_back(d);
}
void insert(const data_t &data, inserter_t &inserter) {
inserter.insert(this, data);
}
void insert(const data_t &data) {
inserter_t inserter;
insert(data, inserter);
}
void remove(const data_t &data, inserter_t &inserter) {
inserter.remove(this, data);
}
void remove(const data_t &data) {
inserter_t inserter;
remove(data, inserter);
}
carve::geom::aabb<ndim> nodeAABB() const {
carve::geom::aabb<ndim> aabb;
if (c_neg) {
aabb = c_neg->nodeAABB();
aabb.unionAABB(c_pos->nodeAABB());
} else {
if (data.size()) {
typename container_t::const_iterator i = data.begin();
aabb = aabb_calc_t()(*i);
while (i != data.end()) {
aabb.unionAABB(aabb_calc_t()(*i));
++i;
}
}
}
return aabb;
}
bool split(axis_pos split_at, inserter_t &inserter) {
if (c_neg) {
// already split
return false;
}
c_neg = new kd_node(this);
c_pos = new kd_node(this);
// choose an axis and split point.
splitpos = split_at;
carve::geom::aabb<ndim> aabb;
if (splitpos.axis < 0 ||
splitpos.axis >= ndim ||
splitpos.pos == std::numeric_limits<double>::max()) {
// need an aabb
if (data.size()) {
typename container_t::const_iterator i = data.begin();
aabb = aabb_calc_t()(*i);
while (i != data.end()) {
aabb.unionAABB(aabb_calc_t()(*i));
++i;
}
}
}
if (splitpos.axis < 0 || splitpos.axis >= ndim) {
// choose an axis;
// if no axis was specified, force calculation of the split position.
splitpos.pos = std::numeric_limits<double>::max();
// choose the axis of the AABB with the biggest extent.
splitpos.axis = largestAxis(aabb.extent);
if (parent && splitpos.axis == parent->splitpos.axis) {
// but don't choose the same axis as the parent node;
// choose the axis with the second greatest AABB extent.
double e = -1.0;
int a = -1;
for (int i = 0; i < ndim; ++i) {
if (i == splitpos.axis) continue;
if (e < aabb.extent[i]) { a = i; e = aabb.extent[i]; }
}
if (a != -1) {
splitpos.axis = a;
}
}
}
if (splitpos.pos == std::numeric_limits<double>::max()) {
carve::geom::vector<ndim> min = aabb.min();
carve::geom::vector<ndim> max = aabb.max();
splitpos.pos = aabb.pos.v[splitpos.axis];
}
inserter.propagate(this);
return true;
}
bool split(axis_pos split_at = axis_pos(-1, std::numeric_limits<double>::max())) {
inserter_t inserter;
return split(split_at, inserter);
}
void splitn(int num, inserter_t &inserter) {
if (num <= 0) return;
if (!c_neg) {
split(inserter);
}
if (c_pos) c_pos->splitn(num-1, inserter);
if (c_neg) c_neg->splitn(num-1, inserter);
}
void splitn(int num) {
inserter_t inserter;
splitn(num, inserter);
}
template<typename split_t>
void splitn(int num, split_t splitter, inserter_t &inserter) {
if (num <= 0) return;
if (!c_neg) {
split(inserter, splitter(this));
}
if (c_pos) c_pos->splitn(num-1, inserter, splitter);
if (c_neg) c_neg->splitn(num-1, inserter, splitter);
}
template<typename split_t>
void splitn(int num, split_t splitter) {
inserter_t inserter;
splitn(num, splitter, inserter);
}
template<typename pred_t>
void splitpred(pred_t pred, inserter_t &inserter, int depth = 0) {
if (!c_neg) {
axis_pos splitpos(-1, std::numeric_limits<double>::max());
if (!pred(this, depth, splitpos)) return;
split(splitpos, inserter);
}
if (c_pos) c_pos->splitpred(pred, inserter, depth + 1);
if (c_neg) c_neg->splitpred(pred, inserter, depth + 1);
}
template<typename pred_t>
void splitpred(pred_t pred, int depth = 0) {
inserter_t inserter;
splitpred(pred, inserter, depth);
}
// distance_t must provide:
// double operator()(data_t, vector<ndim>);
// double operator()(axis_pos, vector<ndim>);
template<typename distance_t>
struct near_point_query {
// q_t - the priority queue value type.
// q_t.first: distance from object to query point.
// q_t.second: pointer to object
typedef std::pair<double, const data_t *> q_t;
// the queue priority should sort from smallest distance to largest, and on equal distance, by object pointer.
struct pcmp {
bool operator()(const q_t &a, const q_t &b) {
return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
}
};
vector<ndim> point;
const kd_node *node;
std::priority_queue<q_t, std::vector<q_t>, pcmp> pq;
distance_t dist;
double dist_to_parent_split;
void addToPQ(kd_node *node) {
if (node->c_neg) {
addToPQ(node->c_neg);
addToPQ(node->c_pos);
} else {
for (typename kd_node::container_t::const_iterator i = node->data.begin(); i != node->data.end(); ++i) {
double d = dist((*i), point);
pq.push(std::make_pair(d, &(*i)));
}
}
}
const data_t *next() {
while (1) {
if (pq.size()) {
q_t t = pq.top();
if (!node->parent || t.first < dist_to_parent_split) {
pq.pop();
return t.second;
}
}
if (!node->parent) return NULL;
if (node->parent->c_neg == node) {
addToPQ(node->parent->c_pos);
} else {
addToPQ(node->parent->c_neg);
}
node = node->parent;
dist_to_parent_split = dist(node->splitpos, point);
}
}
near_point_query(const vector<ndim> _point, const kd_node *_node) : point(_point), node(_node), pq(), dist() {
while (node->c_neg) {
node = (point[node->axis] < node->pos) ? node->c_neg : node->c_pos;
}
if (node->parent) {
dist_to_parent_split = dist(node->parent->splitpos, point);
} else {
dist_to_parent_split = HUGE_VAL;
}
addToPQ(node);
}
};
};
}
}

View File

@@ -1,60 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/math_constants.hpp>
#include <math.h>
namespace carve {
namespace geom {
template<unsigned ndim> struct vector;
}
}
namespace carve {
namespace math {
struct Matrix3;
int cubic_roots(double c3, double c2, double c1, double c0, double *roots);
void eigSolveSymmetric(const Matrix3 &m,
double &l1, carve::geom::vector<3> &e1,
double &l2, carve::geom::vector<3> &e2,
double &l3, carve::geom::vector<3> &e3);
void eigSolve(const Matrix3 &m, double &l1, double &l2, double &l3);
static inline bool ZERO(double x) { return fabs(x) < carve::EPSILON; }
static inline double radians(double deg) { return deg * M_PI / 180.0; }
static inline double degrees(double rad) { return rad * 180.0 / M_PI; }
static inline double ANG(double x) {
return (x < 0) ? x + M_TWOPI : x;
}
template<typename T>
static inline const T &clamp(const T &val, const T &min, const T &max) {
if (val < min) return min;
if (val > max) return max;
return val;
}
}
}

View File

@@ -1,33 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <math.h>
#ifndef M_SQRT_3
#define M_SQRT_3 1.73205080756887729352
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_TWOPI
#define M_TWOPI (M_PI + M_PI)
#endif

View File

@@ -1,262 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <cstring>
#include <carve/carve.hpp>
#include <carve/math.hpp>
#include <carve/geom.hpp>
namespace carve {
namespace math {
struct Quaternion {
double x, y, z, w;
Quaternion(double _x, double _y, double _z, double _w) : x(_x), y(_y), z(_z), w(_w) {
}
Quaternion(double angle, const carve::geom::vector<3> &axis) {
double s = axis.length();
if (!carve::math::ZERO(s)) {
double c = 1.0 / s;
double omega = -0.5 * angle;
s = sin(omega);
x = axis.x * c * s;
y = axis.y * c * s;
z = axis.z * c * s;
w = cos(omega);
normalize();
} else {
x = y = z = 0.0;
w = 1.0;
}
}
double lengthSquared() const {
return x * x + y * y + z * z + w * w;
}
double length() const {
return sqrt(lengthSquared());
}
Quaternion normalized() const {
return Quaternion(*this).normalize();
}
Quaternion &normalize() {
double l = length();
if (l == 0.0) {
x = 1.0; y = 0.0; z = 0.0; w = 0.0;
} else {
x /= l; y /= l; z /= l; w /= l;
}
return *this;
}
};
struct Matrix3 {
// access: .m[col][row], .v[col * 4 + row], ._cr
union {
double m[3][3];
double v[9];
struct {
// transposed
double _11, _12, _13;
double _21, _22, _23;
double _31, _32, _33;
};
};
Matrix3(double __11, double __21, double __31,
double __12, double __22, double __32,
double __13, double __23, double __33) {
// nb, args are row major, storage is column major.
_11 = __11; _12 = __12; _13 = __13;
_21 = __21; _22 = __22; _23 = __23;
_31 = __31; _32 = __32; _33 = __33;
}
Matrix3(double _m[3][3]) {
std::memcpy(m, _m, sizeof(m));
}
Matrix3(double _v[9]) {
std::memcpy(v, _v, sizeof(v));
}
Matrix3() {
_11 = 1.00; _12 = 0.00; _13 = 0.00;
_21 = 0.00; _22 = 1.00; _23 = 0.00;
_31 = 0.00; _32 = 0.00; _33 = 1.00;
}
};
struct Matrix {
// access: .m[col][row], .v[col * 4 + row], ._cr
union {
double m[4][4];
double v[16];
struct {
// transposed
double _11, _12, _13, _14;
double _21, _22, _23, _24;
double _31, _32, _33, _34;
double _41, _42 ,_43, _44;
};
};
Matrix(double __11, double __21, double __31, double __41,
double __12, double __22, double __32, double __42,
double __13, double __23, double __33, double __43,
double __14, double __24, double __34, double __44) {
// nb, args are row major, storage is column major.
_11 = __11; _12 = __12; _13 = __13; _14 = __14;
_21 = __21; _22 = __22; _23 = __23; _24 = __24;
_31 = __31; _32 = __32; _33 = __33; _34 = __34;
_41 = __41; _42 = __42; _43 = __43; _44 = __44;
}
Matrix(double _m[4][4]) {
std::memcpy(m, _m, sizeof(m));
}
Matrix(double _v[16]) {
std::memcpy(v, _v, sizeof(v));
}
Matrix() {
_11 = 1.00; _12 = 0.00; _13 = 0.00; _14 = 0.00;
_21 = 0.00; _22 = 1.00; _23 = 0.00; _24 = 0.00;
_31 = 0.00; _32 = 0.00; _33 = 1.00; _34 = 0.00;
_41 = 0.00; _42 = 0.00; _43 = 0.00; _44 = 1.00;
}
static Matrix ROT(const Quaternion &q) {
const double w = q.w;
const double x = q.x;
const double y = q.y;
const double z = q.z;
return Matrix(1 - 2*y*y - 2*z*z, 2*x*y - 2*z*w, 2*x*z + 2*y*w, 0.0,
2*x*y + 2*z*w, 1 - 2*x*x - 2*z*z, 2*y*z - 2*x*w, 0.0,
2*x*z - 2*y*w, 2*y*z + 2*x*w, 1 - 2*x*x - 2*y*y, 0.0,
0.0, 0.0, 0.0, 1.0);
}
static Matrix ROT(double angle, const carve::geom::vector<3> &axis) {
return ROT(Quaternion(angle, axis));
}
static Matrix ROT(double angle, double x, double y, double z) {
return ROT(Quaternion(angle, carve::geom::VECTOR(x, y, z)));
}
static Matrix TRANS(double x, double y, double z) {
return Matrix(1.0, 0.0, 0.0, x,
0.0, 1.0, 0.0, y,
0.0, 0.0, 1.0, z,
0.0, 0.0, 0.0, 1.0);
}
static Matrix TRANS(const carve::geom::vector<3> &v) {
return TRANS(v.x, v.y, v.z);
}
static Matrix SCALE(double x, double y, double z) {
return Matrix(x, 0.0, 0.0, 0.0,
0.0, y, 0.0, 0.0,
0.0, 0.0, z, 0.0,
0.0, 0.0, 0.0, 1.0);
}
static Matrix SCALE(const carve::geom::vector<3> &v) {
return SCALE(v.x, v.y, v.z);
}
static Matrix IDENT() {
return Matrix(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
}
};
static inline bool operator==(const Matrix &A, const Matrix &B) {
for (size_t i = 0; i < 16; ++i) if (A.v[i] != B.v[i]) return false;
return true;
}
static inline bool operator!=(const Matrix &A, const Matrix &B) {
return !(A == B);
}
static inline carve::geom::vector<3> operator*(const Matrix &A, const carve::geom::vector<3> &b) {
return carve::geom::VECTOR(
A._11 * b.x + A._21 * b.y + A._31 * b.z + A._41,
A._12 * b.x + A._22 * b.y + A._32 * b.z + A._42,
A._13 * b.x + A._23 * b.y + A._33 * b.z + A._43
);
}
static inline carve::geom::vector<3> &operator*=(carve::geom::vector<3> &b, const Matrix &A) {
b = A * b;
return b;
}
static inline carve::geom::vector<3> operator*(const Matrix3 &A, const carve::geom::vector<3> &b) {
return carve::geom::VECTOR(
A._11 * b.x + A._21 * b.y + A._31 * b.z,
A._12 * b.x + A._22 * b.y + A._32 * b.z,
A._13 * b.x + A._23 * b.y + A._33 * b.z
);
}
static inline carve::geom::vector<3> &operator*=(carve::geom::vector<3> &b, const Matrix3 &A) {
b = A * b;
return b;
}
static inline Matrix operator*(const Matrix &A, const Matrix &B) {
Matrix c;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
c.m[i][j] = 0.0;
for (int k = 0; k < 4; k++) {
c.m[i][j] += A.m[k][j] * B.m[i][k];
}
}
}
return c;
}
static inline Matrix3 operator*(const Matrix3 &A, const Matrix3 &B) {
Matrix3 c;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
c.m[i][j] = 0.0;
for (int k = 0; k < 3; k++) {
c.m[i][j] += A.m[k][j] * B.m[i][k];
}
}
}
return c;
}
struct matrix_transformation {
Matrix matrix;
matrix_transformation(const Matrix &_matrix) : matrix(_matrix) {
}
carve::geom::vector<3> operator()(const carve::geom::vector<3> &vector) const {
return matrix * vector;
}
};
}
}

View File

@@ -1,874 +0,0 @@
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom.hpp>
#include <carve/geom3d.hpp>
#include <carve/tag.hpp>
#include <carve/djset.hpp>
#include <carve/aabb.hpp>
#include <carve/rtree.hpp>
#include <iostream>
namespace carve {
namespace poly {
class Polyhedron;
}
namespace mesh {
template<unsigned ndim> class Edge;
template<unsigned ndim> class Face;
template<unsigned ndim> class Mesh;
template<unsigned ndim> class MeshSet;
// A Vertex may participate in several meshes. If the Mesh belongs
// to a MeshSet, then the vertices come from the vertex_storage
// member of the MeshSet. This allows one to construct one or more
// Meshes out of sets of connected faces (possibly using vertices
// from a variety of MeshSets, and other storage), then create a
// MeshSet from the Mesh(es), causing the vertices to be
// collected, cloned and repointed into the MeshSet.
// Normally, in a half-edge structure, Vertex would have a member
// pointing to an incident edge, allowing the enumeration of
// adjacent faces and edges. Because we want to support vertex
// sharing between Meshes and groups of Faces, this is made more
// complex. If Vertex contained a list of incident edges, one from
// each disjoint face set, then this could be done (with the
// caveat that you'd need to pass in a Mesh pointer to the
// adjacency queries). However, it seems that this would
// unavoidably complicate the process of incorporating or removing
// a vertex into an edge.
// In most cases it is expected that a vertex will be arrived at
// via an edge or face in the mesh (implicit or explicit) of
// interest, so not storing this information will not hurt,
// overly.
template<unsigned ndim>
class Vertex : public tagable {
public:
typedef carve::geom::vector<ndim> vector_t;
typedef MeshSet<ndim> owner_t;
typedef carve::geom::aabb<ndim> aabb_t;
carve::geom::vector<ndim> v;
Vertex(const vector_t &_v) : tagable(), v(_v) {
}
Vertex() : tagable(), v() {
}
aabb_t getAABB() const {
return aabb_t(v, carve::geom::vector<ndim>::ZERO());
}
};
struct hash_vertex_pair {
template<unsigned ndim>
size_t operator()(const std::pair<Vertex<ndim> *, Vertex<ndim> *> &pair) const {
size_t r = (size_t)pair.first;
size_t s = (size_t)pair.second;
return r ^ ((s >> 16) | (s << 16));
}
template<unsigned ndim>
size_t operator()(const std::pair<const Vertex<ndim> *, const Vertex<ndim> *> &pair) const {
size_t r = (size_t)pair.first;
size_t s = (size_t)pair.second;
return r ^ ((s >> 16) | (s << 16));
}
};
struct vertex_distance {
template<unsigned ndim>
double operator()(const Vertex<ndim> &a, const Vertex<ndim> &b) const {
return carve::geom::distance(a.v, b.v);
}
template<unsigned ndim>
double operator()(const Vertex<ndim> *a, const Vertex<ndim> *b) const {
return carve::geom::distance(a->v, b->v);
}
};
namespace detail {
template<typename list_t> struct list_iter_t;
template<typename list_t, typename mapping_t> struct mapped_list_iter_t;
}
// The half-edge structure proper (Edge) is maintained by Face
// instances. Together with Face instances, the half-edge
// structure defines a simple mesh (either one or two faces
// incident on each edge).
template<unsigned ndim>
class Edge : public tagable {
public:
typedef Vertex<ndim> vertex_t;
typedef Face<ndim> face_t;
vertex_t *vert;
face_t *face;
Edge *prev, *next, *rev;
private:
static void _link(Edge *a, Edge *b) {
a->next = b; b->prev = a;
}
static void _freeloop(Edge *s) {
Edge *e = s;
do {
Edge *n = e->next;
delete e;
e = n;
} while (e != s);
}
static void _setloopface(Edge *s, face_t *f) {
Edge *e = s;
do {
e->face = f;
e = e->next;
} while (e != s);
}
static size_t _looplen(Edge *s) {
Edge *e = s;
face_t *f = s->face;
size_t c = 0;
do {
++c;
CARVE_ASSERT(e->rev->rev == e);
CARVE_ASSERT(e->next->prev == e);
CARVE_ASSERT(e->face == f);
e = e->next;
} while (e != s);
return c;
}
public:
void validateLoop() {
Edge *e = this;
face_t *f = face;
size_t c = 0;
do {
++c;
CARVE_ASSERT(e->rev == NULL || e->rev->rev == e);
CARVE_ASSERT(e->next == e || e->next->vert != e->vert);
CARVE_ASSERT(e->prev == e || e->prev->vert != e->vert);
CARVE_ASSERT(e->next->prev == e);
CARVE_ASSERT(e->prev->next == e);
CARVE_ASSERT(e->face == f);
e = e->next;
} while (e != this);
CARVE_ASSERT(f == NULL || c == f->n_edges);
}
size_t loopLen() {
return _looplen(this);
}
Edge *mergeFaces();
Edge *removeHalfEdge();
// Remove and delete this edge.
Edge *removeEdge();
// Unlink this edge from its containing edge loop. disconnect
// rev links. The rev links of the previous edge also change, as
// its successor vertex changes.
void unlink();
// Insert this edge into a loop before other. If edge was
// already in a loop, it needs to be removed first.
void insertBefore(Edge *other);
// Insert this edge into a loop after other. If edge was
// already in a loop, it needs to be removed first.
void insertAfter(Edge *other);
size_t loopSize() const;
vertex_t *v1() { return vert; }
vertex_t *v2() { return next->vert; }
const vertex_t *v1() const { return vert; }
const vertex_t *v2() const { return next->vert; }
Edge *perimNext() const;
Edge *perimPrev() const;
double length2() const {
return (v1()->v - v2()->v).length2();
}
double length() const {
return (v1()->v - v2()->v).length();
}
Edge(vertex_t *_vert, face_t *_face);
~Edge();
};
// A Face contains a pointer to the beginning of the half-edge
// circular list that defines its boundary.
template<unsigned ndim>
class Face : public tagable {
public:
typedef Vertex<ndim> vertex_t;
typedef Edge<ndim> edge_t;
typedef Mesh<ndim> mesh_t;
typedef typename Vertex<ndim>::vector_t vector_t;
typedef carve::geom::aabb<ndim> aabb_t;
typedef carve::geom::plane<ndim> plane_t;
typedef carve::geom::vector<2> (*project_t)(const vector_t &);
typedef vector_t (*unproject_t)(const carve::geom::vector<2> &, const plane_t &);
struct vector_mapping {
typedef typename vertex_t::vector_t value_type;
value_type operator()(const carve::geom::vector<ndim> &v) const { return v; }
value_type operator()(const carve::geom::vector<ndim> *v) const { return *v; }
value_type operator()(const Edge<ndim> &e) const { return e.vert->v; }
value_type operator()(const Edge<ndim> *e) const { return e->vert->v; }
value_type operator()(const Vertex<ndim> &v) const { return v.v; }
value_type operator()(const Vertex<ndim> *v) const { return v->v; }
};
struct projection_mapping {
typedef carve::geom::vector<2> value_type;
project_t proj;
projection_mapping(project_t _proj) : proj(_proj) { }
value_type operator()(const carve::geom::vector<ndim> &v) const { return proj(v); }
value_type operator()(const carve::geom::vector<ndim> *v) const { return proj(*v); }
value_type operator()(const Edge<ndim> &e) const { return proj(e.vert->v); }
value_type operator()(const Edge<ndim> *e) const { return proj(e->vert->v); }
value_type operator()(const Vertex<ndim> &v) const { return proj(v.v); }
value_type operator()(const Vertex<ndim> *v) const { return proj(v->v); }
};
edge_t *edge;
size_t n_edges;
mesh_t *mesh;
size_t id;
plane_t plane;
project_t project;
unproject_t unproject;
private:
Face &operator=(const Face &other);
protected:
Face() : edge(NULL), n_edges(0), mesh(NULL), id(0), plane(), project(NULL), unproject(NULL) {
}
Face(const Face &other) :
edge(NULL), n_edges(other.n_edges), mesh(NULL), id(other.id),
plane(other.plane), project(other.project), unproject(other.unproject) {
}
project_t getProjector(bool positive_facing, int axis) const;
unproject_t getUnprojector(bool positive_facing, int axis) const;
public:
typedef detail::list_iter_t<Edge<ndim> > edge_iter_t;
typedef detail::list_iter_t<const Edge<ndim> > const_edge_iter_t;
edge_iter_t begin() { return edge_iter_t(edge, 0); }
edge_iter_t end() { return edge_iter_t(edge, n_edges); }
const_edge_iter_t begin() const { return const_edge_iter_t(edge, 0); }
const_edge_iter_t end() const { return const_edge_iter_t(edge, n_edges); }
bool containsPoint(const vector_t &p) const;
bool containsPointInProjection(const vector_t &p) const;
bool simpleLineSegmentIntersection(
const carve::geom::linesegment<ndim> &line,
vector_t &intersection) const;
IntersectionClass lineSegmentIntersection(
const carve::geom::linesegment<ndim> &line,
vector_t &intersection) const;
aabb_t getAABB() const;
bool recalc();
void clearEdges();
// build an edge loop in forward orientation from an iterator pair
template<typename iter_t>
void loopFwd(iter_t vbegin, iter_t vend);
// build an edge loop in reverse orientation from an iterator pair
template<typename iter_t>
void loopRev(iter_t vbegin, iter_t vend);
// initialize a face from an ordered list of vertices.
template<typename iter_t>
void init(iter_t begin, iter_t end);
// initialization of a triangular face.
void init(vertex_t *a, vertex_t *b, vertex_t *c);
// initialization of a quad face.
void init(vertex_t *a, vertex_t *b, vertex_t *c, vertex_t *d);
void getVertices(std::vector<vertex_t *> &verts) const;
void getProjectedVertices(std::vector<carve::geom::vector<2> > &verts) const;
projection_mapping projector() const {
return projection_mapping(project);
}
std::pair<double, double> rangeInDirection(const vector_t &v, const vector_t &b) const {
edge_t *e = edge;
double lo, hi;
lo = hi = carve::geom::dot(v, e->vert->v - b);
e = e->next;
for (; e != edge; e = e->next) {
double d = carve::geom::dot(v, e->vert->v - b);
lo = std::min(lo, d);
hi = std::max(hi, d);
}
return std::make_pair(lo, hi);
}
size_t nVertices() const {
return n_edges;
}
size_t nEdges() const {
return n_edges;
}
vector_t centroid() const;
static Face *closeLoop(edge_t *open_edge);
Face(edge_t *e) : edge(e), n_edges(0), mesh(NULL) {
do {
e->face = this;
n_edges++;
e = e->next;
} while (e != edge);
recalc();
}
Face(vertex_t *a, vertex_t *b, vertex_t *c) : edge(NULL), n_edges(0), mesh(NULL) {
init(a, b, c);
recalc();
}
Face(vertex_t *a, vertex_t *b, vertex_t *c, vertex_t *d) : edge(NULL), n_edges(0), mesh(NULL) {
init(a, b, c, d);
recalc();
}
template<typename iter_t>
Face(iter_t begin, iter_t end) : edge(NULL), n_edges(0), mesh(NULL) {
init(begin, end);
recalc();
}
template<typename iter_t>
Face *create(iter_t beg, iter_t end, bool reversed) const;
Face *clone(const vertex_t *old_base, vertex_t *new_base, std::unordered_map<const edge_t *, edge_t *> &edge_map) const;
void remove() {
edge_t *e = edge;
do {
if (e->rev) e->rev->rev = NULL;
e = e->next;
} while (e != edge);
}
void invert() {
// We invert the direction of the edges of the face in this
// way so that the edge rev pointers (if any) are still
// correct. It is expected that invert() will be called on
// every other face in the mesh, too, otherwise everything
// will get messed up.
{
// advance vertices.
edge_t *e = edge;
vertex_t *va = e->vert;
do {
e->vert = e->next->vert;
e = e->next;
} while (e != edge);
edge->prev->vert = va;
}
{
// swap prev and next pointers.
edge_t *e = edge;
do {
edge_t *n = e->next;
std::swap(e->prev, e->next);
e = n;
} while (e != edge);
}
plane.negate();
int da = carve::geom::largestAxis(plane.N);
project = getProjector(plane.N.v[da] > 0, da);
unproject = getUnprojector(plane.N.v[da] > 0, da);
}
void canonicalize();
~Face() {
clearEdges();
}
};
struct MeshOptions {
bool opt_avoid_cavities;
MeshOptions() :
opt_avoid_cavities(false) {
}
MeshOptions &avoid_cavities(bool val) {
opt_avoid_cavities = val;
return *this;
}
};
namespace detail {
class FaceStitcher {
FaceStitcher();
FaceStitcher(const FaceStitcher &);
FaceStitcher &operator=(const FaceStitcher &);
typedef Vertex<3> vertex_t;
typedef Edge<3> edge_t;
typedef Face<3> face_t;
typedef std::pair<const vertex_t *, const vertex_t *> vpair_t;
typedef std::list<edge_t *> edgelist_t;
typedef std::unordered_map<vpair_t, edgelist_t, carve::mesh::hash_vertex_pair> edge_map_t;
typedef std::unordered_map<const vertex_t *, std::set<const vertex_t *> > edge_graph_t;
MeshOptions opts;
edge_map_t edges;
edge_map_t complex_edges;
carve::djset::djset face_groups;
std::vector<bool> is_open;
edge_graph_t edge_graph;
struct EdgeOrderData {
size_t group_id;
bool is_reversed;
carve::geom::vector<3> face_dir;
edge_t *edge;
EdgeOrderData(edge_t *_edge, size_t _group_id, bool _is_reversed) :
group_id(_group_id),
is_reversed(_is_reversed) {
if (is_reversed) {
face_dir = -(_edge->face->plane.N);
} else {
face_dir = (_edge->face->plane.N);
}
edge = _edge;
}
struct TestGroups {
size_t fwd, rev;
TestGroups(size_t _fwd, size_t _rev) : fwd(_fwd), rev(_rev) {
}
bool operator()(const EdgeOrderData &eo) const {
return eo.group_id == (eo.is_reversed ? rev : fwd);
}
};
struct Cmp {
carve::geom::vector<3> edge_dir;
carve::geom::vector<3> base_dir;
Cmp(const carve::geom::vector<3> &_edge_dir,
const carve::geom::vector<3> &_base_dir) :
edge_dir(_edge_dir),
base_dir(_base_dir) {
}
bool operator()(const EdgeOrderData &a, const EdgeOrderData &b) const;
};
};
void extractConnectedEdges(std::vector<const vertex_t *>::iterator begin,
std::vector<const vertex_t *>::iterator end,
std::vector<std::vector<Edge<3> *> > &efwd,
std::vector<std::vector<Edge<3> *> > &erev);
size_t faceGroupID(const Face<3> *face);
size_t faceGroupID(const Edge<3> *edge);
void resolveOpenEdges();
void fuseEdges(std::vector<Edge<3> *> &fwd,
std::vector<Edge<3> *> &rev);
void joinGroups(std::vector<std::vector<Edge<3> *> > &efwd,
std::vector<std::vector<Edge<3> *> > &erev,
size_t fwd_grp,
size_t rev_grp);
void matchOrderedEdges(const std::vector<std::vector<EdgeOrderData> >::iterator begin,
const std::vector<std::vector<EdgeOrderData> >::iterator end,
std::vector<std::vector<Edge<3> *> > &efwd,
std::vector<std::vector<Edge<3> *> > &erev);
void reorder(std::vector<EdgeOrderData> &ordering, size_t fwd_grp);
void orderForwardAndReverseEdges(std::vector<std::vector<Edge<3> *> > &efwd,
std::vector<std::vector<Edge<3> *> > &erev,
std::vector<std::vector<EdgeOrderData> > &result);
void edgeIncidentGroups(const vpair_t &e,
const edge_map_t &all_edges,
std::pair<std::set<size_t>, std::set<size_t> > &groups);
void buildEdgeGraph(const edge_map_t &all_edges);
void extractPath(std::vector<const vertex_t *> &path);
void removePath(const std::vector<const vertex_t *> &path);
void matchSimpleEdges();
void construct();
template<typename iter_t>
void initEdges(iter_t begin, iter_t end);
template<typename iter_t>
void build(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes);
public:
FaceStitcher(const MeshOptions &_opts);
template<typename iter_t>
void create(iter_t begin, iter_t end, std::vector<Mesh<3> *> &meshes);
};
}
// A Mesh is a connected set of faces. It may be open (some edges
// have NULL rev members), or closed. On destruction, a Mesh
// should free its Faces (which will in turn free Edges, but not
// Vertices). A Mesh is edge-connected, which is to say that each
// face in the mesh shares an edge with at least one other face in
// the mesh. Touching at a vertex is not sufficient. This means
// that the perimeter of an open mesh visits each vertex no more
// than once.
template<unsigned ndim>
class Mesh {
public:
typedef Vertex<ndim> vertex_t;
typedef Edge<ndim> edge_t;
typedef Face<ndim> face_t;
typedef carve::geom::aabb<ndim> aabb_t;
typedef MeshSet<ndim> meshset_t;
std::vector<face_t *> faces;
// open_edges is a vector of all the edges in the mesh that
// don't have a matching edge in the opposite direction.
std::vector<edge_t *> open_edges;
// closed_edges is a vector of all the edges in the mesh that
// have a matching edge in the opposite direction, and whose
// address is lower than their counterpart. (i.e. for each pair
// of adjoining faces, one of the two half edges is stored in
// closed_edges).
std::vector<edge_t *> closed_edges;
bool is_negative;
meshset_t *meshset;
protected:
Mesh(std::vector<face_t *> &_faces,
std::vector<edge_t *> &_open_edges,
std::vector<edge_t *> &_closed_edges,
bool _is_negative);
public:
Mesh(std::vector<face_t *> &_faces);
~Mesh();
template<typename iter_t>
static void create(iter_t begin, iter_t end, std::vector<Mesh<ndim> *> &meshes, const MeshOptions &opts);
aabb_t getAABB() const {
return aabb_t(faces.begin(), faces.end());
}
bool isClosed() const {
return open_edges.size() == 0;
}
bool isNegative() const {
return is_negative;
}
double volume() const {
if (is_negative || !faces.size()) return 0.0;
double vol = 0.0;
typename vertex_t::vector_t origin = faces[0]->edge->vert->v;
for (size_t f = 0; f < faces.size(); ++f) {
face_t *face = faces[f];
edge_t *e1 = face->edge;
for (edge_t *e2 = e1->next ;e2->next != e1; e2 = e2->next) {
vol += carve::geom3d::tetrahedronVolume(e1->vert->v, e2->vert->v, e2->next->vert->v, origin);
}
}
return vol;
}
struct IsClosed {
bool operator()(const Mesh &mesh) const { return mesh.isClosed(); }
bool operator()(const Mesh *mesh) const { return mesh->isClosed(); }
};
struct IsNegative {
bool operator()(const Mesh &mesh) const { return mesh.isNegative(); }
bool operator()(const Mesh *mesh) const { return mesh->isNegative(); }
};
void cacheEdges();
int orientationAtVertex(edge_t *);
void calcOrientation();
void recalc() {
for (size_t i = 0; i < faces.size(); ++i) faces[i]->recalc();
calcOrientation();
}
void invert() {
for (size_t i = 0; i < faces.size(); ++i) {
faces[i]->invert();
}
if (isClosed()) is_negative = !is_negative;
}
Mesh *clone(const vertex_t *old_base, vertex_t *new_base) const;
};
// A MeshSet manages vertex storage, and a collection of meshes.
// It should be easy to turn a vertex pointer into its index in
// its MeshSet vertex_storage.
template<unsigned ndim>
class MeshSet {
MeshSet();
MeshSet(const MeshSet &);
MeshSet &operator=(const MeshSet &);
template<typename iter_t>
void _init_from_faces(iter_t begin, iter_t end, const MeshOptions &opts);
public:
typedef Vertex<ndim> vertex_t;
typedef Edge<ndim> edge_t;
typedef Face<ndim> face_t;
typedef Mesh<ndim> mesh_t;
typedef carve::geom::aabb<ndim> aabb_t;
std::vector<vertex_t> vertex_storage;
std::vector<mesh_t *> meshes;
public:
template<typename face_type>
struct FaceIter : public std::iterator<std::random_access_iterator_tag, face_type> {
typedef std::iterator<std::random_access_iterator_tag, face_type> super;
typedef typename super::difference_type difference_type;
const MeshSet<ndim> *obj;
size_t mesh, face;
FaceIter(const MeshSet<ndim> *_obj, size_t _mesh, size_t _face);
void fwd(size_t n);
void rev(size_t n);
void adv(int n);
FaceIter operator++(int) { FaceIter tmp = *this; tmp.fwd(1); return tmp; }
FaceIter operator+(int v) { FaceIter tmp = *this; tmp.adv(v); return tmp; }
FaceIter &operator++() { fwd(1); return *this; }
FaceIter &operator+=(int v) { adv(v); return *this; }
FaceIter operator--(int) { FaceIter tmp = *this; tmp.rev(1); return tmp; }
FaceIter operator-(int v) { FaceIter tmp = *this; tmp.adv(-v); return tmp; }
FaceIter &operator--() { rev(1); return *this; }
FaceIter &operator-=(int v) { adv(-v); return *this; }
difference_type operator-(const FaceIter &other) const;
bool operator==(const FaceIter &other) const {
return obj == other.obj && mesh == other.mesh && face == other.face;
}
bool operator!=(const FaceIter &other) const {
return !(*this == other);
}
bool operator<(const FaceIter &other) const {
CARVE_ASSERT(obj == other.obj);
return mesh < other.mesh || (mesh == other.mesh && face < other.face);
}
bool operator>(const FaceIter &other) const {
return other < *this;
}
bool operator<=(const FaceIter &other) const {
return !(other < *this);
}
bool operator>=(const FaceIter &other) const {
return !(*this < other);
}
face_type operator*() const {
return obj->meshes[mesh]->faces[face];
}
};
typedef FaceIter<const face_t *> const_face_iter;
typedef FaceIter<face_t *> face_iter;
face_iter faceBegin() { return face_iter(this, 0, 0); }
face_iter faceEnd() { return face_iter(this, meshes.size(), 0); }
const_face_iter faceBegin() const { return const_face_iter(this, 0, 0); }
const_face_iter faceEnd() const { return const_face_iter(this, meshes.size(), 0); }
aabb_t getAABB() const {
return aabb_t(meshes.begin(), meshes.end());
}
template<typename func_t>
void transform(func_t func) {
for (size_t i = 0; i < vertex_storage.size(); ++i) {
vertex_storage[i].v = func(vertex_storage[i].v);
}
for (size_t i = 0; i < meshes.size(); ++i) {
meshes[i]->recalc();
}
}
MeshSet(const std::vector<typename vertex_t::vector_t> &points,
size_t n_faces,
const std::vector<int> &face_indices,
const MeshOptions &opts = MeshOptions());
// Construct a mesh set from a set of disconnected faces. Takes
// posession of the face pointers.
MeshSet(std::vector<face_t *> &faces,
const MeshOptions &opts = MeshOptions());
MeshSet(std::list<face_t *> &faces,
const MeshOptions &opts = MeshOptions());
MeshSet(std::vector<vertex_t> &_vertex_storage,
std::vector<mesh_t *> &_meshes);
// This constructor consolidates and rewrites vertex pointers in
// each mesh, repointing them to local storage.
MeshSet(std::vector<mesh_t *> &_meshes);
MeshSet *clone() const;
~MeshSet();
bool isClosed() const {
for (size_t i = 0; i < meshes.size(); ++i) {
if (!meshes[i]->isClosed()) return false;
}
return true;
}
void invert() {
for (size_t i = 0; i < meshes.size(); ++i) {
meshes[i]->invert();
}
}
void collectVertices();
void canonicalize();
void separateMeshes();
};
carve::PointClass classifyPoint(
const carve::mesh::MeshSet<3> *meshset,
const carve::geom::RTreeNode<3, carve::mesh::Face<3> *> *face_rtree,
const carve::geom::vector<3> &v,
bool even_odd = false,
const carve::mesh::Mesh<3> *mesh = NULL,
const carve::mesh::Face<3> **hit_face = NULL);
}
mesh::MeshSet<3> *meshFromPolyhedron(const poly::Polyhedron *, int manifold_id);
poly::Polyhedron *polyhedronFromMesh(const mesh::MeshSet<3> *, int manifold_id);
};
#include <carve/mesh_impl.hpp>

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More