]> git.seodisparate.com - RockPaperScissorsDuel/commitdiff
Rename V3, etc. to A3F, etc.
authorStephen Seo <seo.disparate@gmail.com>
Fri, 13 Jan 2023 07:34:40 +0000 (16:34 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 13 Jan 2023 07:34:40 +0000 (16:34 +0900)
13 files changed:
CMakeLists.txt
src/3d/a3f.cc [new file with mode: 0644]
src/3d/a3f.h [new file with mode: 0644]
src/3d/a3f_conv.cc [new file with mode: 0644]
src/3d/a3f_conv.h [new file with mode: 0644]
src/3d/obj.cc
src/3d/obj.h
src/3d/qm.cc
src/3d/v3.cc [deleted file]
src/3d/v3.h [deleted file]
src/3d/v3_conv.cc [deleted file]
src/3d/v3_conv.h [deleted file]
wasm_build/Makefile

index dcae071a0c7edf3d43f0f1061bb0c0d613eb18f6..09f62eeccc4f662470e1d1902fda858f35c7fb30 100644 (file)
@@ -22,8 +22,8 @@ set(RPSDuelNative_SOURCES
     "${CMAKE_CURRENT_SOURCE_DIR}/src/3d_renderer.cc"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/constants.cc"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/obj.cc"
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/v3.cc"
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/v3_conv.cc"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/a3f.cc"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/a3f_conv.cc"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/qm.cc"
 )
 
@@ -35,8 +35,8 @@ set(RPSDuelNative_HEADERS
     "${CMAKE_CURRENT_SOURCE_DIR}/src/basic_renderer.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/3d_renderer.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/obj.h"
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/v3.h"
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/v3_conv.h"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/a3f.h"
+    "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/a3f_conv.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/src/3d/qm.h"
 )
 
diff --git a/src/3d/a3f.cc b/src/3d/a3f.cc
new file mode 100644 (file)
index 0000000..4d1f3e2
--- /dev/null
@@ -0,0 +1,26 @@
+#include "a3f.h"
+
+A3F operator+(const A3F &a, const A3F &b) {
+  return A3F{a[0] + b[0], a[1] + b[1], a[2] + b[2]};
+}
+
+A3F operator-(const A3F &a, const A3F &b) {
+  return A3F{a[0] - b[0], a[1] - b[1], a[2] - b[2]};
+}
+
+A3F operator*(const A3F &v, float s) {
+  return A3F{v[0] * s, v[1] * s, v[2] * s};
+}
+
+A3F operator/(const A3F &v, float s) {
+  return A3F{v[0] / s, v[1] / s, v[2] / s};
+}
+
+float A3F_F::dotp(const A3F &a, const A3F &b) {
+  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
+}
+
+A3F A3F_F::crossp(const A3F &a, const A3F &b) {
+  return A3F{a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2],
+             a[0] * b[1] - a[1] * b[0]};
+}
diff --git a/src/3d/a3f.h b/src/3d/a3f.h
new file mode 100644 (file)
index 0000000..219b05f
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef ROCK_PAPER_SCISSORS_3D_ARRAY3F_H_
+#define ROCK_PAPER_SCISSORS_3D_ARRAY3F_H_
+
+#include <array>
+
+using A3F = std::array<float, 3>;
+
+A3F operator+(const A3F &a, const A3F &b);
+A3F operator-(const A3F &a, const A3F &b);
+
+A3F operator*(const A3F &v, float s);
+A3F operator/(const A3F &v, float s);
+
+using A3C = std::array<unsigned char, 3>;
+using A4C = std::array<unsigned char, 4>;
+
+namespace A3F_F {
+extern float dotp(const A3F &a, const A3F &b);
+extern A3F crossp(const A3F &a, const A3F &b);
+}  // namespace A3F_F
+
+#endif
diff --git a/src/3d/a3f_conv.cc b/src/3d/a3f_conv.cc
new file mode 100644 (file)
index 0000000..cdebf19
--- /dev/null
@@ -0,0 +1,9 @@
+#include "a3f_conv.h"
+
+Vector3 A3FToRV3(const A3F &v) { return Vector3{v[0], v[1], v[2]}; }
+
+A3F RV3ToA3F(const Vector3 &v) { return A3F{v.x, v.y, v.z}; }
+
+Color A4CToC(const A4C &v) { return Color{v[0], v[1], v[2], v[3]}; }
+
+A4C CToA4C(const Color &c) { return A4C{c.r, c.g, c.b, c.a}; }
diff --git a/src/3d/a3f_conv.h b/src/3d/a3f_conv.h
new file mode 100644 (file)
index 0000000..597afdb
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef ROCK_PAPER_SCISSORS_3D_A3F_CONV_H_
+#define ROCK_PAPER_SCISSORS_3D_A3F_CONV_H_
+
+#include "a3f.h"
+
+// third party includes
+#include <raylib.h>
+
+extern Vector3 A3FToRV3(const A3F &v);
+extern A3F RV3ToA3F(const Vector3 &v);
+
+extern Color A4CToC(const A4C &v);
+extern A4C CToA4C(const Color &c);
+
+#endif
index bd8d6fa24504c71f0aaf6a404c3f69e80351454a..7ebaf1ecbaef7a2f64d729c4d3afef9e847c29b2 100644 (file)
@@ -19,11 +19,11 @@ void Object3D::set_model(Model *model) {
   }
 }
 
