Commit Graph

166 Commits

Author SHA1 Message Date
jean-pierre charras 98339cd5eb 3d viewer: fix incorrect calculation of pad hole size of vertical shape.
Fixes #5627
https://gitlab.com/kicad/code/kicad/issues/5627
2020-09-15 10:17:31 +02:00
Jeff Young e2bc7557cc Clean up arc/circle polygonization.
1) For a while now we've been using a calculated seg count from a given
maxError, and a correction factor to push the radius out so that all
the error is outside the arc/circle.  However, the second calculation
(which pre-dates the first) is pretty much just the inverse of the first
(and yields nothing more than maxError back). This is particularly
sub-optimal given the cost of trig functions.

2) There are a lot of old optimizations to reduce segcounts in certain
situations, someting that our error-based calculation compensates for
 anyway.  (Smaller radii need fewer segments to meet the maxError
condition.) But perhaps more importantly we now surface maxError in the
UI and we don't really want to call it "Max deviation except when it's
not".

3) We were also clamping the segCount twice: once in the calculation
routine and once in most of it's callers.  Furthermore, the caller
clamping was inconsistent (both in being done and in the clamping
value). We now clamp only in the calculation routine.

4) There's no reason to use the correction factors in the 3Dviewer;
it's just a visualization and whether the polygonization error is
inside or outside the shape isn't really material.

5) The arc-correction-disabling stuff (used for solder mask layer) was
somewhat fragile in that it depended on the caller to turn it back on
afterwards.  It's now only exposed as a RAII object which  automatically
cleans up when it goes out of scope.

6) There were also bugs in a couple of the polygonization routines where
we'd accumulate round-off error in adding up the segments and end up with
an overly long last segment (which of course would voilate the error
max). This was the cause of the linked bug and also some issues with vias
that we had fudged in the past with extra clearance.

Fixes https://gitlab.com/kicad/code/kicad/issues/5567
2020-09-11 11:23:49 +01:00
Seth Hillbrand 08d4e91f3b Change partitions to fixed size
Partititioning small polygons causes excessive partitions when we use a
fixed number of cells per side.  Partitioning by size keeps the
partition count limited and speeds the calculations.

Also adds an option to not partition the grid for elements (like 3d
raytracing) that do not need it.

Fixes https://gitlab.com/kicad/code/kicad/issues/5579
2020-09-10 09:31:20 -07:00
Mario Luzeiro d52c475b27 3D-Viewer: implements plated copper texture
improves copper and board textures.
Related to https://gitlab.com/kicad/code/kicad/-/issues/2058
Use only one PerlinNoise class.
2020-09-08 21:02:20 +00:00
Mario Luzeiro f0edbd088c 3D-Viewer: fixing z-fight issues 2020-09-08 21:02:20 +00:00
Mario Luzeiro d7a95951e1 3D-Viewer: implement nonplated copper on raytracing 2020-09-08 21:02:19 +00:00
Mario Luzeiro 1ab968e72f 3D-Viewer: render different materials plated and non plated copper
implement on OpenGL
2020-09-08 21:02:19 +00:00
Jeff Young 2251716784 Don't show 3D models with their show flag set to false.
Fixes https://gitlab.com/kicad/code/kicad/issues/5548
2020-09-08 20:42:09 +01:00
Mario Luzeiro 306a8f57f7 3D-Viewer: Parameterize sampling options 2020-09-04 15:12:01 +00:00
Mario Luzeiro 2feef44fca 3D-Viewer: Limit the recursive reflection level
Fixes https://gitlab.com/kicad/code/kicad/issues/5426
2020-09-01 01:08:38 +00:00
Mario Luzeiro 820e3089a2 3D-Viewer: use the correct opacity meaning in the color settings 2020-09-01 01:08:38 +00:00
Mario Luzeiro 40d5746df6 3D-Viewer: Parameterize body board transparency
Fix/workarround raytracing render issues related with refraction
2020-09-01 01:08:38 +00:00
Mario Luzeiro 0302fe5570 3D-Viewer: Parameterize soldermask transparency 2020-09-01 01:08:37 +00:00
Wayne Stambaugh ede39780e2 Remove all debugging output that cannot be disabled.
The use of printf, wxLogDebug, and std::err/std::out causes excessive
debugging output which makes finding specific debugging messages more
difficult than it needs to be.

