Browse Source

Merge remote-tracking branch 'origin/master' into feature_model_list

Lipu Fei 5 years ago
parent
commit
28172c9ad2

+ 139 - 0
cura/API/Machines.py

@@ -0,0 +1,139 @@
+# Copyright (c) 2019 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+
+from typing import Optional, Dict,  List, TYPE_CHECKING, Any
+from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty
+from UM.i18n import i18nCatalog
+from UM.Logger import Logger
+if TYPE_CHECKING:
+    from cura.CuraApplication import CuraApplication
+    from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice
+
+i18n_catalog = i18nCatalog("cura")
+
+##  The account API provides a version-proof bridge to use Ultimaker Accounts
+#
+#   Usage:
+#       ```
+#       from cura.API import CuraAPI
+#       api = CuraAPI()
+#       api.machines.addOutputDeviceToCurrentMachine()
+#       ```
+
+##  Since Cura doesn't have a machine class, we're going to make a fake one to make our lives a
+#   little bit easier.
+class Machine():
+    def __init__(self) -> None:
+        self.hostname = "" # type: str
+        self.group_id = "" # type: str
+        self.group_name = "" # type: str
+        self.um_network_key = "" # type: str
+        self.configuration = {} # type: Dict[str, Any]
+        self.connection_types = [] # type: List[int]
+
+class Machines(QObject):
+
+    def __init__(self, application: "CuraApplication", parent = None) -> None:
+        super().__init__(parent)
+        self._application = application
+
+    @pyqtSlot(result="QVariantMap")
+    def getCurrentMachine(self) -> Machine:
+        fake_machine = Machine() # type: Machine
+        global_stack = self._application.getGlobalContainerStack()
+        if global_stack:
+            metadata = global_stack.getMetaData()
+            if "group_id" in metadata:
+                fake_machine.group_id = global_stack.getMetaDataEntry("group_id")
+            if "group_name" in metadata:
+                fake_machine.group_name = global_stack.getMetaDataEntry("group_name")
+            if "um_network_key" in metadata:
+                fake_machine.um_network_key = global_stack.getMetaDataEntry("um_network_key")
+
+            fake_machine.connection_types = global_stack.configuredConnectionTypes
+            
+        return fake_machine
+
+    ##  Set the current machine's friendy name.
+    #   This is the same as "group name" since we use "group" and "current machine" interchangeably.
+    #   TODO: Maybe make this "friendly name" to distinguish from "hostname"?
+    @pyqtSlot(str)
+    def setCurrentMachineGroupName(self, group_name: str) -> None:
+        Logger.log("d", "Attempting to set the group name of the active machine to %s", group_name)
+        global_stack = self._application.getGlobalContainerStack()
+        if global_stack:
+            # Update a GlobalStacks in the same group with the new group name.
+            group_id = global_stack.getMetaDataEntry("group_id")
+            machine_manager = self._application.getMachineManager()
+            for machine in machine_manager.getMachinesInGroup(group_id):
+                machine.setMetaDataEntry("group_name", group_name)
+
+            # Set the default value for "hidden", which is used when you have a group with multiple types of printers
+            global_stack.setMetaDataEntry("hidden", False)
+
+    ##  Set the current machine's configuration from an (optional) output device.
+    #   If no output device is given, the first one available on the machine will be used.
+    #   NOTE: Group and machine are used interchangeably.
+    #   NOTE: This doesn't seem to be used anywhere. Maybe delete?
+    @pyqtSlot(QObject)
+    def updateCurrentMachineConfiguration(self, output_device: Optional["PrinterOutputDevice"]) -> None:
+
+        if output_device is None:
+            machine_manager = self._application.getMachineManager()
+            output_device = machine_manager.printerOutputDevices[0]
+        
+        hotend_ids = output_device.hotendIds
+        for index in range(len(hotend_ids)):
+            output_device.hotendIdChanged.emit(index, hotend_ids[index])
+        
+        material_ids = output_device.materialIds
+        for index in range(len(material_ids)):
+            output_device.materialIdChanged.emit(index, material_ids[index])
+
+    ##  Add an output device to the current machine.
+    #   In practice, this means:
+    #   - Setting the output device's network key in the current machine's metadata
+    #   - Adding the output device's connection type to the current machine's configured connection
+    #     types.
+    #   TODO: CHANGE TO HOSTNAME
+    @pyqtSlot(QObject)
+    def addOutputDeviceToCurrentMachine(self, output_device: "PrinterOutputDevice") -> None:
+        if not output_device:
+            return
+        Logger.log("d",
+            "Attempting to set the network key of the active machine to %s",
+            output_device.key)
+        global_stack = self._application.getGlobalContainerStack()
+        if not global_stack:
+            return
+        metadata = global_stack.getMetaData()
+
+        # Global stack already had a connection, but it's changed.
+        if "um_network_key" in metadata: 
+            old_network_key = metadata["um_network_key"]
+
+            # Since we might have a bunch of hidden stacks, we also need to change it there.
+            metadata_filter = {"um_network_key": old_network_key}
+            containers = self._application.getContainerRegistry().findContainerStacks(
+                type = "machine", **metadata_filter)
+            for container in containers:
+                container.setMetaDataEntry("um_network_key", output_device.key)
+
+                # Delete old authentication data.
+                Logger.log("d", "Removing old authentication id %s for device %s",
+                    global_stack.getMetaDataEntry("network_authentication_id", None),
+                    output_device.key)
+
+                container.removeMetaDataEntry("network_authentication_id")
+                container.removeMetaDataEntry("network_authentication_key")
+
+                # Ensure that these containers do know that they are configured for the given
+                # connection type (can be more than one type; e.g. LAN & Cloud)
+                container.addConfiguredConnectionType(output_device.connectionType.value)
+
+        else:  # Global stack didn't have a connection yet, configure it.
+            global_stack.setMetaDataEntry("um_network_key", output_device.key)
+            global_stack.addConfiguredConnectionType(output_device.connectionType.value)
+
+        return None
+    

