Add tint and fixed size to be divided by 32

This commit is contained in:
Goodlyay 2020-02-22 00:25:22 -08:00
parent 94bc9b02b1
commit 8bdce11220
3 changed files with 13 additions and 6 deletions

View File

@ -332,6 +332,7 @@ static void CustomParticle_Render(struct CustomParticle* p, float t, VertexP3fT2
x = Math_Floor(pos.X); y = Math_Floor(pos.Y); z = Math_Floor(pos.Z);
col = p->prop->fullBright ? PACKEDCOL_WHITE : (World_Contains(x, y, z) ? Lighting_Col(x, y, z) : Env.SunCol);
col = PackedCol_Tint(col, p->prop->tint);
Particle_DoRender(&size, &pos, &rec, col, vertices);
}

View File

@ -19,6 +19,7 @@ struct Particle {
struct CustomParticleProperty {
TextureRec rec;
PackedCol tint;
int frameCount;
int particleCount; //how many of this particle are spawned per spawn-packet
float size; //size of the particle in fixed-point world units (e.g. 32 is a full block's length)

View File

@ -1346,10 +1346,13 @@ static void CPE_DefineParticle(cc_uint8* data) {
cc_uint8 V1 = data[2];
cc_uint8 U2 = data[3];
cc_uint8 V2 = data[4];
cc_uint8 frameCount = data[5];
cc_uint8 particleCount = data[6];
cc_uint8 size = data[7];
data += 8;
cc_uint8 tintRed = data[5];
cc_uint8 tintGreen = data[6];
cc_uint8 tintBlue = data[7];
cc_uint8 frameCount = data[8];
cc_uint8 particleCount = data[9];
cc_uint8 size = data[10];
data += 11;
int sizeVariation = (int)Stream_GetU32_BE(&data[0]);
int spread = (int)Stream_GetU32_BE(&data[4]);
int speed = (int)Stream_GetU32_BE(&data[8]);
@ -1366,9 +1369,11 @@ static void CPE_DefineParticle(cc_uint8* data) {
//e.g. bounds of 0 0, 16 16 makes an 8x8 icon in the default 128x128 particles.png
TextureRec rec = { U1/256, V1/256, U2/256, V2/256 };
prop->rec = rec;
PackedCol tint = PackedCol_Make(tintRed, tintGreen, tintBlue, 255);
prop->tint = tint;
prop->frameCount = frameCount;
prop->particleCount = particleCount;
prop->size = size;
prop->size = size * 0.03125; //divided by 32 to turn it into world units
prop->sizeVariation = sizeVariation / 10000.0f;
prop->spread = spread;
prop->speed = speed / 10000.0f;
@ -1434,7 +1439,7 @@ static void CPE_Reset(void) {
Net_Set(OPCODE_SET_HOTBAR, CPE_SetHotbar, 3);
Net_Set(OPCODE_SET_SPAWNPOINT, CPE_SetSpawnPoint, 9);
Net_Set(OPCODE_VELOCITY_CONTROL, CPE_VelocityControl, 16);
Net_Set(OPCODE_DEFINE_PARTICLE, CPE_DefineParticle, 35);
Net_Set(OPCODE_DEFINE_PARTICLE, CPE_DefineParticle, 38);
Net_Set(OPCODE_SPAWN_PARTICLE, CPE_SpawnParticle, 26);
}