Skip to content

Commit

Permalink
fix object placement issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Nov 21, 2023
1 parent dd22ee3 commit 8626399
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Autoload/Things.gd
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ func get_png_filenames_in_dir(path):
print("An error occurred when trying to access the path.")
return dictionary

func convert_relative_256_to_float(datnum):
if datnum >= 32768: # If the sign bit is set (indicating a negative value)
datnum -= 65536 # Convert to signed by subtracting 2^16
return datnum / 256.0 # Scale it to floating-point

#func load_custom_images_into_array(DATA_ARRAY, thingtypeImageFolder):
# print("Loading /thing-images/" + thingtypeImageFolder + " directory ...")
# var arrayOfFilenames = get_png_files_in_dir(Settings.unearthdata.plus_file("thing-images").plus_file(thingtypeImageFolder))
Expand Down
8 changes: 3 additions & 5 deletions Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,9 @@ func spawn_attached(xSlab, ySlab, slabID, ownership, subtile, tngObj): # Spawns

var subtileY = subtile/3
var subtileX = subtile-(subtileY*3)
id.locationX = ((xSlab*3) + subtileX) + tngObj[Slabset.obj.RELATIVE_X]
id.locationY = ((ySlab*3) + subtileY) + tngObj[Slabset.obj.RELATIVE_Y]
id.locationZ = tngObj[Slabset.obj.RELATIVE_Z]


id.locationX = ((xSlab*3) + subtileX) + Things.convert_relative_256_to_float(tngObj[Slabset.obj.RELATIVE_X])
id.locationY = ((ySlab*3) + subtileY) + Things.convert_relative_256_to_float(tngObj[Slabset.obj.RELATIVE_Y])
id.locationZ = Things.convert_relative_256_to_float(tngObj[Slabset.obj.RELATIVE_Z])

id.ownership = ownership

Expand Down

0 comments on commit 8626399

Please sign in to comment.