+ 8 - 0
cura/API/__init__.py

@@ -6,6 +6,7 @@ from PyQt5.QtCore import QObject, pyqtProperty
 
 
 from cura.API.Backups import Backups
 from cura.API.Backups import Backups
 from cura.API.Interface import Interface
 from cura.API.Interface import Interface
+from cura.API.Machines import Machines
 from cura.API.Account import Account
 from cura.API.Account import Account
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:
@@ -44,6 +45,9 @@ class CuraAPI(QObject):
         # Backups API
         # Backups API
         self._backups = Backups(self._application)
         self._backups = Backups(self._application)
 
 
+        # Machines API
+        self._machines = Machines(self._application)
+
         # Interface API
         # Interface API
         self._interface = Interface(self._application)
         self._interface = Interface(self._application)
 
 
@@ -58,6 +62,10 @@ class CuraAPI(QObject):
     def backups(self) -> "Backups":
     def backups(self) -> "Backups":
         return self._backups
         return self._backups
 
 
+    @pyqtProperty(QObject)
+    def machines(self) -> "Machines":
+        return self._machines
+
     @property
     @property
     def interface(self) -> "Interface":
     def interface(self) -> "Interface":
         return self._interface
         return self._interface

+ 1 - 1
cura/PrinterOutput/PrintJobOutputModel.py

@@ -1,4 +1,4 @@
 import warnings
 import warnings
-warnings.warn("Importing cura.PrinterOutput.PrintJobOutputModel has been deprecated since 4.1, use cura.PrinterOutput.Models.PrintJobOutputModel inststad", DeprecationWarning, stacklevel=2)
+warnings.warn("Importing cura.PrinterOutput.PrintJobOutputModel has been deprecated since 4.1, use cura.PrinterOutput.Models.PrintJobOutputModel instead", DeprecationWarning, stacklevel=2)
 # We moved the the models to one submodule deeper
 # We moved the the models to one submodule deeper
 from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
 from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel

+ 1 - 1
cura/PrinterOutput/PrinterOutputModel.py

@@ -1,4 +1,4 @@
 import warnings
 import warnings
-warnings.warn("Importing cura.PrinterOutput.PrinterOutputModel has been deprecated since 4.1, use cura.PrinterOutput.Models.PrinterOutputModel inststad", DeprecationWarning, stacklevel=2)
+warnings.warn("Importing cura.PrinterOutput.PrinterOutputModel has been deprecated since 4.1, use cura.PrinterOutput.Models.PrinterOutputModel instead", DeprecationWarning, stacklevel=2)
 # We moved the the models to one submodule deeper
 # We moved the the models to one submodule deeper
 from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel
 from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel

