Merge pull request #5372 from larsbrubaker/main

Fixing error with support not visible when looking up from under the …
This commit is contained in:
Lars Brubaker 2022-09-06 17:34:49 -07:00 committed by GitHub
commit 0fa7dc8cd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 34 deletions

3
.gitmodules vendored
View file

@ -4,3 +4,6 @@
[submodule "Submodules/agg-sharp"]
path = Submodules/agg-sharp
url = https://github.com/MatterHackers/agg-sharp.git
[submodule "Submodules/agg-sharp/glfw-net"]
path = Submodules/agg-sharp/glfw-net
url = https://github.com/MatterHackers/glfw-net.git

View file

@ -73,6 +73,8 @@
<ProjectReference Include="..\Submodules\agg-sharp\DataConverters2D\DataConverters2D.csproj" />
<ProjectReference Include="..\Submodules\agg-sharp\DataConverters3D\DataConverters3D.csproj" />
<ProjectReference Include="..\Submodules\agg-sharp\geometry3Sharp\geometry3Sharp.csproj" />
<ProjectReference Include="..\Submodules\agg-sharp\glfw-net\GLFW.NET\GLFW.NETStandard.csproj" />
<ProjectReference Include="..\Submodules\agg-sharp\Glfw\GlfwProvider.csproj" />
<ProjectReference Include="..\Submodules\agg-sharp\GuiAutomation\GuiAutomation.csproj" />
<ProjectReference Include="..\Submodules\agg-sharp\Gui\Gui.csproj" />
<ProjectReference Include="..\Submodules\agg-sharp\ImageProcessing\ImageProcessing.csproj" />

View file

@ -1141,13 +1141,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
var renderBedTransparent = !floorDrawable.LookingDownOnBed || floorDrawable.SelectedObjectUnderBed;
if (renderBedTransparent)
{
floorDrawable.Draw(this, e, Matrix4X4.Identity, this.World);
}
var wireColor = Color.Transparent;
switch (modelRenderStyle)
{
@ -1170,30 +1163,47 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
// Draw transparent objects
foreach (var item in transparentMeshes)
void DrawTransparentMeshes(bool aboveBed)
{
GL.Enable(EnableCap.Lighting);
foreach (var item in transparentMeshes)
{
if (aboveBed && item.Object3D.GetAxisAlignedBoundingBox().Center.Z <= 0
|| (!aboveBed && item.Object3D.GetAxisAlignedBoundingBox().Center.Z > 0))
{
continue;
}
var object3D = item.Object3D;
GLHelper.Render(
object3D.Mesh,
item.Color,
object3D.WorldMatrix(),
RenderTypes.Outlines,
object3D.WorldMatrix() * World.ModelviewMatrix,
wireColor,
allowBspRendering: transparentMeshes.Count < 1000,
forceCullBackFaces: false);
GL.Enable(EnableCap.Lighting);
var object3D = item.Object3D;
GLHelper.Render(
object3D.Mesh,
item.Color,
object3D.WorldMatrix(),
RenderTypes.Outlines,
object3D.WorldMatrix() * World.ModelviewMatrix,
wireColor,
allowBspRendering: transparentMeshes.Count < 1000,
forceCullBackFaces: false);
}
}
if (!renderBedTransparent)
// Draw transparent objects
if (floorDrawable.LookingDownOnBed)
{
floorDrawable.Draw(this, e, Matrix4X4.Identity, this.World);
}
DrawTransparentMeshes(false);
floorDrawable.Draw(this, e, Matrix4X4.Identity, this.World);
DrawTransparentMeshes(true);
}
else
{
DrawTransparentMeshes(true);
floorDrawable.Draw(this, e, Matrix4X4.Identity, this.World);
DrawTransparentMeshes(false);
}
// Draw the editor items in the same scope as the 3D Controls
foreach (var item in editorDrawItems)
// Draw the editor items in the same scope as the 3D Controls
foreach (var item in editorDrawItems)
{
// Invoke existing IEditorDraw when iterating items
if (item is IEditorDraw editorDraw)
@ -1203,16 +1213,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
DrawObject3DControlVolumes(e);
// draw everything
foreach (var drawable in drawables.Where(d => d.DrawStage == DrawStage.TransparentContent))
{
if (drawable.Enabled)
{
drawable.Draw(this, e, Matrix4X4.Identity, this.World);
}
}
foreach (var drawable in drawables.Where(d => d.DrawStage == DrawStage.TransparentContent))
{
if (drawable.Enabled)
{
drawable.Draw(this, e, Matrix4X4.Identity, this.World);
}
}
GLHelper.UnsetGlContext();
GLHelper.UnsetGlContext();
// Invoke DrawStage.Last item drawables
foreach (var item in scene.Children)