Skip to content

Commit

Permalink
Rendering refactoring (openscad#5533)
Browse files Browse the repository at this point in the history
  • Loading branch information
kintel authored Jan 12, 2025
1 parent fc57adb commit 3d2d3f2
Show file tree
Hide file tree
Showing 34 changed files with 586 additions and 1,593 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_UNITY_BUILD=OFF -DEXPERIMENTAL=ON -DSNAPSHOT=ON $CMAKE_OPTIONS
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_UNITY_BUILD=OFF -DEXPERIMENTAL=ON -DSNAPSHOT=ON -DUSE_CCACHE=OFF $CMAKE_OPTIONS
export NUMCPU=$(($(sysctl -n hw.ncpu) * 3 / 2))
make -j$NUMCPU
- name: Run Test Suite
Expand Down
13 changes: 0 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ option(EXPERIMENTAL "Enable Experimental Features" OFF)
option(USE_MANIFOLD_TRIANGULATOR "Use Manifold's triangulator instead of CGAL's" ON)
option(USE_BUILTIN_MANIFOLD "Use manifold from submodule" ON)
option(USE_BUILTIN_CLIPPER2 "Use Clipper2 from submodule" ON)
option(USE_LEGACY_RENDERERS "Use legacy (non-VBO) OpenGL renderers" OFF)
option(SNAPSHOT "Create dev snapshot, uses nightly icons" OFF)
option(HEADLESS "Build without GUI frontend" OFF)
if(APPLE)
Expand Down Expand Up @@ -214,9 +213,6 @@ endif()
if(IDPREFIX)
target_compile_definitions(OpenSCAD PRIVATE IDPREFIX)
endif()
if(USE_LEGACY_RENDERERS)
target_compile_definitions(OpenSCAD PRIVATE USE_LEGACY_RENDERERS)
endif()

if (NOT "${SUFFIX}" STREQUAL "")
set(SUFFIX_WITH_DASH "-${SUFFIX}")
Expand Down Expand Up @@ -1040,14 +1036,6 @@ if(NULLGL)
src/io/export_png.cc
src/io/imageutils.cc)
else()
if(USE_LEGACY_RENDERERS)
set(LEGACY_RENDERER_SOURCES
src/glview/cgal/LegacyCGALRenderer.cc
src/glview/preview/LegacyOpenCSGRenderer.cc
src/glview/preview/LegacyThrownTogetherRenderer.cc
src/glview/LegacyRendererUtils.cc
)
endif()
set(OFFSCREEN_SOURCES
src/glview/OpenGLContext.cc
src/glview/fbo.cc
Expand All @@ -1065,7 +1053,6 @@ else()
src/glview/preview/ThrownTogetherRenderer.cc
src/io/export_png.cc
src/io/imageutils.cc
${LEGACY_RENDERER_SOURCES}
${GLEW_SOURCES})
endif()

Expand Down
2 changes: 2 additions & 0 deletions shaders/MouseSelector.frag
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#version 120

uniform vec3 frag_idcolor;
void main() {
gl_FragColor = vec4(frag_idcolor, 1.0);
Expand Down
2 changes: 2 additions & 0 deletions shaders/MouseSelector.vert
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#version 120

void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
2 changes: 1 addition & 1 deletion shaders/Preview.frag
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#version 110
#version 120

uniform vec4 color1, color2;
varying vec3 vBC;
Expand Down
5 changes: 2 additions & 3 deletions shaders/Preview.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#version 110
#version 120

uniform vec4 color1; // face color
uniform vec4 color2; // edge color
attribute vec3 barycentric; // barycentric form of vertex coord
// either [1,0,0], [0,1,0] or [0,0,1] under normal circumstances (no edges disabled)

varying vec3 vBC; // varying barycentric coords
varying float shading; // multiplied by color1. color2 is without lighting

Expand Down
44 changes: 22 additions & 22 deletions src/core/CSGNode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,34 +275,34 @@ std::string CSGProduct::dump() const
BoundingBox CSGProduct::getBoundingBox(bool throwntogether) const
{
BoundingBox bbox;
if (!this->intersections.empty()) {
if (throwntogether) {
bbox = std::accumulate(
this->intersections.cbegin() + 1,
this->intersections.cend(),
this->intersections.front().leaf->bbox,
[](const BoundingBox& a, const CSGChainObject& b) {
if (this->intersections.empty()) return bbox;

if (throwntogether) {
bbox = std::accumulate(
this->intersections.cbegin() + 1,
this->intersections.cend(),
this->intersections.front().leaf->bbox,
[](const BoundingBox& a, const CSGChainObject& b) {
return a.merged(b.leaf->bbox);
}
);
bbox = std::accumulate(
this->subtractions.cbegin(),
this->subtractions.cend(),
bbox,
[](const BoundingBox& a, const CSGChainObject& b) {
);
bbox = std::accumulate(
this->subtractions.cbegin(),
this->subtractions.cend(),
bbox,
[](const BoundingBox& a, const CSGChainObject& b) {
return a.merged(b.leaf->bbox);
}
);
} else {
bbox = std::accumulate(
this->intersections.cbegin() + 1,
this->intersections.cend(),
this->intersections.front().leaf->bbox,
[](const BoundingBox& a, const CSGChainObject& b) {
);
} else {
bbox = std::accumulate(
this->intersections.cbegin() + 1,
this->intersections.cend(),
this->intersections.front().leaf->bbox,
[](const BoundingBox& a, const CSGChainObject& b) {
return a.intersection(b.leaf->bbox);
}
);
}
);
}
return bbox;
}
Expand Down
6 changes: 0 additions & 6 deletions src/glview/GLView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ GLView::GLView()
void GLView::setRenderer(std::shared_ptr<Renderer> r)
{
this->renderer = r;
if (this->renderer) {
this->renderer->resize(cam.pixel_width, cam.pixel_height);
}
}

/* update the color schemes of the Renderer attached to this GLView
Expand Down Expand Up @@ -75,9 +72,6 @@ void GLView::resizeGL(int w, int h)
cam.pixel_height = h;
glViewport(0, 0, w, h);
aspectratio = 1.0 * w / h;
if (this->renderer) {
this->renderer->resize(cam.pixel_width, cam.pixel_height);
}
}

void GLView::setCamera(const Camera& cam)
Expand Down
111 changes: 0 additions & 111 deletions src/glview/LegacyRendererUtils.cc

This file was deleted.

9 changes: 0 additions & 9 deletions src/glview/LegacyRendererUtils.h

This file was deleted.

Loading

0 comments on commit 3d2d3f2

Please sign in to comment.