+ 1 - 1
cura/PrinterOutputDevice.py

@@ -1,4 +1,4 @@
 import warnings
 import warnings
-warnings.warn("Importing cura.PrinterOutputDevice has been deprecated since 4.1, use cura.PrinterOutput.PrinterOutputDevice inststad", DeprecationWarning, stacklevel=2)
+warnings.warn("Importing cura.PrinterOutputDevice has been deprecated since 4.1, use cura.PrinterOutput.PrinterOutputDevice instead", DeprecationWarning, stacklevel=2)
 # We moved the PrinterOutput device to it's own submodule.
 # We moved the PrinterOutput device to it's own submodule.
 from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
 from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionState

+ 7 - 3
cura/Settings/MachineManager.py

@@ -394,6 +394,7 @@ class MachineManager(QObject):
     @pyqtSlot(str)
     @pyqtSlot(str)
     @pyqtSlot(str, str)
     @pyqtSlot(str, str)
     def addMachine(self, definition_id: str, name: Optional[str] = None) -> None:
     def addMachine(self, definition_id: str, name: Optional[str] = None) -> None:
+        Logger.log("i", "Trying to add a machine with the definition id [%s]", definition_id)
         if name is None:
         if name is None:
             definitions = CuraContainerRegistry.getInstance().findDefinitionContainers(id = definition_id)
             definitions = CuraContainerRegistry.getInstance().findDefinitionContainers(id = definition_id)
             if definitions:
             if definitions:
@@ -464,6 +465,7 @@ class MachineManager(QObject):
     #   \param key \type{str} the name of the key to delete
     #   \param key \type{str} the name of the key to delete
     @pyqtSlot(str)
     @pyqtSlot(str)
     def clearUserSettingAllCurrentStacks(self, key: str) -> None:
     def clearUserSettingAllCurrentStacks(self, key: str) -> None:
+        Logger.log("i", "Clearing the setting [%s] from all stacks", key)
         if not self._global_container_stack:
         if not self._global_container_stack:
             return
             return
 
 
@@ -786,6 +788,7 @@ class MachineManager(QObject):
 
 
     @pyqtSlot(str)
     @pyqtSlot(str)
     def removeMachine(self, machine_id: str) -> None:
     def removeMachine(self, machine_id: str) -> None:
+        Logger.log("i", "Attempting to remove a machine with the id [%s]", machine_id)
         # If the machine that is being removed is the currently active machine, set another machine as the active machine.
         # If the machine that is being removed is the currently active machine, set another machine as the active machine.
         activate_new_machine = (self._global_container_stack and self._global_container_stack.getId() == machine_id)
         activate_new_machine = (self._global_container_stack and self._global_container_stack.getId() == machine_id)
 
 
@@ -1263,8 +1266,8 @@ class MachineManager(QObject):
         if self._global_container_stack is not None:
         if self._global_container_stack is not None:
             if Util.parseBool(self._global_container_stack.getMetaDataEntry("has_materials", False)):
             if Util.parseBool(self._global_container_stack.getMetaDataEntry("has_materials", False)):
                 for position, extruder in self._global_container_stack.extruders.items():
                 for position, extruder in self._global_container_stack.extruders.items():
-                    if extruder.isEnabled and not extruder.material.getMetaDataEntry("compatible"):
-                        return False
+                    if not extruder.isEnabled:
+                        continue
                     if not extruder.material.getMetaDataEntry("compatible"):
                     if not extruder.material.getMetaDataEntry("compatible"):
                         return False
                         return False
         return True
         return True
@@ -1273,7 +1276,7 @@ class MachineManager(QObject):
     def _updateQualityWithMaterial(self, *args: Any) -> None:
     def _updateQualityWithMaterial(self, *args: Any) -> None:
         if self._global_container_stack is None:
         if self._global_container_stack is None:
             return
             return
-        Logger.log("i", "Updating quality/quality_changes due to material change")
+        Logger.log("d", "Updating quality/quality_changes due to material change")
         current_quality_type = None
         current_quality_type = None
         if self._current_quality_group:
         if self._current_quality_group:
             current_quality_type = self._current_quality_group.quality_type
             current_quality_type = self._current_quality_group.quality_type
