Skip to content

Commit

Permalink
Fixed bug in level saving caused type inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklbell committed Oct 11, 2022
1 parent ee4ad7e commit b0b0ec7
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 21 deletions.
Binary file modified data/levels/vegetation_test.level
Binary file not shown.
2 changes: 1 addition & 1 deletion data/shaders/lib/vegetation.gl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ vec3 applyWindToVegetation(vec3 v, vec3 n, float branch_atten, float branch_phas
v.xyz += wave_sum.xxy * vec3((1.0-edge_atten) * fDetailAmp * n.xy, (1.0-branch_atten) * fBranchAmp);

//const float fBendScale = 0.1 + 0.1*sin(0.5*time);
const float fBendScale = 0.0;
const float fBendScale = 0.005;
// Bend factor - Wind variation is done on the CPU.
float fBF = v.z * fBendScale;
// Smooth bending factor and increase its nearby height limit.
Expand Down
14 changes: 1 addition & 13 deletions src/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ static void readColliderEntity(ColliderEntity* e, FILE *f) {
static void writeVegetationEntity(VegetationEntity* e, std::unordered_map<uint64_t, uint64_t> asset_lookup, FILE *f) {
uint64_t lookup = asset_lookup[reinterpret_cast<uint64_t>(e->texture)];
fwrite(&lookup, sizeof(lookup), 1, f);

fwrite(&e->position, sizeof(e->position), 1, f);
fwrite(&e->rotation, sizeof(e->rotation), 1, f);
fwrite(&e->scale , sizeof(e->scale ), 1, f);

fwrite(&e->casts_shadow, sizeof(e->casts_shadow), 1, f);
}
static void readVegetationEntity(VegetationEntity* e, const std::unordered_map<uint64_t, void*> index_to_asset, FILE *f) {
uint64_t lookup;
Expand All @@ -160,12 +154,6 @@ static void readVegetationEntity(VegetationEntity* e, const std::unordered_map<u
} else {
std::cerr << "Unknown texture index " << lookup << " when reading vegetation entity\n";
}

fwrite(&e->position, sizeof(e->position), 1, f);
fwrite(&e->rotation, sizeof(e->rotation), 1, f);
fwrite(&e->scale , sizeof(e->scale ), 1, f);

fwrite(&e->casts_shadow, sizeof(e->casts_shadow), 1, f);
}

static void writeCamera(const Camera &camera, FILE *f) {
Expand Down Expand Up @@ -455,7 +443,7 @@ bool loadLevel(EntityManager &entity_manager, AssetManager &asset_manager, const
}

// Water is a special case since there is only one per level
if(type & WATER_ENTITY) {
if(entityInherits(e->type, WATER_ENTITY)) {
if(entity_manager.water != NULLID) {
std::cerr << "Duplicate water in level, skipping\n";
free(e);
Expand Down
7 changes: 0 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,6 @@ int main() {
/*level_path = "data/levels/animation_test2.level";
loadLevel(*entity_manager, asset_manager, level_path, level_camera);
editor_camera = level_camera;*/

auto seaweed = asset_manager.createMesh("data/mesh/seaweed.mesh");
asset_manager.loadMeshFile(seaweed, seaweed->handle);
auto veg = (VegetationEntity*)entity_manager->createEntity(VEGETATION_ENTITY);
veg->mesh = seaweed;
veg->texture = asset_manager.createTexture("data/textures/extern/Leaves/Leaves_Pine_Texture.png");
asset_manager.loadTexture(veg->texture, veg->texture->handle, GL_RGBA);

std::array<std::string, 6> skybox_paths = { "data/textures/simple_skybox/0006.png", "data/textures/simple_skybox/0002.png",
"data/textures/simple_skybox/0005.png", "data/textures/simple_skybox/0004.png",
Expand Down

0 comments on commit b0b0ec7

Please sign in to comment.