Removed unused files

master
Marc Gilleron 2016-05-05 02:28:10 +02:00
parent 3ab843aa3f
commit 5485a32b6d
7 changed files with 0 additions and 597 deletions

View File

@ -1,247 +0,0 @@
#Copyright (c) 2015 OvermindDL1
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#
#OvermindDL1 would love to receive updates, fixes, and more to this code,
#though it is not required: https://github.com/OvermindDL1/Godot-Helpers
## Testing only
#extends SceneTree
#const F2 = 0.5 * (sqrt(3.0) - 1.0)
#const G2 = (3.0 - sqrt(3.0)) / 6.0
#const G2o = G2*2.0 - 1.0
#const F3 = (1.0 / 3.0)
#const G3 = (1.0 / 6.0)
#const F2 = 0.3660254037844385965883020617184229195117950439453125
#const G2 = 0.2113248654051871344705659794271923601627349853515625
#const G2o = -0.577350269189625731058868041145615279674530029296875
#const F3 = 0.333333333333333314829616256247390992939472198486328125
#const G3 = 0.1666666666666666574148081281236954964697360992431640625
const F2 = 0.36602540378443860
const G2 = 0.21132486540518714
const G2o = -0.577350269189626
const F3 = 0.33333333333333333
const G3 = 0.16666666666666666
const GRAD3 = [
1,1,0, -1,1,0, 1,-1,0, -1,-1,0,
1,0,1, -1,0,1, 1,0,-1, -1,0,-1,
0,1,1, 0,-1,1, 0,1,-1, 0,-1,-1,
1,0,-1, -1,0,-1, 0,-1,1, 0,1,1,
]
const GRAD4 = [
0,1,1,1, 0,1,1,-1, 0,1,-1,1, 0,1,-1,-1,
0,-1,1,1, 0,-1,1,-1, 0,-1,-1,1, 0,-1,-1,-1,
1,0,1,1, 1,0,1,-1, 1,0,-1,1, 1,0,-1,-1,
-1,0,1,1, -1,0,1,-1, -1,0,-1,1, -1,0,-1,-1,
1,1,0,1, 1,1,0,-1, 1,-1,0,1, 1,-1,0,-1,
-1,1,0,1, -1,1,0,-1, -1,-1,0,1, -1,-1,0,-1,
1,1,1,0, 1,1,-1,0, 1,-1,1,0, 1,-1,-1,0,
-1,1,1,0, -1,1,-1,0, -1,-1,1,0, -1,-1,-1,0,
]
const PERM = [
151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140,
36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120,
234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,
88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71,
134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133,
230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161,
1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130,
116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250,
124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227,
47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44,
154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98,
108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34,
242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14,
239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121,
50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243,
141, 128, 195, 78, 66, 215, 61, 156, 180, 151, 160, 137, 91, 90, 15, 131,
13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37,
240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252,
219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125,
136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158,
231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245,
40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187,
208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198,
173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126,
255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223,
183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167,
43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185,
112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179,
162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199,
106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236,
05, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156,
180,
]
static func simplex2(c0, c1):
var s = (c0+c1) * 0.36602540378443860
var a0 = floor(c0+s)
var a1 = floor(c1+s)
var t = (a0+a1) * 0.21132486540518714
var n0 = 0.0
var n1 = 0.0
var n2 = 0.0
var p00 = c0-(a0-t)
var p01 = 0.0
var p02 = 0.0
var p10 = c1-(a1-t)
var p11 = 0.0
var p12 = 0.0
# Current gdscript casts false to 0 and true to 1
var b0 = int(p00 > p10)
var b1 = int(p00 <= p10)
p01 = p00 - b0 + 0.21132486540518714
p11 = p10 - b1 + 0.21132486540518714
p02 = p00 + -0.577350269189626
p12 = p10 + -0.577350269189626
var A0 = int(a0)&255
var A1 = int(a1)&255
var g0 = (PERM[A0 + PERM[A1]] % 12) * 3
var g1 = (PERM[A0 + b0 + PERM[A1 + b1]] % 12) * 3
var g2 = (PERM[A0 + 1 + PERM[A1 + 1]] % 12) * 3
var f0 = 0.5 - p00*p00 - p10*p10
var f1 = 0.5 - p01*p01 - p11*p11
var f2 = 0.5 - p02*p02 - p12*p12
if f0 > 0:
#n0 = f0*f0*f0*f0 * (GRAD3[g0]*p00 + GRAD3[g0]*p10)
n0 = f0*f0*f0*f0 * (GRAD3[g0]*p00 + GRAD3[g0 + 1]*p10)
if f1 > 0:
#n1 = f1*f1*f1*f1 * (GRAD3[g1 + 1]*p01 + GRAD3[g1 + 1]*p11)
n1 = f1*f1*f1*f1 * (GRAD3[g1]*p01 + GRAD3[g1 + 1]*p11)
if f2 > 0:
#n2 = f2*f2*f2*f2 * (GRAD3[g2 + 2]*p02 + GRAD3[g2 + 2]*p12)
n2 = f2*f2*f2*f2 * (GRAD3[g2]*p02 + GRAD3[g2 + 1]*p12)
return (n0 + n1 + n2) * 70.0
static func simplex3(c0, c1, c2):
var s = (c0+c1+c2) * 0.33333333333333333
var a0 = floor(c0+s)
var a1 = floor(c1+s)
var a2 = floor(c2+s)
var t = (a0+a1+a2) * 0.16666666666666666
var n00 = 0
var n01 = 0
var n02 = 0
var n10 = 0
var n11 = 0
var n12 = 0
var p00 = c0-(a0-t)
var p01 = c1-(a1-t)
var p02 = c2-(a2-t)
if p00 >= p01:
if p01 >= p02:
n00 = 1
n10 = 1
n11 = 1
elif p00 >= p02:
n00 = 1
n10 = 1
n12 = 1
else:
n02 = 1
n10 = 1
n12 = 1
else:
if p01 < p02:
n02 = 1
n11 = 1
n12 = 1
elif p00 < p02:
n01 = 1
n11 = 1
n12 = 1
else:
n01 = 1
n10 = 1
n11 = 1
var p10 = p00 - 1.0 + 0.5
var p20 = p00 - n10 + 0.33333333333333333
var p30 = p00 - n00 + 0.16666666666666666
var p11 = p01 - 1.0 + 0.5
var p21 = p01 - n11 + 0.33333333333333333
var p31 = p01 - n01 + 0.16666666666666666
var p12 = p02 - 1.0 + 0.5
var p22 = p02 - n12 + 0.33333333333333333
var p32 = p02 - n02 + 0.16666666666666666
var A0 = int(a0)&255
var A1 = int(a1)&255
var A2 = int(a2)&255
var g0 = (PERM[A0 + PERM[A2]] % 12) * 3
var g1 = (PERM[A0 + n00 + PERM[A1 + n01 + PERM[n02 + A2]]] % 12) * 3
var g2 = (PERM[A0 + n10 + PERM[A1 + n11 + PERM[n12 + A2]]] % 12) * 3
var g3 = (PERM[A0 + 1 + PERM[A1 + 1 + PERM[A2 + 1]]] % 12) * 3
var f0 = 0.6 - p00*p00 - p01*p01 - p02*p02
var f1 = 0.6 - p10*p10 - p11*p11 - p12*p12
var f2 = 0.6 - p20*p20 - p21*p21 - p22*p22
var f3 = 0.6 - p30*p30 - p31*p31 - p32*p32
var n0 = 0.0
var n1 = 0.0
var n2 = 0.0
var n3 = 0.0
if f0 > 0:
n0 = f0*f0*f0*f0 * (p00*GRAD3[g0] + p01*GRAD3[g0+1] + p02*GRAD3[g0+2])
if f1 > 0:
n1 = f1*f1*f1*f1 * (p10*GRAD3[g1] + p11*GRAD3[g1+1] + p12*GRAD3[g1+2])
if f2 > 0:
n2 = f2*f2*f2*f2 * (p20*GRAD3[g2] + p21*GRAD3[g2+1] + p22*GRAD3[g2+2])
if f3 > 0:
n3 = f3*f3*f3*f3 * (p30*GRAD3[g3] + p31*GRAD3[g3+1] + p32*GRAD3[g3+2])
return (n0 + n1 + n2 + n3) * 32.0
## Testing only
#func _init():
# var c = 1000000
# print("Preloading data into active memory")
# for a in range(c/100):
# simplex2(c, c)
#
# print("Testing simplex2...")
# var t = OS.get_unix_time()
# for a in range(c):
# simplex2(c, c)
# print ("Testing of simplex2 with "+str(c)+" iterations took "+str(OS.get_unix_time()-t)+" seconds.")
#
# print("Testing simplex3...")
# t = OS.get_unix_time()
# for a in range(c):
# simplex3(c, c, c)
# print ("Testing of simplex3 with "+str(c)+" iterations took "+str(OS.get_unix_time()-t)+" seconds.")
# quit()