There is still some debugging output in test code that really needs to
be moved into a unit test.

Add debugging output section to the coding policy regarding debugging
output.
2020-08-18 10:17:36 -04:00
Mario Luzeiro 2764a41d96 3D-Viewer: fixes a shadow hit bug 2020-08-18 00:31:35 +00:00
Mario Luzeiro 78ac675316 3D-Viewer: parameterize raytracing lights, add it to options dialog
Remove some hacks related to postprocessing (not need now because the
previous postprocessing improvements, light parametrization could be
used for tune or future parameters could be implemented)
2020-08-15 09:41:34 +01:00
Ian McInerney 50b2271f84 Fix missing variable initialization 2020-07-18 23:56:39 +01:00
Joshua Redstone ad99d85390 3d-viewer: add option to clip silkscreen around via annular ring
Add more conservative clipping of silkscreen layers around vias.
Clips at outside of annular ring rather than outside of copper plating.
2020-07-16 22:36:06 +00:00
Mario Luzeiro 779ed40588 3D-Viewer: improve SSAO
Implement blur based on depth weights.
Improve occlusion based on direct light/shadow it receives.
Improve occlusion mixing with the final color by using multiply instead
of subtract.
Remove debug and test code.
2020-07-16 11:23:02 +00:00
Mario Luzeiro 74c6f6ab82 3D-Viewer: set missing scale and position to the list
Fixes https://gitlab.com/kicad/code/kicad/issues/4826
2020-07-11 16:55:49 +00:00
Mario Luzeiro ef7d7477d0 3D-Viewer: Remove not used list 2020-07-11 16:55:49 +00:00
Jeff Young d01b29ab37 Cleanup pad geometry handling.
There were a lot of plotters, exporters, etc. that were rolling their
own implementations.

This also introduces a lazily-built set of SHAPE objects for doing
collision detection and some forms of rendering (and later DRC).
2020-06-22 22:28:37 +01:00
Ian McInerney d46f9a5273 Give the 3D viewer an infobar & Infobar upgrades
ADDED: Infobar warning in 3d viewer for board outline issues
2020-06-04 00:13:27 +01:00
Mario Luzeiro 94ed433f64 3D-Viewer: Fixes #4432
Set default transparency of model from the assigned material.
2020-05-22 13:28:04 +00:00
jean-pierre charras 3b84653591 3D viewer: avoid crash in raytracing (null pointer use) if layer mask is
not shown and must be removed from silk screen layer.

