Skip to content

Commit be0faf0

Browse files
authored
xDecal: Apply Square's scratch match fixes to xDecalEmitter::update (#643)
1 parent 591b8e5 commit be0faf0

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/SB/Core/x/xDecal.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,48 +217,53 @@ namespace
217217
{
218218
void lerp(iColor_tag& out, F32 t, const iColor_tag& a, const iColor_tag& b);
219219
void lerp(U8& out, F32 t, U8 a, U8 b);
220+
void lerp(F32& out, F32 t, F32 a, F32 b);
220221
} // end of anonymous namespace
221222

222223
void xDecalEmitter::update(F32 dt)
223224
{
224-
// curve_node& node0;
225-
// curve_node& node1;
226-
F32 scale; // r20
227-
xVec4* _loc; // r2
228-
F32 par_dist; // r1
229-
225+
// Unused from DWARF
226+
// xVec4* _loc; // r2
227+
// F32 par_dist; // r1
228+
230229
debug_update(dt);
231-
F32 dage = this->ilife;
230+
F32 dage = dt * this->ilife;
232231

233232
ptank_pool__color_mat_uv2 pool;
234233
pool.reset();
235234

236235
pool.rs.texture = this->texture.asset;
236+
pool.rs.src_blend = this->cfg.blend_src;
237+
pool.rs.dst_blend = this->cfg.blend_dst;
237238
pool.rs.flags = this->cfg.flags & 0x1;
238239
this->curve_index = 0;
239-
240+
240241
static_queue<unit_data>::iterator it = this->units.begin();
241242
for (; it != this->units.end(); ++it)
242243
{
243244
unit_data& unit = *it;
244-
unit.age += dt;
245-
245+
unit.age += dage;
246+
246247
if (unit.age >= 1.0f)
247248
{
248-
continue;
249+
break;
249250
}
250251

251252
update_frac(unit);
252-
lerp(pool.color[0], unit.frac, this->curve[unit.curve_index].color, this->curve[unit.curve_index + 1].color);
253-
254-
*((F32*)&unit.mat.pos.z + 1) = unit.frac * dage; // Definitely something weird here
253+
curve_node& node0 = this->curve[unit.curve_index];
254+
curve_node& node1 = this->curve[unit.curve_index+1];
255+
256+
F32 scale;
257+
lerp(scale, unit.frac, node0.scale, node1.scale);
258+
259+
*((F32*)&unit.mat.pos.z + 1) = unit.cull_size * scale;
255260
pool.next();
256261
if (!pool.valid())
257262
{
258263
break;
259264
}
260265

261-
get_render_data(unit, dage, pool.color[0], pool.mat[0], pool.uv[0], pool.uv[1]);
266+
get_render_data(unit, scale, pool.color[0], pool.mat[0], pool.uv[0], pool.uv[1]);
262267
}
263268

264269
pool.flush();

0 commit comments

Comments
 (0)