Skip to content

Commit ce2598e

Browse files
committed
feat(cloth): add state buffers
1 parent 30b79fe commit ce2598e

26 files changed

Lines changed: 723 additions & 569 deletions

modules/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cc_library(
1414
}),
1515
hdrs = [
1616
"graphics/types.h",
17+
"graphics/real.h",
1718
"graphics/camera.h",
1819
"graphics/components.h",
1920
"graphics/fonts.h",

modules/graphics/real.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include <Eigen/Dense>
4+
5+
// matches graphics::scalar_real
6+
using Real = float;
7+
8+
namespace Eigen {
9+
using Vector3r = Matrix<Real, 3, 1, DontAlign>;
10+
using Vector4r = Matrix<Real, 4, 1, DontAlign>;
11+
using Matrix2r = Matrix<Real, 2, 2>;
12+
using Matrix3r = Matrix<Real, 3, 3>;
13+
using VectorXr = Matrix<Real, Dynamic, 1>;
14+
using ArrayXr = Array<Real, Dynamic, 1>;
15+
using MatrixXr = Matrix<Real, Dynamic, Dynamic>;
16+
} // namespace Eigen

small/cloth/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ cc_library(
2323
"components/render.h",
2424
"components/solver.h",
2525
"physics.h",
26+
"physics/bridge.h",
2627
"physics/integration.h",
28+
"physics/model.h",
2729
"physics/spring.h",
30+
"physics/state.h",
2831
"queries.h",
2932
"vars.h",
3033
"systems.h",
@@ -71,7 +74,6 @@ cc_library(
7174
cc_binary(
7275
name = "bench",
7376
srcs = [
74-
"bench/bench.h",
7577
"bench/bench.cpp",
7678
],
7779
data = [

small/cloth/assets/all.flecs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ p1 {
88
Position: { 1, 0, 0 }
99
Velocity: { x: 0, y: 0, z: 0 }
1010
Mass: { 1.0 }
11-
ParticleIndex: { 0 }
1211
Particle
1312
ParticleState: { Selected }
1413
IsPinned
@@ -18,7 +17,6 @@ p2 {
1817
Position: { x: 1, y: 0, z: 0 }
1918
Velocity: { x: 0, y: 0, z: 0 }
2019
Mass: { 1.0 }
21-
ParticleIndex: { 1 }
2220
Particle
2321
}
2422

@@ -54,7 +52,6 @@ for y in 0..$height {
5452
Position: { x: $start_x + $x * $spacing, y: $start_y, z: $start_z - $y * $spacing }
5553
Velocity: { x: 0, y: 0, z: 0 }
5654
Mass: { $mass }
57-
ParticleIndex: { $particle_offset + $y * $width + $x }
5855
Particle
5956
}
6057
}

small/cloth/assets/cloth.flecs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ for y in 0..$height {
2626
Position: { x: $start_x + $x * $spacing, y: $start_y, z: $start_z - $y * $spacing }
2727
Velocity: { x: 0, y: 0, z: 0 }
2828
Mass: { $mass }
29-
ParticleIndex: { $y * $width + $x }
3029
Particle
3130
}
3231
}

small/cloth/assets/default.flecs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ for y in 0..$height {
2020
Position: { x: $start_x + $x * $spacing, y: $start_y, z: $start_z - $y * $spacing }
2121
Velocity: { x: 0, y: 0, z: 0 }
2222
Mass: { $mass }
23-
ParticleIndex: { $y * $width + $x }
2423
Particle
2524
}
2625
}

small/cloth/assets/hammock.flecs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ for y in 0..$height {
2525
Position: { x: $start_x + $x * $spacing, y: $start_y, z: $start_z - $y * $spacing }
2626
Velocity: { x: 0, y: 0, z: 0 }
2727
Mass: { $mass }
28-
ParticleIndex: { $y * $width + $x }
2928
Particle
3029
}
3130
}

small/cloth/assets/intro.flecs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ for y in 0..$height {
2525
Position: { x: $start_x + $x * $spacing, y: $start_y, z: $start_z - $y * $spacing }
2626
Velocity: { x: 0, y: 0, z: 0 }
2727
Mass: { $mass }
28-
ParticleIndex: { $y * $width + $x }
2928
Particle
3029
}
3130
}

small/cloth/assets/spring.flecs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ p1 {
44
Position: { x: 0, y: 0, z: 0 }
55
Velocity: { x: 0, y: 0, z: 0 }
66
Mass: { 1.0 }
7-
ParticleIndex: { 0 }
87
Particle
98
IsPinned
109
}
@@ -13,7 +12,6 @@ p2 {
1312
Position: { x: 1, y: 0, z: 0 }
1413
Velocity: { x: 0, y: 0, z: 0 }
1514
Mass: { 1.0 }
16-
ParticleIndex: { 1 }
1715
Particle
1816
}
1917

small/cloth/assets/spring2.flecs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ p_0 {
1717
Position: { x: 0, y: $start_y, z: 0 }
1818
Velocity: { x: 0, y: 0, z: 0 }
1919
Mass: { $mass }
20-
ParticleIndex: { 0 }
2120
Particle
2221
IsPinned
2322
}
@@ -27,7 +26,6 @@ for i in 1..$count {
2726
Position: { x: $i * $spacing, y: $start_y, z: 0 }
2827
Velocity: { x: 0, y: 0, z: 0 }
2928
Mass: { $mass }
30-
ParticleIndex: { $i }
3129
Particle
3230
}
3331
}

0 commit comments

Comments
 (0)