Browse Source

use more const references and fix light colors in console

Kolja Strohm 2 months ago
parent
commit
d693a2dbfa
8 changed files with 51 additions and 40 deletions
  1. 10 7
      Console.cpp
  2. 2 1
      Fenster.cpp
  3. 9 5
      Fenster.h
  4. 2 2
      Logging.cpp
  5. 9 8
      Model3D.cpp
  6. 9 9
      Model3D.h
  7. 6 4
      Zeichnung3D.cpp
  8. 4 4
      Zeichnung3D.h

+ 10 - 7
Console.cpp

@@ -264,9 +264,10 @@ int Framework::StickyConsoleContent::print() const
                     }
                     else
                     {
-                        std::cout << Text("\033[1;")
-                                         + Text(100 + (int)backgroundColor[i])
-                                         + "m";
+                        std::cout
+                            << Text("\033[1;")
+                                   + Text(100 + (int)backgroundColor[i] - 8)
+                                   + "m";
                     }
                 }
             }
@@ -276,7 +277,8 @@ int Framework::StickyConsoleContent::print() const
             }
             else
             {
-                std::cout << Text("\033[1;") + Text(90 + (int)color[i]) + "m";
+                std::cout << Text("\033[1;") + Text(90 + (int)color[i] - 8)
+                                 + "m";
             }
         }
         if (backgroundColor && (int)backgroundColor[i] != lastBgColor)
@@ -293,8 +295,8 @@ int Framework::StickyConsoleContent::print() const
                     }
                     else
                     {
-                        std::cout
-                            << Text("\033[1;") + Text(90 + (int)color[i]) + "m";
+                        std::cout << Text("\033[1;")
+                                         + Text(90 + (int)color[i] - 8) + "m";
                     }
                 }
             }
@@ -306,7 +308,8 @@ int Framework::StickyConsoleContent::print() const
             else
             {
                 std::cout << Text("\033[1;")
-                                 + Text(100 + (int)backgroundColor[i]) + "m";
+                                 + Text(100 + (int)backgroundColor[i] - 8)
+                                 + "m";
             }
         }
         std::cout << content[i];

+ 2 - 1
Fenster.cpp

@@ -544,7 +544,8 @@ void WFenster::setSize(int breite, int h
         hWnd, 0, res.left, res.top, res.right, res.bottom, 0); // Größe ändern
 }
 
-void WFenster::setBounds(Punkt& p, Punkt& g) // setzt größe und Position
+void WFenster::setBounds(
+    const Punkt& p, const Punkt& g) // setzt größe und Position
 {
     SetWindowPos(hWnd, 0, p.x, p.y, g.x, g.y, 0); // Größe und Position ändern
 }

+ 9 - 5
Fenster.h

@@ -115,7 +115,7 @@ namespace Framework
         //! Setzt die Position und die Größe des Fensters
         //! \param pos Die Position in Pixeln
         //! \param größe Die Größe in Pixeln
-        DLLEXPORT void setBounds(Punkt& pos, Punkt& größe);
+        DLLEXPORT void setBounds(const Punkt& pos, const Punkt& größe);
         //! Setzt das Verwendete Bildschirm Objekt, um Tastatur und Maus
         //! Eingaben an die Objekte des Frameworks weiterzugeben. Muss vor dem
         //! Zerstören des Fensters mit 0 aufgerufen werden. \param screen Das
@@ -373,7 +373,8 @@ namespace Framework
             //! Legt fest, ob die untere Seite des Fensters fixiert ist wenn die
             //! größe änderbar ist
             static const __int64 BottomPositionFixed = 0x2000000000;
-            //! Legt fest, ob die Position und Größe des Titel Textfeldes unverändert bleiben soll
+            //! Legt fest, ob die Position und Größe des Titel Textfeldes
+            //! unverändert bleiben soll
             static const __int64 CustomTitle = 0x4000000000;
             //! Vereint die Flags MinHö, MaxHö, MaxBr, MaxHö
             static const __int64 min_max = MinHi | MaxHi | MaxBr | MaxHi;
@@ -592,14 +593,17 @@ namespace Framework
         //! \param scroll Die Anzahl der Pixel, die der Inhalt nach oben
         //! verschoben werden soll
         DLLEXPORT void setVSBScroll(int scroll);