@@ -1354,6 +1357,7 @@ class MachineManager(QObject):
     #   instance with the same network key.
     #   instance with the same network key.
     @pyqtSlot(str)
     @pyqtSlot(str)
     def switchPrinterType(self, machine_name: str) -> None:
     def switchPrinterType(self, machine_name: str) -> None:
+        Logger.log("i", "Attempting to switch the printer type to [%s]", machine_name)
         # Don't switch if the user tries to change to the same type of printer
         # Don't switch if the user tries to change to the same type of printer
         if self._global_container_stack is None or self.activeMachineDefinitionName == machine_name:
         if self._global_container_stack is None or self.activeMachineDefinitionName == machine_name:
             return
             return

+ 4 - 2
cura/Settings/cura_empty_instance_containers.py

@@ -1,9 +1,11 @@
-# Copyright (c) 2018 Ultimaker B.V.
+# Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 
 import copy
 import copy
 
 
 from UM.Settings.constant_instance_containers import EMPTY_CONTAINER_ID, empty_container
 from UM.Settings.constant_instance_containers import EMPTY_CONTAINER_ID, empty_container
+from UM.i18n import i18nCatalog
+catalog = i18nCatalog("cura")
 
 
 
 
 # Empty definition changes
 # Empty definition changes
@@ -28,7 +30,7 @@ empty_material_container.setMetaDataEntry("type", "material")
 EMPTY_QUALITY_CONTAINER_ID = "empty_quality"
 EMPTY_QUALITY_CONTAINER_ID = "empty_quality"
 empty_quality_container = copy.deepcopy(empty_container)
 empty_quality_container = copy.deepcopy(empty_container)
 empty_quality_container.setMetaDataEntry("id", EMPTY_QUALITY_CONTAINER_ID)
 empty_quality_container.setMetaDataEntry("id", EMPTY_QUALITY_CONTAINER_ID)
-empty_quality_container.setName("Not Supported")
+empty_quality_container.setName(catalog.i18nc("@info:not supported profile", "Not supported"))
 empty_quality_container.setMetaDataEntry("quality_type", "not_supported")
 empty_quality_container.setMetaDataEntry("quality_type", "not_supported")
 empty_quality_container.setMetaDataEntry("type", "quality")
 empty_quality_container.setMetaDataEntry("type", "quality")
 empty_quality_container.setMetaDataEntry("supported", False)
 empty_quality_container.setMetaDataEntry("supported", False)

+ 3 - 6
plugins/CuraEngineBackend/CuraEngineBackend.py

@@ -207,7 +207,7 @@ class CuraEngineBackend(QObject, Backend):
             self._createSocket()
             self._createSocket()
 
 
         if self._process_layers_job is not None:  # We were processing layers. Stop that, the layers are going to change soon.
         if self._process_layers_job is not None:  # We were processing layers. Stop that, the layers are going to change soon.
-            Logger.log("d", "Aborting process layers job...")
+            Logger.log("i", "Aborting process layers job...")
             self._process_layers_job.abort()
             self._process_layers_job.abort()
             self._process_layers_job = None
             self._process_layers_job = None
 
 
@@ -222,7 +222,7 @@ class CuraEngineBackend(QObject, Backend):
 
 
     ##  Perform a slice of the scene.
     ##  Perform a slice of the scene.
     def slice(self) -> None:
     def slice(self) -> None:
-        Logger.log("d", "Starting to slice...")
+        Logger.log("i", "Starting to slice...")
         self._slice_start_time = time()
         self._slice_start_time = time()
         if not self._build_plates_to_be_sliced:
         if not self._build_plates_to_be_sliced:
             self.processingProgress.emit(1.0)
             self.processingProgress.emit(1.0)
@@ -517,9 +517,6 @@ class CuraEngineBackend(QObject, Backend):
                 self._build_plates_to_be_sliced.append(build_plate_number)
                 self._build_plates_to_be_sliced.append(build_plate_number)
             self.printDurationMessage.emit(source_build_plate_number, {}, [])
             self.printDurationMessage.emit(source_build_plate_number, {}, [])
         self.processingProgress.emit(0.0)
         self.processingProgress.emit(0.0)
-        self.setState(BackendState.NotStarted)
-        # if not self._use_timer:
-            # With manually having to slice, we want to clear the old invalid layer data.
         self._clearLayerData(build_plate_changed)
         self._clearLayerData(build_plate_changed)
 
 
         self._invokeSlice()
         self._invokeSlice()