Fixes #4430
https://gitlab.com/kicad/code/kicad/issues/4430
2020-05-14 11:50:12 +02:00
Simon Richter 632494cba7 Add missing includes
A few more instances of missing <algorithm> for std::max
2020-05-10 00:24:11 +02:00
Jon Evans 7ca069e63e A few formatting fixes 2020-05-08 17:32:06 -04:00
Mario Luzeiro 9446a9166d 3D-Viewer: implement opacity in raytracing
fix opacity implementation on OpenGL
2020-05-08 21:28:16 +00:00
Mario Luzeiro 5a7f875602 3D-Viewer: implements opacity property for 3D models
fixes #2087
2020-05-08 21:28:16 +00:00
Jon Evans 4923d993a7 Factor out raytracing background color calculation 2020-05-07 18:40:06 -04:00
Emery Burhan 6c3cc0cfd4 3d_viewer: Ceiling plane: fixed formatting. 2020-05-07 18:00:55 -04:00
Emery Burhan c665bf69b6 3d_viewer: Added a ceiling plane, similar to the floor plane. 2020-05-07 18:00:55 -04:00
Ian McInerney 99dcadf7e6 Introduce new KI_FALLTHROUGH macro
Annotate purposeful fallthroughs in switch statements with the
KI_FALLTHROUGH macro.
2020-04-25 00:44:09 +01:00
Ian McInerney ff67d6300d Hide more OpenGL deprecation warnings on OSX 2020-04-24 23:28:31 +01:00
jean-pierre charras cf66aac15d 3d viewer: fix compil issue (missing include in c3d_render_ogl_legacy.cpp) 2020-04-24 08:24:59 +02:00
Mario Luzeiro b0bf9f7b57 3D-Viewer: use wxStaticBoxSizer for options, fix coding style 2020-04-23 17:28:56 +01:00
Mario Luzeiro 00da17bc7d 3D-Viewer: Add new options: Anti-aliasing quality, "While moving"
Create new window options with tabs for 3D-Viewer. Remove
"showCopperThickness" option from menus and place it on OpenGL options.
2020-04-23 09:29:39 +00:00
Mario Luzeiro 656efc8d62 3D-Viewer: disable AA while moving
disable AA for Raytracing
Fixes #4007
2020-04-23 09:29:38 +00:00
Emery Burhan b1ac504fcd 3d_viewer: Fix bottom view image being too dark when floor+shadows are enabled
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2083
2020-04-22 23:00:15 +00:00
Oleg Endo ae6fbc9c60 Improve 3D viewer rendering performance
* Use GL vertex buffers and index buffers for 3D model rendering
* Use material or average vertex color for bounding boxes instead of red
* Reinstate bounding box rendering with GL vertex/index buffers
* Use compact vertex/index data representation
  - 8-bit normals
  - 8-bit colors
  - 16-bit or 32-bit indices, depending on model size

This should improve performance a bit on lower end GPUs with less memory
and bandwidth.

Fixes #4112
2020-04-17 16:10:04 +00:00
Jeff Young 174856bac5 Promote 3D model "preview" flag to a persisted "show" flag.
Fixes https://gitlab.com/kicad/code/kicad/issues/2061
2020-04-10 22:49:56 +01:00
Jeff Young 5134856f18 Rationalise 3D settings data-structure.
Move the camera out to its own so that everything else is board-
related, and then rename BOARD_ADAPTER.

At some point the flags should probably be moved out too, and they
can have the EDA_3D_SETTINGS name.
2020-03-28 16:09:40 +00:00
Jeff Young d69ebfae49 Push tool framework base down into TOOL_HOLDER.
This allows us to use it outside of EDA_BASE_FRAMEs (in this case, in
PANEL_PREVIEW_3D.)
2020-03-24 19:00:25 +00:00
jean-pierre charras cc47062b17 Fix a few Coverity issues 2020-03-23 16:17:22 +01:00
Jeff Young e9cd9ee8ff Actionize the rest of the 3D viewer.
Fixes https://gitlab.com/kicad/code/kicad/issues/2228
2020-03-19 15:10:32 +00:00
Ian McInerney 34e5b76c5f Add virtual constructors to some classes that should have them
This is more for safety from undefined deletion behavior than
anything else (it also silences the Clang -Wnon-virtual-dtor warning).
2020-02-05 22:19:14 +00:00
Ian McInerney 5053f58bfc Move 3d viewer board outline warning to the status bar
This is less intrusive than a dialog that is constantly opening
whenever the 3d view is refreshed.
2020-02-03 22:09:14 +00:00
Mario Luzeiro 970a0a593a 3d-viewer, add an option to subtract Mask from Silk
Remove holes on Silk layer by default so the behaviour is the same
on OpenGL and Raytracing.
Fixes #1836
Fix raytracing shadow offset issue.
Some codestyle fix.
2020-01-29 16:00:05 +00:00
Ian McInerney c5a9479953 Only get 3D viewer colors when launched from the PCb editor
When launched from CVPCB or the footprint editor/viewer the stackup
isn't user-editable, so it just gives its default colors.
2020-01-22 22:48:20 +00:00
Fabien Corona 183bbf6914 3d-viewer : synchronise colours with board stackup.
ADDED: 3d-viewer can now look up colours defined in board properties

Fixes https://gitlab.com/kicad/code/kicad/issues/2261
2020-01-22 22:38:30 +00:00