View File

@ -1,2 +0,0 @@

View File

@ -1,14 +0,0 @@
extends Node
var chunk_position = Vector2(0,0)
var voxel_map = null
var _blocks = []
func _ready():
pass

View File

@ -1,9 +0,0 @@
[gd_scene load_steps=2 format=1]
[ext_resource path="res://chunk.gd" type="Script" id=1]
[node name="Node" type="Node"]
script/script = ExtResource( 1 )

View File

@ -1,10 +0,0 @@
# Currently unused.
extends Camera2D
func _ready():
#var image = get_parent().get_screen_capture()
pass

View File

@ -1,68 +0,0 @@
[gd_scene load_steps=5 format=1]
[ext_resource path="res://gpu_generator.gd" type="Script" id=1]
[ext_resource path="res://icon.png" type="Texture" id=2]
[sub_resource type="CanvasItemShader" id=4]
_code = { "fragment":"vec2 pos = floor(UV * 64.0);\nfloat a = fract(sin(dot(pos ,vec2(12.9898,78.233))) * 438.5453);\nvec4 col = vec4(a, a, a, 1.0);\n\nCOLOR = col;\n", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }
[sub_resource type="CanvasItemMaterial" id=5]
shader/shader = SubResource( 4 )
shader/shading_mode = 0
[node name="ShaderGen" type="Node"]
[node name="Viewport" type="Viewport" parent="."]
rect = Rect2( 0, 0, 0, 0 )
own_world = false
world = null
transparent_bg = false
render_target/enabled = true
render_target/v_flip = false
render_target/clear_on_new_frame = true
render_target/filter = false
render_target/gen_mipmaps = false
render_target/update_mode = 2
audio_listener/enable_2d = false
audio_listener/enable_3d = false
physics/object_picking = false
gui/disable_input = false
[node name="Camera2D" type="Camera2D" parent="."]
anchor_mode = 0
rotating = false
current = false
zoom = Vector2( 1, 1 )
limit/left = -10000000
limit/top = -10000000
limit/right = 10000000
limit/bottom = 10000000
drag_margin/h_enabled = true
drag_margin/v_enabled = true
smoothing/enable = false
smoothing/speed = 5.0
drag_margin/left = 0.2
drag_margin/top = 0.2
drag_margin/right = 0.2
drag_margin/bottom = 0.2
script/script = ExtResource( 1 )
[node name="Polygon2D" type="Polygon2D" parent="."]
material/material = SubResource( 5 )
polygon = Vector2Array( 0, 0, 64, 0, 64, 64, 0, 64 )
uv = Vector2Array( 0, 0, 64, 0, 64, 64, 0, 64 )
color = Color( 1, 1, 1, 1 )
offset = Vector2( 0, 0 )
texture/texture = ExtResource( 2 )
texture/offset = Vector2( 0, 0 )
texture/scale = Vector2( 1, 1 )
texture/rotation = 0.0
invert/enable = false
invert/border = 100.0