@@ -563,10 +560,10 @@ class CuraEngineBackend(QObject, Backend):
 
 
     ##  Convenient function: mark everything to slice, emit state and clear layer data
     ##  Convenient function: mark everything to slice, emit state and clear layer data
     def needsSlicing(self) -> None:
     def needsSlicing(self) -> None:
+        self.determineAutoSlicing()
         self.stopSlicing()
         self.stopSlicing()
         self.markSliceAll()
         self.markSliceAll()
         self.processingProgress.emit(0.0)
         self.processingProgress.emit(0.0)
-        self.setState(BackendState.NotStarted)
         if not self._use_timer:
         if not self._use_timer:
             # With manually having to slice, we want to clear the old invalid layer data.
             # With manually having to slice, we want to clear the old invalid layer data.
             self._clearLayerData()
             self._clearLayerData()

+ 13 - 5
plugins/SimulationView/layers.shader

@@ -1,6 +1,9 @@
 [shaders]
 [shaders]
 vertex =
 vertex =
-    uniform highp mat4 u_modelViewProjectionMatrix;
+    uniform highp mat4 u_modelMatrix;
+    uniform highp mat4 u_viewMatrix;
+    uniform highp mat4 u_projectionMatrix;
+
     uniform lowp float u_active_extruder;
     uniform lowp float u_active_extruder;
     uniform lowp float u_shade_factor;
     uniform lowp float u_shade_factor;
     uniform highp int u_layer_view_type;
     uniform highp int u_layer_view_type;
@@ -16,7 +19,7 @@ vertex =
 
 
     void main()
     void main()
     {
     {
-        gl_Position = u_modelViewProjectionMatrix * a_vertex;
+        gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
         // shade the color depending on the extruder index
         // shade the color depending on the extruder index
         v_color = a_color;
         v_color = a_color;
         // 8 and 9 are travel moves
         // 8 and 9 are travel moves
@@ -76,7 +79,10 @@ fragment =
 
 
 vertex41core =
 vertex41core =
     #version 410
     #version 410
-    uniform highp mat4 u_modelViewProjectionMatrix;
+    uniform highp mat4 u_modelMatrix;
+    uniform highp mat4 u_viewMatrix;
+    uniform highp mat4 u_projectionMatrix;
+
     uniform lowp float u_active_extruder;
     uniform lowp float u_active_extruder;
     uniform lowp float u_shade_factor;
     uniform lowp float u_shade_factor;
     uniform highp int u_layer_view_type;
     uniform highp int u_layer_view_type;
@@ -92,7 +98,7 @@ vertex41core =
 
 
     void main()
     void main()
     {
     {
-        gl_Position = u_modelViewProjectionMatrix * a_vertex;
+        gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
         v_color = a_color;
         v_color = a_color;
         if ((a_line_type != 8) && (a_line_type != 9)) {
         if ((a_line_type != 8) && (a_line_type != 9)) {
             v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
             v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
@@ -154,7 +160,9 @@ u_show_skin = 1
 u_show_infill = 1
 u_show_infill = 1
 
 
 [bindings]
 [bindings]
-u_modelViewProjectionMatrix = model_view_projection_matrix
+u_modelMatrix = model_matrix
+u_viewMatrix = view_matrix
+u_projectionMatrix = projection_matrix
 
 
 [attributes]
 [attributes]
 a_vertex = vertex
 a_vertex = vertex

+ 68 - 45
plugins/SimulationView/layers3d.shader

@@ -1,10 +1,10 @@
 [shaders]
 [shaders]
 vertex41core =
 vertex41core =
     #version 410
     #version 410
-    uniform highp mat4 u_modelViewProjectionMatrix;
-
     uniform highp mat4 u_modelMatrix;
     uniform highp mat4 u_modelMatrix;
-    uniform highp mat4 u_viewProjectionMatrix;
+    uniform highp mat4 u_viewMatrix;
+    uniform highp mat4 u_projectionMatrix;
+
     uniform lowp float u_active_extruder;
     uniform lowp float u_active_extruder;
     uniform lowp float u_max_feedrate;
     uniform lowp float u_max_feedrate;
     uniform lowp float u_min_feedrate;
     uniform lowp float u_min_feedrate;
@@ -104,7 +104,10 @@ vertex41core =
 geometry41core =
 geometry41core =
     #version 410
     #version 410
 
 
-    uniform highp mat4 u_viewProjectionMatrix;
+    uniform highp mat4 u_modelMatrix;
+    uniform highp mat4 u_viewMatrix;
+    uniform highp mat4 u_projectionMatrix;
+
     uniform int u_show_travel_moves;
     uniform int u_show_travel_moves;
     uniform int u_show_helpers;
     uniform int u_show_helpers;
     uniform int u_show_skin;
     uniform int u_show_skin;
@@ -136,6 +139,8 @@ geometry41core =
 
 
     void main()
     void main()
     {
     {
+        highp mat4 viewProjectionMatrix = u_projectionMatrix * u_viewMatrix;
+
         vec4 g_vertex_delta;
         vec4 g_vertex_delta;
         vec3 g_vertex_normal_horz;  // horizontal and vertical in respect to layers
         vec3 g_vertex_normal_horz;  // horizontal and vertical in respect to layers
         vec4 g_vertex_offset_horz;  // vec4 to match gl_in[x].gl_Position
         vec4 g_vertex_offset_horz;  // vec4 to match gl_in[x].gl_Position
@@ -183,65 +188,83 @@ geometry41core =
         g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0);
         g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0);
 
 
         if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) {
         if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) {
+            vec4 va_head = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert);
+            vec4 va_up =  viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert);
+            vec4 va_down = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert);
+            vec4 vb_head =  viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head + g_vertex_offset_vert);
+            vec4 vb_down = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert);
+            vec4 vb_up = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert);
+
             // Travels: flat plane with pointy ends
             // Travels: flat plane with pointy ends
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head + g_vertex_offset_vert));
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_head);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_down);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_down);
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_up);
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_head);
             //And reverse so that the line is also visible from the back side.
             //And reverse so that the line is also visible from the back side.
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert));
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_up);
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_down);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_down);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_head);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
 
 
             EndPrimitive();
             EndPrimitive();
         } else {
         } else {
+            vec4 va_m_horz = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz);
+            vec4 vb_m_horz = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz);
+            vec4 va_p_vert = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert);
+            vec4 vb_p_vert = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert);
+            vec4 va_p_horz = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz);
+            vec4 vb_p_horz = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz);
+            vec4 va_m_vert = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert);
+            vec4 vb_m_vert = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert);
+            vec4 va_head   = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head);
+            vec4 vb_head   = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head);
+
             // All normal lines are rendered as 3d tubes.
             // All normal lines are rendered as 3d tubes.