-const V3 &Object3D::get_pos() const { return pos; }
+const A3F &Object3D::get_pos() const { return pos; }
 
-void Object3D::set_pos(const V3 &pos) { this->pos = pos; }
+void Object3D::set_pos(const A3F &pos) { this->pos = pos; }
 
-void Object3D::set_pos(V3 &&pos) { this->pos = std::forward<V3>(pos); }
+void Object3D::set_pos(A3F &&pos) { this->pos = std::forward<A3F>(pos); }
 
 void Object3D::set_pos_x(float x) { pos[0] = x; }
 
@@ -31,12 +31,12 @@ void Object3D::set_pos_y(float y) { pos[1] = y; }
 
 void Object3D::set_pos_z(float z) { pos[2] = z; }
 
-const VC4 &Object3D::get_color() const { return color; }
+const A4C &Object3D::get_color() const { return color; }
 
-void Object3D::set_color(const VC4 &color) { this->color = color; }
+void Object3D::set_color(const A4C &color) { this->color = color; }
 
-void Object3D::set_color(VC4 &&color) {
-  this->color = std::forward<VC4>(color);
+void Object3D::set_color(A4C &&color) {
+  this->color = std::forward<A4C>(color);
 }
 
 void Object3D::set_color_r(unsigned char r) { color[0] = r; }
index 5c41956e8500170a3c8e45054c79b5ed6d75f1d1..e6f5f9727c969105553dd18862f354895780b62c 100644 (file)
@@ -5,7 +5,7 @@
 #include <optional>
 
 // local includes
-#include "v3.h"
+#include "a3f.h"
 
 // forward declarations
 struct Model;
@@ -21,24 +21,24 @@ class Object3D {
 
   void set_model(Model *model);
 
-  const V3 &get_pos() const;
-  void set_pos(const V3 &pos);
-  void set_pos(V3 &&pos);
+  const A3F &get_pos() const;
+  void set_pos(const A3F &pos);
+  void set_pos(A3F &&pos);
   void set_pos_x(float x);
   void set_pos_y(float y);
   void set_pos_z(float z);
 
-  const VC4 &get_color() const;
-  void set_color(const VC4 &color);
-  void set_color(VC4 &&color);
+  const A4C &get_color() const;
+  void set_color(const A4C &color);
+  void set_color(A4C &&color);
   void set_color_r(unsigned char r);
   void set_color_g(unsigned char g);
   void set_color_b(unsigned char b);
   void set_color_a(unsigned char a);
 
  protected:
-  V3 pos;
-  VC4 color;
+  A3F pos;
+  A4C color;
   std::optional<Model *> model;
 };
 
index f346a3e451ae7f132ea341a938533088deb0ebce..570b54446e313707713363e1ec36be3dd973fbcb 100644 (file)
@@ -11,7 +11,7 @@
 
 // local includes
 #include "../constants.h"
-#include "v3_conv.h"
+#include "a3f_conv.h"
 
 QuestionMark::QuestionMark()
     : Object3D()
@@ -68,7 +68,7 @@ void QuestionMark::draw() {
   }
 
   Vector3 unit{1.0F, 1.0F, 1.0F};
-  Vector3 vec3pos = V3ToRV3(pos);
+  Vector3 vec3pos = A3FToRV3(pos);
   float angle = angle_timer / angle_timer_max * 2.0F - 1.0F;
   angle = angle >= 0.0F ? (std::cos(PI_F * angle) * QM_MAX_ANGLE_OFFSET)
                         : (std::cos(PI_F * (-angle)) * QM_MAX_ANGLE_OFFSET);
@@ -78,7 +78,7 @@ void QuestionMark::draw() {
                : ((std::cos(PI_F * (-offset)) + 1.0F) / 2.0F * QM_MAX_Y_OFFSET);
   vec3pos.y += offset;
   DrawModelEx(*model.value(), vec3pos, {0.0F, 1.0F, 0.0F}, angle, unit,
-              VC4ToC(color));
+              A4CToC(color));
 }
 
 void QuestionMark::randomize_timer_values() {
diff --git a/src/3d/v3.cc b/src/3d/v3.cc
deleted file mode 100644 (file)
index fae3d69..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "v3.h"
-
-V3 operator+(const V3 &a, const V3 &b) {
-  return V3{a[0] + b[0], a[1] + b[1], a[2] + b[2]};
-}
-
-V3 operator-(const V3 &a, const V3 &b) {
-  return V3{a[0] - b[0], a[1] - b[1], a[2] - b[2]};
-}
-
-V3 operator*(const V3 &v, float s) { return V3{v[0] * s, v[1] * s, v[2] * s}; }
-
-V3 operator/(const V3 &v, float s) { return V3{v[0] / s, v[1] / s, v[2] / s}; }
-
-float V3F::dotp(const V3 &a, const V3 &b) {
-  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
-}
-
-V3 V3F::crossp(const V3 &a, const V3 &b) {
-  return V3{a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2],
-            a[0] * b[1] - a[1] * b[0]};
-}
diff --git a/src/3d/v3.h b/src/3d/v3.h
deleted file mode 100644 (file)
index a03d2da..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef ROCK_PAPER_SCISSORS_3D_V3_H_
-#define ROCK_PAPER_SCISSORS_3D_V3_H_
-
-#include <array>
-
-using V3 = std::array<float, 3>;
-
-V3 operator+(const V3 &a, const V3 &b);
-V3 operator-(const V3 &a, const V3 &b);
-
-V3 operator*(const V3 &v, float s);
-V3 operator/(const V3 &v, float s);
-
-using VC3 = std::array<unsigned char, 3>;
-using VC4 = std::array<unsigned char, 4>;
-
-namespace V3F {
-extern float dotp(const V3 &a, const V3 &b);
-extern V3 crossp(const V3 &a, const V3 &b);
-}  // namespace V3F
-
-#endif
diff --git a/src/3d/v3_conv.cc b/src/3d/v3_conv.cc
deleted file mode 100644 (file)
index 6eb61a8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "v3_conv.h"
-
-Vector3 V3ToRV3(const V3 &v) { return Vector3{v[0], v[1], v[2]}; }
-
-V3 RV3ToV3(const Vector3 &v) { return V3{v.x, v.y, v.z}; }
-
-Color VC4ToC(const VC4 &v) { return Color{v[0], v[1], v[2], v[3]}; }
-
-VC4 CToVC4(const Color &c) { return VC4{c.r, c.g, c.b, c.a}; }
diff --git a/src/3d/v3_conv.h b/src/3d/v3_conv.h
deleted file mode 100644 (file)
index 72443fa..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef ROCK_PAPER_SCISSORS_3D_V3_CONF_H_
-#define ROCK_PAPER_SCISSORS_3D_V3_CONF_H_
-
-#include "v3.h"
-
-// third party includes
-#include <raylib.h>
-
-extern Vector3 V3ToRV3(const V3 &v);
-extern V3 RV3ToV3(const Vector3 &v);
-
-extern Color VC4ToC(const VC4 &v);
-extern VC4 CToVC4(const Color &c);
-
-#endif
index 898a0e20ce71131a94a448c5c394f3d4bc53fb76..395b76ff117bfc6310dc33f08c13126267adfb27 100644 (file)
@@ -12,8 +12,8 @@ SOURCES = \
                ../src/3d_renderer.cc \
                ../src/constants.cc \
                ../src/3d/obj.cc \
-               ../src/3d/v3.cc \
-               ../src/3d/v3_conv.cc \
+               ../src/3d/a3f.cc \
+               ../src/3d/a3f_conv.cc \
                ../src/3d/qm.cc
 
 HEADERS = \
@@ -24,8 +24,8 @@ HEADERS = \
                ../src/game_renderer.h \
                ../src/3d_renderer.h \
                ../src/3d/obj.h \
-               ../src/3d/v3.h \
-               ../src/3d/v3_conv.h \
+               ../src/3d/a3f.h \
+               ../src/3d/a3f_conv.h \
                ../src/3d/qm.h
 
 CXX = source ${HOME}/git/emsdk/emsdk_env.sh && em++