Skip to content

Commit

Permalink
Atlas padding.
Browse files Browse the repository at this point in the history
  • Loading branch information
MDFL64 committed Jun 11, 2015
1 parent d9c1846 commit a5f1ec5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/vox_Voxels.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct VoxelConfig {
bool sv_useMeshCollisions = false;

IMaterial* cl_atlasMaterial = nullptr;
bool cl_drawExterior = true;
bool cl_drawExterior = false;
int cl_atlasWidth = 1;
int cl_atlasHeight = 1;

Expand Down
31 changes: 19 additions & 12 deletions src/vox_lua_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,13 @@ int luaf_voxInit(lua_State* state) {
if (STATE_SERVER) {
LUA->GetField(2, "useMeshCollisions");
if (LUA->IsType(-1, GarrysMod::Lua::Type::BOOL))
config->sv_useMeshCollisions = LUA->GetBool(-1);
config->sv_useMeshCollisions = LUA->GetBool();
LUA->Pop();
}
else {
LUA->GetField(2, "drawExterior");
if (LUA->IsType(-1, GarrysMod::Lua::Type::BOOL))
config->cl_drawExterior = LUA->GetBool(-1);
LUA->Pop();

LUA->GetField(2, "atlasMaterial");
if (LUA->IsType(-1, GarrysMod::Lua::Type::STRING))
config->cl_atlasMaterial = iface_cl_materials->FindMaterial(LUA->GetString(-1), nullptr);
else
config->cl_atlasMaterial = iface_cl_materials->FindMaterial("models/debug/debugwhite", nullptr);
config->cl_atlasMaterial->IncrementReferenceCount();
config->cl_pixel_bias_x = 1.0 / config->cl_atlasMaterial->GetMappingWidth();
config->cl_pixel_bias_y = 1.0 / config->cl_atlasMaterial->GetMappingHeight();
config->cl_drawExterior = LUA->GetBool();
LUA->Pop();

LUA->GetField(2, "atlasWidth");
Expand All @@ -98,8 +88,25 @@ int luaf_voxInit(lua_State* state) {
LUA->GetField(2, "atlasHeight");
if (LUA->IsType(-1, GarrysMod::Lua::Type::NUMBER))
config->cl_atlasHeight = LUA->GetNumber();
LUA->Pop();

LUA->GetField(2, "atlasMaterial");
if (LUA->IsType(-1, GarrysMod::Lua::Type::STRING))
config->cl_atlasMaterial = iface_cl_materials->FindMaterial(LUA->GetString(-1), nullptr);
else
config->cl_atlasMaterial = iface_cl_materials->FindMaterial("models/debug/debugwhite", nullptr);
LUA->Pop();

config->cl_atlasMaterial->IncrementReferenceCount();

LUA->GetField(2, "atlasIsPadded");
if (LUA->IsType(-1, GarrysMod::Lua::Type::BOOL) && LUA->GetBool()) {
config->cl_pixel_bias_x = (config->cl_atlasMaterial->GetMappingWidth() / config->cl_atlasWidth / 4.0) / config->cl_atlasMaterial->GetMappingWidth();
config->cl_pixel_bias_y = (config->cl_atlasMaterial->GetMappingHeight() / config->cl_atlasHeight / 4.0) / config->cl_atlasMaterial->GetMappingHeight();
}
LUA->Pop();

//vox_print("%f <-> %f", config->cl_pixel_bias_x, config->cl_pixel_bias_y);
}

LUA->GetField(2, "dimensions");
Expand Down

0 comments on commit a5f1ec5

Please sign in to comment.