-            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz));
-            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz));
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz));
-            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert));
-            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz));
-            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz));
+            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
+            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_p_vert);
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_p_vert);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
+            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, va_m_vert);
+            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, vb_m_vert);
+            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
+            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
 
 
             EndPrimitive();
             EndPrimitive();
 
 
             // left side
             // left side
-            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz));
+            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_p_vert);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, va_head);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
 
 
             EndPrimitive();
             EndPrimitive();
 
 
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz));
-            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert));
-            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head));
-            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz));
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
+            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, va_m_vert);
+            myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, va_head);
+            myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
 
 
             EndPrimitive();
             EndPrimitive();
 
 
             // right side
             // right side
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz));
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert));
-            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head));
-            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz));
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_p_vert);
+            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, vb_head);
+            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
 
 
             EndPrimitive();
             EndPrimitive();
 
 
-            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz));
-            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert));
-            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head));
-            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz));
+            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
+            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, vb_m_vert);
+            myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, vb_head);
+            myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
 
 
             EndPrimitive();
             EndPrimitive();
         }
         }
@@ -301,9 +324,9 @@ u_min_thickness = 0
 u_max_thickness = 1
 u_max_thickness = 1
 
 
 [bindings]
 [bindings]
-u_modelViewProjectionMatrix = model_view_projection_matrix
 u_modelMatrix = model_matrix
 u_modelMatrix = model_matrix
-u_viewProjectionMatrix = view_projection_matrix
+u_viewMatrix = view_matrix
+u_projectionMatrix = projection_matrix
 u_normalMatrix = normal_matrix
 u_normalMatrix = normal_matrix
 u_lightPosition = light_0_position
 u_lightPosition = light_0_position
 
 

Some files were not shown because too many files changed in this diff