View File

@ -1,247 +0,0 @@
# TODO Move this to VoxelMap
# Still here, because accessing constants from another script don't work... (issue 4457)
const ATLAS_SIZE = 4
const SIDE_LEFT = 0
const SIDE_RIGHT = 1
const SIDE_BOTTOM = 2
const SIDE_TOP = 3
const SIDE_BACK = 4
const SIDE_FRONT = 5
const GEOM_EMPTY = 0
const GEOM_CUBE = 1
const GEOM_XQUAD = 2
const GEOM_MODEL = 3
const GEOM_LIQUID = 4
var id = 0
var name = "default"
var cube_side_uv4 = []
var is_transparent = false
var geom_type = GEOM_CUBE
# Mesh that will always be included in the voxel
var model_vertices = []
var model_uv = []
# Parts of the mesh that will appear only if connected sides are transparent
var model_side_vertices = []
var model_side_uv = []
var model_normals = []
func _init(id, name):
self.id = id
self.name = name
cube_side_uv4.resize(6)
set_all_atlas_pos(Vector2(0,0))
func set_side_atlas_pos(side, pos):
var s = 1.0 / float(ATLAS_SIZE)
# Apply a tiny padding to avoid tiling artefacts
var e = 0.001
cube_side_uv4[side] = [
s * (pos + Vector2(e,e)),
s * (pos + Vector2(1-e,e)),
s * (pos + Vector2(e,1-e)),
s * (pos + Vector2(1-e,1-e))
]
return self
func set_all_atlas_pos(pos):
for i in range(0, 6):
set_side_atlas_pos(i, pos)
return self
func set_tbs_atlas_pos(top_pos, bottom_pos, sides_pos):
set_side_atlas_pos(SIDE_LEFT, sides_pos)
set_side_atlas_pos(SIDE_RIGHT, sides_pos)
set_side_atlas_pos(SIDE_FRONT, sides_pos)
set_side_atlas_pos(SIDE_BACK, sides_pos)
set_side_atlas_pos(SIDE_TOP, top_pos)
set_side_atlas_pos(SIDE_BOTTOM, bottom_pos)
return self
func set_geom(g):
geom_type = g
return self
func set_transparent(trans):
is_transparent = trans
return self
func compile():
if geom_type == GEOM_CUBE:
model_side_vertices = _make_cube_vertex_offsets()
model_side_uv = _make_cube_side_uv6(cube_side_uv4)
elif geom_type == GEOM_LIQUID:
model_side_vertices = _make_cube_vertex_offsets(15.0 / 16.0)
model_side_uv = _make_cube_side_uv6(cube_side_uv4)
elif geom_type == GEOM_XQUAD:
var uv = cube_side_uv4
model_uv = [
uv[0][2],
uv[0][0],
uv[0][1],
uv[0][2],
uv[0][1],
uv[0][3],
uv[0][3],
uv[0][2],
uv[0][1],
uv[0][2],
uv[0][0],
uv[0][1]
]
model_vertices = [
Vector3(0,0,0),
Vector3(0,1,0),
Vector3(1,1,1),
Vector3(0,0,0),
Vector3(1,1,1),
Vector3(1,0,1),
Vector3(1,0,0),
Vector3(0,0,1),
Vector3(1,1,0),
Vector3(0,0,1),
Vector3(0,1,1),
Vector3(1,1,0)
]
model_normals = [
Vector3(-0.7, 0.0, 0.7),
Vector3(-0.7, 0.0, 0.7),
Vector3(-0.7, 0.0, 0.7),
Vector3(-0.7, 0.0, 0.7),
Vector3(-0.7, 0.0, 0.7),
Vector3(-0.7, 0.0, 0.7),
Vector3(0.7, 0.0, 0.7),
Vector3(0.7, 0.0, 0.7),
Vector3(0.7, 0.0, 0.7),
Vector3(0.7, 0.0, 0.7),
Vector3(0.7, 0.0, 0.7),
Vector3(0.7, 0.0, 0.7)
]
else:
print("Unknown voxel geometry type")
static func _make_cube_vertex_offsets(sy=1):
var a = [
[
# LEFT
Vector3(0,0,0),
Vector3(0,sy,0),
Vector3(0,sy,1),
Vector3(0,0,0),
Vector3(0,sy,1),
Vector3(0,0,1),
],
[
# RIGHT
Vector3(1,0,0),
Vector3(1,sy,1),
Vector3(1,sy,0),
Vector3(1,0,0),
Vector3(1,0,1),
Vector3(1,sy,1)
],
[
# BOTTOM
Vector3(0,0,0),
Vector3(1,0,1),
Vector3(1,0,0),
Vector3(0,0,0),
Vector3(0,0,1),
Vector3(1,0,1)
],
[
# TOP
Vector3(0,sy,0),
Vector3(1,sy,0),
Vector3(1,sy,1),
Vector3(0,sy,0),
Vector3(1,sy,1),
Vector3(0,sy,1)
],
[
# BACK
Vector3(0,0,0),
Vector3(1,0,0),
Vector3(1,sy,0),
Vector3(0,0,0),
Vector3(1,sy,0),
Vector3(0,sy,0),
],
[
# FRONT
Vector3(1,0,1),
Vector3(0,0,1),
Vector3(1,sy,1),
Vector3(0,0,1),
Vector3(0,sy,1),
Vector3(1,sy,1)
]
]
return a
static func _make_cube_side_uv6(sides_uv4):
var uvs = sides_uv4
var uv6 = [
[
uvs[SIDE_LEFT][2],
uvs[SIDE_LEFT][0],
uvs[SIDE_LEFT][1],
uvs[SIDE_LEFT][2],
uvs[SIDE_LEFT][1],
uvs[SIDE_LEFT][3]
],
[
uvs[SIDE_RIGHT][2],
uvs[SIDE_RIGHT][1],
uvs[SIDE_RIGHT][0],
uvs[SIDE_RIGHT][2],
uvs[SIDE_RIGHT][3],
uvs[SIDE_RIGHT][1]
],
[
uvs[SIDE_BOTTOM][0],
uvs[SIDE_BOTTOM][3],
uvs[SIDE_BOTTOM][1],
uvs[SIDE_BOTTOM][0],
uvs[SIDE_BOTTOM][2],
uvs[SIDE_BOTTOM][3]
],
[
uvs[SIDE_TOP][0],
uvs[SIDE_TOP][1],
uvs[SIDE_TOP][3],
uvs[SIDE_TOP][0],
uvs[SIDE_TOP][3],
uvs[SIDE_TOP][2]
],
[
uvs[SIDE_BACK][2],
uvs[SIDE_BACK][3],
uvs[SIDE_BACK][1],
uvs[SIDE_BACK][2],
uvs[SIDE_BACK][1],
uvs[SIDE_BACK][0]
],
[
uvs[SIDE_FRONT][3],
uvs[SIDE_FRONT][2],
uvs[SIDE_FRONT][1],
uvs[SIDE_FRONT][2],
uvs[SIDE_FRONT][0],
uvs[SIDE_FRONT][1]
],
]
return uv6