-        //! Updates the horizontal scrollbar so that the max scroll size is set to the width of the content
+        //! Updates the horizontal scrollbar so that the max scroll size is set
+        //! to the width of the content
         DLLEXPORT void updateHScroll();
-        //! Updates the vertical scrollbar so that the max scroll size is set to the height of the content
+        //! Updates the vertical scrollbar so that the max scroll size is set to
+        //! the height of the content
         DLLEXPORT void updateVScroll();
         //! Fügt dem Fenster eine Zeichnung hinzu
         //! \param obj Die Zeichnung
         DLLEXPORT virtual void addMember(Zeichnung* obj);
-        //! sets the position of a member to index. This changes the order of rendering and the order input events are processed
+        //! sets the position of a member to index. This changes the order of
+        //! rendering and the order input events are processed
         DLLEXPORT void setMemberIndex(Zeichnung* zMember, int index);
         //! Entfernt eine Zeichnung aus dem Fenster
         //! \param zObj Die Zeichnung (ohne erhöhten reference Counter)

+ 2 - 2
Logging.cpp

@@ -383,7 +383,7 @@ public:
             }
             else
             {
-                return Text("\033[1;") + Text(90 + (int)color) + "m"
+                return Text("\033[1;") + Text(90 + (int)color - 8) + "m"
                      + after->formatMessage(msg, level, location) + "\033[0m";
             }
         }
@@ -449,7 +449,7 @@ public:
             }
             else
             {
-                return Text("\033[1;") + Text(100 + (int)color) + "m"
+                return Text("\033[1;") + Text(100 + (int)color - 8) + "m"
                      + after->formatMessage(msg, level, location) + "\033[0m";
             }
         }

+ 9 - 8
Model3D.cpp

@@ -96,10 +96,10 @@ bool Bone::addChildBone(int id, Bone* b)
 //! \param matBuffer the array to store the calculated matrixes
 //! \param scaleFactor the scaling of the object
 //! \param camMatrix the view-projection matrix of the used camera
