Skip to content

Commit 579a53c

Browse files
unfixed yet
1 parent 4a62e67 commit 579a53c

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

.github/workflows/cmake.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
echo "Running prime -s 100"
4141
./prime -s 100
4242
echo "Running prime -l 100"
43-
./prime -l 1k
43+
./prime -l 100
4444
echo "Running prime -n 104729"
4545
./prime -n 104729
4646
echo "Running prime -i 1m"
@@ -49,3 +49,5 @@ jobs:
4949
./fibonacci -l 10
5050
echo "Running fibonacci -i 100"
5151
./fibonacci -i 100
52+
echo "Running test_3d"
53+
./test_3d

3D/include/matrix.hxx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ class Mat {
3333
for (int i = 0; i < N * N; ++i) arr[i] = vals[i];
3434
}
3535

36-
std::vector<T> to_vector() const { return std::vector<T>(vals, vals + N * N); }
36+
std::vector<T> to_vector() const {
37+
return std::vector<T>(vals, vals + N * N);
38+
}
3739

3840
void set_elements(T (&v)[N * N]) {
3941
for (int i = 0; i < N * N; ++i) vals[i] = v[i];
@@ -59,9 +61,7 @@ class Mat {
5961
vals[row * N + col] = 0;
6062
}
6163

62-
void set_element(size_t i, T valsue){
63-
vals[i] = valsue;
64-
}
64+
void set_element(size_t i, T valsue) { vals[i] = valsue; }
6565

6666
template <typename U>
6767
Mat operator*(U fp) const {
@@ -204,7 +204,7 @@ class Mat {
204204

205205
return Mat(res);
206206
}
207-
const T *data() const { return vals; }
207+
const T *data() { return vals; }
208208
};
209209

210210
// usage Mat3<double> or Mat3<float>
@@ -236,8 +236,9 @@ Mat<T, 4> mat3_to_mat4(const Mat<T, 3> &m) {
236236
return Mat<T, 4>(res_arr);
237237
}
238238

239-
// operasi matriks 4×4 * 3×3
240-
// rubah dulu yang 3×3 ke 4×4 dengan menambahkan komponen w
239+
/*operasi matriks 4×4 * 3×3
240+
* rubah dulu yang 3×3 ke 4×4 dengan menambahkan komponen w
241+
*/
241242
template <typename T>
242243
Mat<T, 4> operator*(const Mat<T, 4> &a, const Mat<T, 3> &b) {
243244
return a * mat3_to_mat4<T>(b);

3D/include/obj3d.hxx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ class Obj3D {
1212
Mat<FP, 3> QcurrMat;
1313
Vec3<FP> pos;
1414
std::vector<Vec3<FP>> vertices;
15-
std::vector<Vec3<I>> face_indices;
16-
std::vector<Vec3<FP>> renew_vertices;
15+
std::vector<Vec3<I>> faceIndices;
16+
std::vector<Vec3<FP>> newVertices;
1717
std::vector<Vec3<FP>> normals;
1818

1919
// update vertices
2020
void update_vertices() {
21-
for (size_t i = 0; i < face_indices.size(); ++i) {
22-
Vec3 f_i = face_indices[i];
21+
for (size_t i = 0; i < faceIndices.size(); ++i) {
22+
Vec3 f_i = faceIndices[i];
2323
assert(f_i.x() > 0 && f_i.x() < vertices.size());
2424
assert(f_i.y() > 0 && f_i.y() < vertices.size());
2525
assert(f_i.z() > 0 && f_i.z() < vertices.size());
26-
renew_vertices.push_back(vertices[f_i.x()]);
27-
renew_vertices.push_back(vertices[f_i.y()]);
28-
renew_vertices.push_back(vertices[f_i.z()]);
26+
newVertices.push_back(vertices[f_i.x()]);
27+
newVertices.push_back(vertices[f_i.y()]);
28+
newVertices.push_back(vertices[f_i.z()]);
2929
}
3030
}
3131

@@ -34,8 +34,8 @@ class Obj3D {
3434
* otomatis memperbarui vertices tapi originalnya tidak dihapus agar lebih
3535
* mudah diambil nanti
3636
*/
37-
Obj3D(std::vector<Vec3<FP>> vertices, std::vector<Vec3<I>> face_indices)
38-
: vertices(vertices), face_indices(face_indices) {
37+
Obj3D(std::vector<Vec3<FP>> vertices, std::vector<Vec3<I>> faceIndices)
38+
: vertices(vertices), faceIndices(faceIndices) {
3939
update_vertices();
4040
QcurrMat.set_identity();
4141
modelMat.set_identity();
@@ -71,24 +71,24 @@ class Obj3D {
7171
return res;
7272
}
7373

74-
std::vector<Vec3<I>> get_face_index() const { return face_indices; }
74+
std::vector<Vec3<I>> get_face_index() const { return faceIndices; }
7575
std::vector<Vec3<FP>> get_default_vertices() const { return vertices; }
7676
std::vector<Vec3<FP>> get_processed_vertices() const {
77-
return renew_vertices;
77+
return newVertices;
7878
}
7979
// setter
8080
void update_vertices(std::vector<Vec3<FP>> vertices) {
8181
this->vertices = vertices;
8282
update_vertices();
8383
}
84-
void update_face(std::vector<Vec3<FP>> face_indices) {
85-
this->face_indices = face_indices;
84+
void update_face(std::vector<Vec3<FP>> faceIndices) {
85+
this->faceIndices = faceIndices;
8686
update_vertices();
8787
}
8888
void update_face_vertices(std::vector<Vec3<FP>> vertices,
89-
std::vector<Vec3<I>> face_indices) {
89+
std::vector<Vec3<I>> faceIndices) {
9090
this->vertices = vertices;
91-
this->face_indices = face_indices;
91+
this->faceIndices = faceIndices;
9292
update_vertices();
9393
}
9494
};

3D/include/vec.hxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ class Vec {
5050
VEC_OV_ASSIGNMENT(/);
5151
#undef VEC_OV_ASSIGNMENT
5252

53-
// karena SFINAE hanya bisa non error jika di paeameter template
54-
// atau di parameter fungsi maka pengecekan diletakan di parametee template
5553
#define GETTER_XYZ(type, index) \
5654
template <typename U = T> \
5755
is_type_t<(N >= 3), U> type() const { \

0 commit comments

Comments
 (0)