|
1 | 1 | # GWater 2 Public API
|
2 | 2 |
|
3 |
| -![cl] `gwater2.solver: FlexSolver` |
4 |
| - FlexSolver used for world water. |
5 |
| -![cl] `gwater2.renderer: FlexRenderer` |
| 3 | +![cl] `gwater2.solver: FlexSolver` \ |
| 4 | + FlexSolver used for world water. \ |
| 5 | +![cl] `gwater2.renderer: FlexRenderer` \ |
6 | 6 | FlexRenderer used for world water.
|
7 | 7 |
|
8 |
| -![cl] `gwater2.reset_solver(err: boolean)` |
9 |
| - Creates map collider and initializes world bounds. |
10 |
| -![sh] `gwater2.quick_matrix(pos: Vector?, ang: Angle?, scale: number?) -> VMatrix: mtrx` |
| 8 | +![cl] `gwater2.reset_solver(err: boolean)` \ |
| 9 | + Creates map collider and initializes world bounds. \ |
| 10 | +![sh] `gwater2.quick_matrix(pos: Vector?, ang: Angle?, scale: number?) -> VMatrix: mtrx` \ |
11 | 11 | Creates quick matrix.
|
12 | 12 |
|
13 |
| -![sv] `gwater2.ChangeParameter(parameter: string, value: any, final: boolean, sender: Player?)` |
| 13 | +![sv] `gwater2.ChangeParameter(parameter: string, value: any, final: boolean, sender: Player?)` \ |
14 | 14 | Gets parameter' value from solver. \
|
15 | 15 | See below for valid parameter list.
|
16 | 16 |
|
17 |
| -![sh] `gwater2.ResetSolver()` |
18 |
| - Resets solver on every client, removing all regular and diffuse particles. |
19 |
| -![sh] `gwater2.RemoveCloth()` |
| 17 | +![sh] `gwater2.ResetSolver()` \ |
| 18 | + Resets solver on every client, removing all regular and diffuse particles. \ |
| 19 | +![sh] `gwater2.RemoveCloth()` \ |
20 | 20 | Resets solver cloth on every client, removing all regular particles associated with cloth.
|
21 | 21 |
|
22 |
| -![sv] `gwater2.AddCloth(mtrx: VMatrix, size: Vector, particle_data: ParticleData?)` |
| 22 | +![sv] `gwater2.AddCloth(mtrx: VMatrix, size: Vector, particle_data: ParticleData?)` \ |
23 | 23 | Adds cloth. \
|
24 | 24 | Matrix translation specifies position. \
|
25 |
| - Matrix rotation specifies rotation. |
26 |
| -![sv] `gwater2.AddParticle(pos: Vector, particle_data: ParticleData?)` |
27 |
| - Adds a single particle. |
28 |
| -![sv] `gwater2.AddCylinder(mtrx: VMatrix, size: number, particle_data: ParticleData?)` |
| 25 | + Matrix rotation specifies rotation. \ |
| 26 | +![sv] `gwater2.AddParticle(pos: Vector, particle_data: ParticleData?)` \ |
| 27 | + Adds a single particle. \ |
| 28 | +![sv] `gwater2.AddCylinder(mtrx: VMatrix, size: number, particle_data: ParticleData?)` \ |
29 | 29 | Adds cylinder of particles. \
|
30 | 30 | Matrix translation specifies position. \
|
31 |
| - Matrix rotation specifies rotation. |
32 |
| -![sv] `gwater2.AddCube(mtrx: VMatrix, size: number, particle_data: ParticleData?))` |
| 31 | + Matrix rotation specifies rotation. \ |
| 32 | +![sv] `gwater2.AddCube(mtrx: VMatrix, size: number, particle_data: ParticleData?))` \ |
33 | 33 | Adds cube of particles. \
|
34 | 34 | Matrix translation specifies position. \
|
35 |
| - Matrix rotation specifies rotation. |
36 |
| -![sv] `gwater2.AddSphere(mtrx: VMatrix, radius: number, particle_data: ParticleData?))` |
| 35 | + Matrix rotation specifies rotation. \ |
| 36 | +![sv] `gwater2.AddSphere(mtrx: VMatrix, radius: number, particle_data: ParticleData?))` \ |
37 | 37 | Adds sphere of particles. \
|
38 |
| - Matrix translation specifies position. |
39 |
| -![sv] `gwater2.AddForceField(pos: Vector, radius: number, strength: number, mode: integer, linear: boolean)` |
40 |
| - Adds particle forcefield. |
41 |
| -![sv] `gwater2.AddModel(mtrx: VMatrix, model: string, particle_data: ParticleData?) -> boolean: success` |
42 |
| - Adds particles in form of model. |
43 |
| -![sv] `gwater2.RemoveSphere(mtrx: VMatrix)` |
44 |
| - **THIS IS NOT AN ACTUAL FUNCTION YET** |
| 38 | + Matrix translation specifies position. \ |
| 39 | +![sv] `gwater2.AddForceField(pos: Vector, radius: number, strength: number, mode: integer, linear: boolean)` \ |
| 40 | + Adds particle forcefield. \ |
| 41 | +![sv] `gwater2.AddModel(mtrx: VMatrix, model: string, particle_data: ParticleData?) -> boolean: success` \ |
| 42 | + Adds particles in form of model. \ |
| 43 | +![sv] `gwater2.RemoveSphere(mtrx: VMatrix)` \ |
| 44 | + **THIS IS NOT AN ACTUAL FUNCTION YET** \ |
45 | 45 | Removes sphere of particles. \
|
46 | 46 | Matrix translarion specifies position. \
|
47 |
| - Matrix scale specifies size. |
48 |
| -![sv] `gwater2.RemoveCube(mtrx: VMatrix)` |
49 |
| - **THIS IS NOT AN ACTUAL FUNCTION YET** |
| 47 | + Matrix scale specifies size. \ |
| 48 | +![sv] `gwater2.RemoveCube(mtrx: VMatrix)` \ |
| 49 | + **THIS IS NOT AN ACTUAL FUNCTION YET** \ |
50 | 50 | Removes cube of particles. \
|
51 | 51 | Matrix translarion specifies position. \
|
52 | 52 | Matrix scale specifies size.
|
53 | 53 |
|
54 | 54 | # GWater 2 Internal API
|
55 | 55 | ## ![cl] FlexSolver
|
56 |
| -![cl] `FlexSolver(limit: integer, diffuse_limit: integer?) -> FlexSolver: solver` |
| 56 | +![cl] `FlexSolver(limit: integer, diffuse_limit: integer?) -> FlexSolver: solver` \ |
57 | 57 | Creates new FlexSolver object with specified max particle and diffuse limits. \
|
58 | 58 | If `diffuse_limit` is unspecified, defaults to `limit`
|
59 | 59 |
|
60 |
| -![cl] `FlexSolver:Destroy()` |
| 60 | +![cl] `FlexSolver:Destroy()` \ |
61 | 61 | Destroys FlexSolver, freeing up all buffers and removing all particles. \
|
62 |
| - Trying to use destroyed FlexSolver will result in nil index errors. |
63 |
| -![cl] `FlexSolver:InitBounds(mins: Vector, maxs: Vector)` |
64 |
| - Initialises simulation bounds. Particles won't be able to leave this space |
65 |
| -![cl] `FlexSolver:Tick(delta: number) -> boolean: ticked` |
| 62 | + Trying to use destroyed FlexSolver will result in nil index errors. \ |
| 63 | +![cl] `FlexSolver:InitBounds(mins: Vector, maxs: Vector)` \ |
| 64 | + Initialises simulation bounds. Particles won't be able to leave this space. \ |
| 65 | +![cl] `FlexSolver:Tick(delta: number) -> boolean: ticked` \ |
66 | 66 | Ticks solver with specified delta (time that has passed since last tick, in seconds). \
|
67 | 67 | Parameters may behave incorrectly with different deltas. \
|
68 | 68 | High or low deltas can result in particles passing through stuff or becoming invalid.
|
69 | 69 |
|
70 |
| -![cl] `FlexSolver:AddMapCollider(idx: integer, mapname: string)` |
71 |
| - Attempts to add a collider from map bsp. |
72 |
| -![cl] `FlexSolver:AddConcaveCollider(idx: integer, concave: table<Vector>, pos: Vector?, ang: Angle?)` |
| 70 | +![cl] `FlexSolver:AddMapCollider(idx: integer, mapname: string)` \ |
| 71 | + Attempts to add a collider from map bsp. \ |
| 72 | +![cl] `FlexSolver:AddConcaveCollider(idx: integer, concave: table<Vector>, pos: Vector?, ang: Angle?)` \ |
73 | 73 | Adds concave collider. \
|
74 |
| - `concave` parameter has to be a sequential table with length divisible by 3, with each 3 vertices specifying a triangle. |
75 |
| -![cl] `FlexSolver:AddConvexCollider(idx: integer, convex: table<Vector>, pos: Vector?, ang: Angle?)` |
| 74 | + `concave` parameter has to be a sequential table with length divisible by 3, with each 3 vertices specifying a triangle. \ |
| 75 | +![cl] `FlexSolver:AddConvexCollider(idx: integer, convex: table<Vector>, pos: Vector?, ang: Angle?)` \ |
76 | 76 | Adds a convex collider. \
|
77 |
| - `convex` parameter has to be a sequential table with length divisible by 3, with each 3 vertices specifying a triangle. |
| 77 | + `convex` parameter has to be a sequential table with length divisible by 3, with each 3 vertices specifying a triangle. \ |
78 | 78 | ![cl] `FlexSolver:RemoveCollider(idx: integer)`
|
79 | 79 | Removes collider with specified index. \
|
80 | 80 | Does nothing if collider doesn't exist.
|
81 | 81 |
|
82 |
| -![cl] `FlexSolver:SetColliderEnabled(idx: integer, enabled: bool)` |
83 |
| - Enables collider. |
84 |
| -![cl] `FlexSolver:SetColliderPos(idx: integer, pos: Vector, dont_lerp: boolean?)` |
85 |
| - Sets collider position, telling FleX that it moved unless `dont_lerp` is true. |
86 |
| -![cl] `FlexSolver:SetColliderAng(idx: integer, ang: Angle, dont_lerp: boolean?)` |
| 82 | +![cl] `FlexSolver:SetColliderEnabled(idx: integer, enabled: bool)` \ |
| 83 | + Enables collider. \ |
| 84 | +![cl] `FlexSolver:SetColliderPos(idx: integer, pos: Vector, dont_lerp: boolean?)` \ |
| 85 | + Sets collider position, telling FleX that it moved unless `dont_lerp` is true. \ |
| 86 | +![cl] `FlexSolver:SetColliderAng(idx: integer, ang: Angle, dont_lerp: boolean?)` \ |
87 | 87 | Sets collider angle, telling FleX that it rotated unless `dont_lerp` is true.
|
88 | 88 |
|
89 |
| -![cl] `FlexSolver:ApplyContacts(radius: unknown, dampening1: unknown, buoyancy: unknown, dampening2: unknown)` |
90 |
| -![cl] `FlexSolver:IterateColliders(iterator: unknown)` |
| 89 | +![cl] `FlexSolver:ApplyContacts(radius: unknown, dampening1: unknown, buoyancy: unknown, dampening2: unknown)` \ |
| 90 | + TODO: Write description. \ |
| 91 | +![cl] `FlexSolver:IterateColliders(iterator: unknown)` \ |
| 92 | + TODO: Write description. |
91 | 93 |
|
92 |
| -![cl] `FlexSolver:GetMaxDiffuseParticles() -> integer: max_diffuse` |
93 |
| - Returns solver' diffuse particles limit. |
94 |
| -![cl] `FlexSolver:GetMaxParticles() -> integer: max_particles` |
95 |
| - Returns solver' regular particles limit. |
96 |
| -![cl] `FlexSolver:GetActiveDiffuseParticles() -> integer: active_diffuse` |
| 94 | +![cl] `FlexSolver:GetMaxDiffuseParticles() -> integer: max_diffuse` \ |
| 95 | + Returns solver' diffuse particles limit. \ |
| 96 | +![cl] `FlexSolver:GetMaxParticles() -> integer: max_particles` \ |
| 97 | + Returns solver' regular particles limit. \ |
| 98 | +![cl] `FlexSolver:GetActiveDiffuseParticles() -> integer: active_diffuse` \ |
97 | 99 | Returns active (alive and simulated) diffuse particles count. \
|
98 |
| - This will sometimes return the previous active value after a solver reset. |
99 |
| - To get around this, do a check with normal particles: |
| 100 | + This will sometimes return the previous active value after a solver reset. \ |
| 101 | + To get around this, do a check with normal particles: \ |
100 | 102 | ```lua
|
101 | 103 | local diffuse = solver:GetActiveDiffuseParticles()
|
102 | 104 | if solver:GetActiveParticles() <= 0 then
|
103 | 105 | diffuse = 0
|
104 | 106 | end
|
105 | 107 | ```
|
106 |
| -![cl] `FlexSolver:GetActiveDiffuseParticlesPos() -> Vector: pos` |
107 |
| - Gets average position of all active (alive and simulated) diffuse particles. |
108 |
| -![cl] `FlexSolver:GetActiveParticles() -> integer: active_particles` |
109 |
| - Returns active (alive and simulated) regular particles count. |
110 |
| -![cl] `FlexSolver:GetParticlesInRadius(pos: Vector, radius: number, search_limit: integer?) -> integer: in_radius` |
| 108 | +![cl] `FlexSolver:GetActiveDiffuseParticlesPos() -> Vector: pos` \ |
| 109 | + Gets average position of all active (alive and simulated) diffuse particles. \ |
| 110 | +![cl] `FlexSolver:GetActiveParticles() -> integer: active_particles` \ |
| 111 | + Returns active (alive and simulated) regular particles count. \ |
| 112 | +![cl] `FlexSolver:GetParticlesInRadius(pos: Vector, radius: number, search_limit: integer?) -> integer: in_radius` \ |
111 | 113 | Returns amount of particles in `radius` near `pos`. \
|
112 | 114 | `search_limit` limits amount of particles returned, increasing performance.
|
113 | 115 |
|
114 |
| -![cl] `FlexSolver:GetParameter(parameter: string) -> number: value` |
| 116 | +![cl] `FlexSolver:GetParameter(parameter: string) -> number: value` \ |
115 | 117 | Gets parameter' value from solver. Will error if parameter is invalid.\
|
116 |
| - See below for valid parameters. |
117 |
| -![cl] `FlexSolver:SetParameter(parameter: string, value: number)` |
| 118 | + See below for valid parameters. \ |
| 119 | +![cl] `FlexSolver:SetParameter(parameter: string, value: number)` \ |
118 | 120 | Sets parameter' value in solver. Will error if parameter is invalid. \
|
119 |
| - See below for valid parameters. |
120 |
| -![cl] `FlexSolver:EnableDiffuse(enable: boolean)` |
| 121 | + See below for valid parameters. \ |
| 122 | +![cl] `FlexSolver:EnableDiffuse(enable: boolean)` \ |
121 | 123 | Enables or disables diffuse particles.
|
122 | 124 |
|
123 |
| -![cl] `FlexSolver:Reset()` |
124 |
| - Resets solver, removing all regular and diffuse particles. |
125 |
| -![cl] `FlexSolver:ResetCloth()` |
126 |
| - Resets solver cloth, removing all regular particles associated with cloth. |
127 |
| -![cl] `FlexSolver:ResetDiffuse()` |
128 |
| - Resets solver diffuse particles, removing all of them. |
| 125 | +![cl] `FlexSolver:Reset()` \ |
| 126 | + Resets solver, removing all regular and diffuse particles. \ |
| 127 | +![cl] `FlexSolver:ResetCloth()` \ |
| 128 | + Resets solver cloth, removing all regular particles associated with cloth. \ |
| 129 | +![cl] `FlexSolver:ResetDiffuse()` \ |
| 130 | + Resets solver diffuse particles, removing all of them. \ |
129 | 131 |
|
130 |
| -![cl] `FlexSolver:AddCloth(mtrx: VMatrix, size: Vector, particle_data: ParticleData?)` |
| 132 | +![cl] `FlexSolver:AddCloth(mtrx: VMatrix, size: Vector, particle_data: ParticleData?)` \ |
131 | 133 | Adds cloth. \
|
132 | 134 | Matrix translarion specifies position. \
|
133 |
| - Matrix rotation specifies rotation. |
134 |
| -![cl] `FlexSolver:AddParticle(pos: Vector, particle_data: ParticleData?)` |
135 |
| - Adds a single particle. |
136 |
| -![cl] `FlexSolver:AddCylinder(mtrx: VMatrix, size: number, particle_data: ParticleData?)` |
| 135 | + Matrix rotation specifies rotation. \ |
| 136 | +![cl] `FlexSolver:AddParticle(pos: Vector, particle_data: ParticleData?)` \ |
| 137 | + Adds a single particle. \ |
| 138 | +![cl] `FlexSolver:AddCylinder(mtrx: VMatrix, size: number, particle_data: ParticleData?)` \ |
137 | 139 | Adds cylinder of particles. \
|
138 | 140 | Matrix translation specifies position. \
|
139 |
| - Matrix rotation specifies rotation. |
140 |
| -![cl] `FlexSolver:AddCube(mtrx: VMatrix, size: number, particle_data: ParticleData?))` |
| 141 | + Matrix rotation specifies rotation. \ |
| 142 | +![cl] `FlexSolver:AddCube(mtrx: VMatrix, size: number, particle_data: ParticleData?))` \ |
141 | 143 | Adds cube of particles. \
|
142 | 144 | Matrix translation specifies position. \
|
143 |
| - Matrix rotation specifies rotation. |
144 |
| -![cl] `FlexSolver:AddSphere(mtrx: VMatrix, radius: number, particle_data: ParticleData?))` |
| 145 | + Matrix rotation specifies rotation. \ |
| 146 | +![cl] `FlexSolver:AddSphere(mtrx: VMatrix, radius: number, particle_data: ParticleData?))` \ |
145 | 147 | Adds sphere of particles. \
|
146 |
| - Matrix translation specifies position. |
147 |
| -![cl] `FlexSolver:AddForceField(pos: Vector, radius: number, strength: number, mode: integer, linear: boolean)` |
148 |
| - Adds particle forcefield. |
149 |
| -![cl] `FlexSolver:AddMesh(mtrx: VMatrix, mesh: table<Vector>, particle_data: ParticleData?) -> boolean: success` |
| 148 | + Matrix translation specifies position. \ |
| 149 | +![cl] `FlexSolver:AddForceField(pos: Vector, radius: number, strength: number, mode: integer, linear: boolean)` \ |
| 150 | + Adds particle forcefield. \ |
| 151 | +![cl] `FlexSolver:AddMesh(mtrx: VMatrix, mesh: table<Vector>, particle_data: ParticleData?) -> boolean: success` \ |
150 | 152 | Adds mesh...? \
|
151 |
| - TODO: Do further testing. |
152 |
| -![cl] `FlexSolver:RemoveSphere(mtrx: VMatrix)` |
| 153 | + TODO: Do further testing. \ |
| 154 | +![cl] `FlexSolver:RemoveSphere(mtrx: VMatrix)` \ |
153 | 155 | Removes sphere of particles. \
|
154 | 156 | Matrix translarion specifies position. \
|
155 |
| - Matrix scale specifies size. |
156 |
| -![cl] `FlexSolver:RemoveCube(mtrx: VMatrix)` |
| 157 | + Matrix scale specifies size. \ |
| 158 | +![cl] `FlexSolver:RemoveCube(mtrx: VMatrix)` \ |
157 | 159 | Removes cube of particles. \
|
158 | 160 | Matrix translarion specifies position. \
|
159 | 161 | Matrix scale specifies size.
|
160 | 162 |
|
161 |
| -![cl] `FlexSolver:RenderParticles(iterator: fun(pos: Vector))` |
| 163 | +![cl] `FlexSolver:RenderParticles(iterator: fun(pos: Vector))` \ |
162 | 164 | Iterates over all particle and calls a function to render particles.
|
163 | 165 |
|
164 | 166 | ## FlexRenderer
|
165 |
| -![cl] `FlexRenderer() -> FlexRenderer: renderer` |
| 167 | +![cl] `FlexRenderer() -> FlexRenderer: renderer` \ |
166 | 168 | Creates new FlexRenderer object.
|
167 | 169 |
|
168 |
| -![cl] `FlexRenderer:BuildMeshes(solver: FlexSolver, diffuse_radius: radius, cull: boolean)` |
169 |
| - Builds meshes of FlexSolver object. |
170 |
| -![cl] `FlexRenderer:DrawCloth()` |
171 |
| - Draws cloth meshes. |
172 |
| -![cl] `FlexRenderer:DrawWater()` |
173 |
| - Draws water meshes. |
174 |
| -![cl] `FlexRenderer:DrawDiffuse()` |
| 170 | +![cl] `FlexRenderer:BuildMeshes(solver: FlexSolver, diffuse_radius: radius, cull: boolean)` \ |
| 171 | + Builds meshes of FlexSolver object. \ |
| 172 | +![cl] `FlexRenderer:DrawCloth()` \ |
| 173 | + Draws cloth meshes. \ |
| 174 | +![cl] `FlexRenderer:DrawWater()` \ |
| 175 | + Draws water meshes. \ |
| 176 | +![cl] `FlexRenderer:DrawDiffuse()` \ |
175 | 177 | Draws diffuse meshes.
|
176 | 178 |
|
177 | 179 | ## Utilities
|
178 |
| -![cl] `GWATER2_SET_CONTACTS(entindex: integer, contacts: integer)` |
| 180 | +![cl] `GWATER2_SET_CONTACTS(entindex: integer, contacts: integer)` \ |
179 | 181 | Will actually work only if client is listen server host. \
|
180 | 182 | Sets `Entity(entindex).GWATER2_CONTACTS` on server without networking.
|
181 | 183 |
|
|
0 commit comments