-void Bone::calculateMatrix(Mat4<float>& elternMat,
+void Bone::calculateMatrix(const Mat4<float>& elternMat,
     Mat4<float>* matBuffer,
     float scaleFactor,
-    Mat4<float>& kamMat)
+    const Mat4<float>& kamMat)
 {
     if (sibling)
         sibling->calculateMatrix(elternMat, matBuffer, scaleFactor, kamMat);
@@ -246,10 +246,10 @@ int Skeleton::addBone(Vec3<float> pos, Vec3<float> rot, int parentId)
 //! model \param matBuffer the array to store the calculated matrixes
 //! \param scaleFactor the scaling of the object
 //! \param camMatrix the view-projection matrix of the used camera
-int Skeleton::calculateMatrix(Mat4<float>& modelMatrix,
+int Skeleton::calculateMatrix(const Mat4<float>& modelMatrix,
     Mat4<float>* matBuffer,
     float scaleFactor,
-    Mat4<float>& kamMatrix)
+    const Mat4<float>& kamMatrix)
 {
     rootBone->calculateMatrix(modelMatrix, matBuffer, scaleFactor, kamMatrix);
     return nextId;
@@ -546,10 +546,10 @@ void Model3DData::removePolygon(int index)
 //  wird scaleFactor: Die Skallierung des Modells kamMatrix: Die vereiniegung
 //  der view und projektions Matrizen return: gibt die Anzahl der verwendeten
 //  Matrizen zurück
-int Model3DData::kalkulateMatrix(Mat4<float>& modelMatrix,
+int Model3DData::kalkulateMatrix(const Mat4<float>& modelMatrix,
     Mat4<float>* matBuffer,
     float scaleFactor,
-    Mat4<float>& kamMatrix) const
+    const Mat4<float>& kamMatrix) const
 {
     if (!skelett) return 0;
     return skelett->calculateMatrix(
@@ -784,7 +784,8 @@ void Framework::Model3D::setSpecularFactor(float f)
 //  viewProj: Die miteinander multiplizierten Kameramatrizen
 //  matBuffer: Ein Array mit Matrizen, der gefüllt werden soll
 //  return: Die Anzahl der Matrizen, die das Model benötigt
-int Model3D::errechneMatrizen(Mat4<float>& viewProj, Mat4<float>* matBuffer)
+int Model3D::errechneMatrizen(
+    const Mat4<float>& viewProj, Mat4<float>* matBuffer)
 {
     int ret = 0;
     if (skelett)
@@ -850,7 +851,7 @@ Model3DData* Model3D::zModelData()
 //  return: den quadratischen Abstand des Schnittpunktes zum Ursprung des
 //  Strahls oder -1, wenn kein schnittpunkt existiert
 float Model3D::traceRay(
-    Vec3<float>& p, Vec3<float>& d, float maxSqDist, int& pId) const
+    const Vec3<float>& p, const Vec3<float>& d, float maxSqDist, int& pId) const
 {
     if (!model) return -1;
     Vec3<float> dir = d;

+ 9 - 9
Model3D.h

@@ -59,10 +59,10 @@ namespace Framework
         //! \param matBuffer the array to store the calculated matrixes
         //! \param scaleFactor the scaling of the object
         //! \param camMatrix the view-projection matrix of the used camera
-        DLLEXPORT void calculateMatrix(Mat4<float>& elternMat,
+        DLLEXPORT void calculateMatrix(const Mat4<float>& elternMat,
             Mat4<float>* matBuffer,
             float scaleFactor,
-            Mat4<float>& camMatrix);
+            const Mat4<float>& camMatrix);
         //! \return the first sibling bone
         DLLEXPORT Bone* zFirstSibling() const;
         //! \return the first child bone
@@ -109,10 +109,10 @@ namespace Framework
         //! model \param matBuffer the array to store the calculated matrixes
         //! \param scaleFactor the scaling of the object
         //! \param camMatrix the view-projection matrix of the used camera
-        DLLEXPORT int calculateMatrix(Mat4<float>& modelMatrix,
+        DLLEXPORT int calculateMatrix(const Mat4<float>& modelMatrix,
             Mat4<float>* matBuffer,
             float scaleFactor,
-            Mat4<float>& camMatrix);
+            const Mat4<float>& camMatrix);
         //! \return the radius of the sceleton
         DLLEXPORT float getRadius() const;
         //! \return the root bone of the sceleton
@@ -225,10 +225,10 @@ namespace Framework
         //! Modells \param kamMatrix Die vereiniegung der view und projektions
         //! Matrizen \return gibt die Anzahl der verwendeten Matrizen zurück. 0,
         //! falls kein Standart Skelett gesetzt wurde
-        int kalkulateMatrix(Mat4<float>& modelMatrix,
+        int kalkulateMatrix(const Mat4<float>& modelMatrix,
             Mat4<float>* matBuffer,
             float scaleFactor,
-            Mat4<float>& kamMatrix) const;
+            const Mat4<float>& kamMatrix) const;
         //! Gibt die Anzahl an Polygonen zurück
         DLLEXPORT int getPolygonAnzahl() const;
         //! Gibt ein bestimmtes Polygon zurück
@@ -336,7 +336,7 @@ namespace Framework
         //! \param matBuffer Ein Array mit Matrizen, der gefüllt werden soll
         //! \return Die Anzahl der Matrizen, die das Model benötigt
         DLLEXPORT int errechneMatrizen(
-            Mat4<float>& viewProj, Mat4<float>* matBuffer) override;
+            const Mat4<float>& viewProj, Mat4<float>* matBuffer) override;
         //! Verarbeitet die vergangene Zeit
         //! \param tickval Die zeit in sekunden, die seit dem letzten Aufruf der
         //! Funktion vergangen ist \return true, wenn sich das Objekt verändert
@@ -362,8 +362,8 @@ namespace Framework
         //! \param pId die Id des Polygons, zu dem der Schnittpunkt gehört
         //! \return den quadratischen Abstand des Schnittpunktes zum Ursprung
         //! des Strahls oder -1, wenn kein schnittpunkt existiert
-        DLLEXPORT virtual float traceRay(Vec3<float>& point,
-            Vec3<float>& dir,
+        DLLEXPORT virtual float traceRay(const Vec3<float>& point,
+            const Vec3<float>& dir,
             float maxSqDist,
             int& pId) const;
         //! berechnet die Farbe des Schnittpunktes deines Strahls

+ 6 - 4
Zeichnung3D.cpp

@@ -21,7 +21,7 @@ Zeichnung3D::~Zeichnung3D() {}
 
 // Setzt die Position der Zeichnung in der Welt
 //  p: Die Position
-void Zeichnung3D::setPosition(Vec3<float>& p)
+void Zeichnung3D::setPosition(const Vec3<float>& p)
 {
     pos = p;
     rend = 1;
@@ -65,7 +65,7 @@ void Zeichnung3D::setZ(float z)
 
 // Setzt die Drehung der Zeichnung in der Welt
 //  d: Die drehung um die x, y und z achse
-void Zeichnung3D::setDrehung(Vec3<float>& d)
+void Zeichnung3D::setDrehung(const Vec3<float>& d)
 {
     angle = d;
     rend = 1;
@@ -126,7 +126,8 @@ void Zeichnung3D::setSize(float size)
 //  viewProj: Die miteinander multiplizierten Kameramatrizen
 //  matBuffer: Ein Array mit Matrizen, der gefüllt werden soll
 //  return: Die Anzahl der Matrizen, die die Zeichnung benötigt
-int Zeichnung3D::errechneMatrizen(Mat4<float>& viewProj, Mat4<float>* matBuffer)
+int Zeichnung3D::errechneMatrizen(
+    const Mat4<float>& viewProj, Mat4<float>* matBuffer)
 {
     matBuffer[0] = viewProj * welt;
     return 1;
@@ -226,7 +227,8 @@ const Mat4<float>& Zeichnung3D::getMatrix() const
 
 //! Berechnet wür einen Punkt in lokalen Zeichnungs Koordinaten den Punkt in
 //! Weltkoordinaten durch anwendung von Drehung, Skallierung und Verschiebung
-Vec3<float> Zeichnung3D::applyWorldTransformation(Vec3<float> modelPos) const
+Vec3<float> Zeichnung3D::applyWorldTransformation(
+    const Vec3<float>& modelPos) const
 {
     return welt * modelPos;
 }

+ 4 - 4
Zeichnung3D.h

@@ -29,7 +29,7 @@ namespace Framework
         DLLEXPORT virtual ~Zeichnung3D();
         //! Setzt die Position der Zeichnung in der Welt
         //! \param p Die Position
-        DLLEXPORT void setPosition(Vec3<float>& p);
+        DLLEXPORT void setPosition(const Vec3<float>& p);
         //! Setzt die Position der Zeichnung in der Welt
         //! \param x Die x Position
         //! \param y Die y Position
@@ -46,7 +46,7 @@ namespace Framework
         DLLEXPORT void setZ(float z);
         //! Setzt die Drehung der Zeichnung in der Welt
         //! \param d Die drehung um die x, y und z achse
-        DLLEXPORT void setDrehung(Vec3<float>& d);
+        DLLEXPORT void setDrehung(const Vec3<float>& d);
         //! Setzt die Drehung der Zeichnung in der Welt
         //! \param xWinkel Die drehung um die x achse
         //! \param yWinkel Die drehung um die y achse
@@ -72,7 +72,7 @@ namespace Framework
         //! \param matBuffer Ein Array mit Matrizen, der gefüllt werden soll
         //! \return Die Anzahl der Matrizen, die die Zeichnung benötigt
         DLLEXPORT virtual int errechneMatrizen(
-            Mat4<float>& viewProj, Mat4<float>* matBuffer);
+            const Mat4<float>& viewProj, Mat4<float>* matBuffer);
         //! Verarbeitet ein Mausereignis
         //! \param me Das Mausereignis, das verarbeitet werden soll
         DLLEXPORT virtual void doMausEreignis(MausEreignis3D& me);
@@ -114,6 +114,6 @@ namespace Framework
         //! Punkt in Weltkoordinaten durch anwendung von Drehung, Skallierung
         //! und Verschiebung
         DLLEXPORT Vec3<float> applyWorldTransformation(
-            Vec3<float> modelPos) const;
+            const Vec3<float>& modelPos) const;
     };
 } // namespace Framework