Propagated side to wedge

This commit is contained in:
2025-02-15 01:30:31 +03:00
parent 2eed8ef509
commit 66838892d5
27 changed files with 4444 additions and 589 deletions

Binary file not shown.

View File

@@ -1,6 +1,6 @@
{
"asset":{
"generator" : "Khronos glTF Blender I/O v3.3.32",
"generator":"Khronos glTF Blender I/O v3.6.28",
"version":"2.0"
},
"extensionsUsed":[
@@ -14,7 +14,9 @@
"nodes":[
0,
1,
2
2,
3,
4
]
}
],
@@ -40,6 +42,35 @@
0,
0
]
},
{
"mesh":3,
"name":"roadd-sidewalk_end",
"translation":[
3.3000001907348633,
0,
0
]
},
{
"mesh":4,
"name":"roadd-sidewalk_start",
"rotation":[
0,
0,
-1,
0
],
"scale":[
-1,
-1,
-1
],
"translation":[
4.55145263671875,
0,
0
]
}
],
"materials":[
@@ -107,6 +138,34 @@
"material":0
}
]
},
{
"name":"road-sidewalk.001",
"primitives":[
{
"attributes":{
"POSITION":12,
"NORMAL":13,
"TEXCOORD_0":14
},
"indices":15,
"material":0
}
]
},
{
"name":"road-sidewalk.006",
"primitives":[
{
"attributes":{
"POSITION":16,
"NORMAL":17,
"TEXCOORD_0":18
},
"indices":15,
"material":0
}
]
}
],
"textures":[
@@ -160,7 +219,7 @@
{
"bufferView":4,
"componentType":5126,
"count" : 80,
"count":74,
"max":[
9.921204764395952e-07,
0.1214386522769928,
@@ -176,13 +235,13 @@
{
"bufferView":5,
"componentType":5126,
"count" : 80,
"count":74,
"type":"VEC3"
},
{
"bufferView":6,
"componentType":5126,
"count" : 80,
"count":74,
"type":"VEC2"
},
{
@@ -194,7 +253,7 @@
{
"bufferView":8,
"componentType":5126,
"count" : 42,
"count":40,
"max":[
2.5033950805664062e-05,
0.19999995827674866,
@@ -210,13 +269,13 @@
{
"bufferView":9,
"componentType":5126,
"count" : 42,
"count":40,
"type":"VEC3"
},
{
"bufferView":10,
"componentType":5126,
"count" : 42,
"count":40,
"type":"VEC2"
},
{
@@ -224,6 +283,68 @@
"componentType":5123,
"count":66,
"type":"SCALAR"
},
{
"bufferView":12,
"componentType":5126,
"count":418,
"max":[
0.00867057777941227,
0.19999998807907104,
0
],
"min":[
-1.100000023841858,
-0.10000000149011612,
-0.5000007152557373
],
"type":"VEC3"
},
{
"bufferView":13,
"componentType":5126,
"count":418,
"type":"VEC3"
},
{
"bufferView":14,
"componentType":5126,
"count":418,
"type":"VEC2"
},
{
"bufferView":15,
"componentType":5123,
"count":975,
"type":"SCALAR"
},
{
"bufferView":16,
"componentType":5126,
"count":418,
"max":[
0.00867057777941227,
0.19999998807907104,
0.5
],
"min":[
-1.100000023841858,
-0.10000000149011612,
-7.152557373046875e-07
],
"type":"VEC3"
},
{
"bufferView":17,
"componentType":5126,
"count":418,
"type":"VEC3"
},
{
"bufferView":18,
"componentType":5126,
"count":418,
"type":"VEC2"
}
],
"bufferViews":[
@@ -253,51 +374,93 @@
},
{
"buffer":0,
"byteLength" : 960,
"byteLength":888,
"byteOffset":1120,
"target":34962
},
{
"buffer":0,
"byteLength" : 960,
"byteOffset" : 2080,
"byteLength":888,
"byteOffset":2008,
"target":34962
},
{
"buffer":0,
"byteLength" : 640,
"byteOffset" : 3040,
"byteLength":592,
"byteOffset":2896,
"target":34962
},
{
"buffer":0,
"byteLength":252,
"byteOffset" : 3680,
"byteOffset":3488,
"target":34963
},
{
"buffer":0,
"byteLength" : 504,
"byteOffset" : 3932,
"byteLength":480,
"byteOffset":3740,
"target":34962
},
{
"buffer":0,
"byteLength" : 504,
"byteOffset" : 4436,
"byteLength":480,
"byteOffset":4220,
"target":34962
},
{
"buffer":0,
"byteLength" : 336,
"byteOffset" : 4940,
"byteLength":320,
"byteOffset":4700,
"target":34962
},
{
"buffer":0,
"byteLength":132,
"byteOffset" : 5276,
"byteOffset":5020,
"target":34963
},
{
"buffer":0,
"byteLength":5016,
"byteOffset":5152,
"target":34962
},
{
"buffer":0,
"byteLength":5016,
"byteOffset":10168,
"target":34962
},
{
"buffer":0,
"byteLength":3344,
"byteOffset":15184,
"target":34962
},
{
"buffer":0,
"byteLength":1950,
"byteOffset":18528,
"target":34963
},
{
"buffer":0,
"byteLength":5016,
"byteOffset":20480,
"target":34962
},
{
"buffer":0,
"byteLength":5016,
"byteOffset":25496,
"target":34962
},
{
"buffer":0,
"byteLength":3344,
"byteOffset":30512,
"target":34962
}
],
"samplers":[
@@ -308,7 +471,7 @@
],
"buffers":[
{
"byteLength" : 5408,
"byteLength":33856,
"uri":"road-lanes.bin"
}
]

Binary file not shown.

View File

@@ -0,0 +1,153 @@
{
"asset":{
"generator":"Khronos glTF Blender I/O v3.6.28",
"version":"2.0"
},
"extensionsUsed":[
"KHR_materials_specular",
"KHR_materials_ior"
],
"scene":0,
"scenes":[
{
"name":"Scene",
"nodes":[
0
]
}
],
"nodes":[
{
"mesh":0,
"name":"terrain-col"
}
],
"materials":[
{
"alphaCutoff":0.5,
"alphaMode":"MASK",
"extensions":{
"KHR_materials_specular":{
"specularColorFactor":[
0.474271529955476,
0.474271529955476,
0.474271529955476
]
},
"KHR_materials_ior":{
"ior":1.4500000476837158
}
},
"name":"material_atlas_36953_1",
"pbrMetallicRoughness":{
"baseColorTexture":{
"index":0
},
"metallicFactor":0
}
}
],
"meshes":[
{
"name":"Plane",
"primitives":[
{
"attributes":{
"POSITION":0,
"NORMAL":1,
"TEXCOORD_0":2
},
"indices":3,
"material":0
}
]
}
],
"textures":[
{
"sampler":0,
"source":0
}
],
"images":[
{
"mimeType":"image/png",
"name":"Atlas_36953",
"uri":"Atlas_36953.png"
}
],
"accessors":[
{
"bufferView":0,
"componentType":5126,
"count":295,
"max":[
19.861404418945312,
0.3628370761871338,
19.687721252441406
],
"min":[
-19.76592445373535,
-4.110562324523926,
-19.641536712646484
],
"type":"VEC3"
},
{
"bufferView":1,
"componentType":5126,
"count":295,
"type":"VEC3"
},
{
"bufferView":2,
"componentType":5126,
"count":295,
"type":"VEC2"
},
{
"bufferView":3,
"componentType":5123,
"count":552,
"type":"SCALAR"
}
],
"bufferViews":[
{
"buffer":0,
"byteLength":3540,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":3540,
"byteOffset":3540,
"target":34962
},
{
"buffer":0,
"byteLength":2360,
"byteOffset":7080,
"target":34962
},
{
"buffer":0,
"byteLength":1104,
"byteOffset":9440,
"target":34963
}
],
"samplers":[
{
"magFilter":9729,
"minFilter":9987
}
],
"buffers":[
{
"byteLength":10544,
"uri":"lot-small-m0.bin"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://astream/terrain/details/lot-small-m0.gltf" type="PackedScene" id=1]
[node name="lot-small-m0" instance=ExtResource( 1 )]

View File

@@ -80,15 +80,15 @@
{
"bufferView":0,
"componentType":5126,
"count":315,
"count":317,
"max":[
29.999271392822266,
0.30028843879699707,
0.32523614168167114,
29.77977752685547
],
"min":[
-29.844146728515625,
-4.802618026733398,
-4.110562324523926,
-29.613506317138672
],
"type":"VEC3"
@@ -96,13 +96,13 @@
{
"bufferView":1,
"componentType":5126,
"count":315,
"count":317,
"type":"VEC3"
},
{
"bufferView":2,
"componentType":5126,
"count":315,
"count":317,
"type":"VEC2"
},
{
@@ -115,26 +115,26 @@
"bufferViews":[
{
"buffer":0,
"byteLength":3780,
"byteLength":3804,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":3780,
"byteOffset":3780,
"byteLength":3804,
"byteOffset":3804,
"target":34962
},
{
"buffer":0,
"byteLength":2520,
"byteOffset":7560,
"byteLength":2536,
"byteOffset":7608,
"target":34962
},
{
"buffer":0,
"byteLength":1104,
"byteOffset":10080,
"byteOffset":10144,
"target":34963
}
],
@@ -146,7 +146,7 @@
],
"buffers":[
{
"byteLength":11184,
"byteLength":11248,
"uri":"lot-small0.bin"
}
]

View File

@@ -0,0 +1,158 @@
{
"asset":{
"generator":"Khronos glTF Blender I/O v3.6.28",
"version":"2.0"
},
"extensionsUsed":[
"KHR_materials_specular",
"KHR_materials_ior"
],
"scene":0,
"scenes":[
{
"name":"Scene",
"nodes":[
0
]
}
],
"nodes":[
{
"mesh":0,
"name":"garage-door",
"translation":[
0,
4,
0
]
}
],
"materials":[
{
"alphaCutoff":0.5,
"alphaMode":"MASK",
"extensions":{
"KHR_materials_specular":{
"specularColorFactor":[
0.474271529955476,
0.474271529955476,
0.474271529955476
]
},
"KHR_materials_ior":{
"ior":1.4500000476837158
}
},
"name":"material_atlas_36953_1",
"pbrMetallicRoughness":{
"baseColorTexture":{
"index":0
},
"metallicFactor":0
}
}
],
"meshes":[
{
"name":"Cube.002",
"primitives":[
{
"attributes":{
"POSITION":0,
"NORMAL":1,
"TEXCOORD_0":2
},
"indices":3,
"material":0
}
]
}
],
"textures":[
{
"sampler":0,
"source":0
}
],
"images":[
{
"mimeType":"image/png",
"name":"Atlas_36953",
"uri":"Atlas_36953.png"
}
],
"accessors":[
{
"bufferView":0,
"componentType":5126,
"count":985,
"max":[
2.4556546211242676,
0.05903172492980957,
0.09999994933605194
],
"min":[
-2.4556546211242676,
-3.980344295501709,
-0.27000004053115845
],
"type":"VEC3"
},
{
"bufferView":1,
"componentType":5126,
"count":985,
"type":"VEC3"
},
{
"bufferView":2,
"componentType":5126,
"count":985,
"type":"VEC2"
},
{
"bufferView":3,
"componentType":5123,
"count":2172,
"type":"SCALAR"
}
],
"bufferViews":[
{
"buffer":0,
"byteLength":11820,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":11820,
"byteOffset":11820,
"target":34962
},
{
"buffer":0,
"byteLength":7880,
"byteOffset":23640,
"target":34962
},
{
"buffer":0,
"byteLength":4344,
"byteOffset":31520,
"target":34963
}
],
"samplers":[
{
"magFilter":9729,
"minFilter":9987
}
],
"buffers":[
{
"byteLength":35864,
"uri":"residental-garage-door.bin"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,158 @@
{
"asset":{
"generator":"Khronos glTF Blender I/O v3.6.28",
"version":"2.0"
},
"extensionsUsed":[
"KHR_materials_specular",
"KHR_materials_ior"
],
"scene":0,
"scenes":[
{
"name":"Scene",
"nodes":[
0
]
}
],
"nodes":[
{
"mesh":0,
"name":"garage-roof-col",
"translation":[
0.27659401297569275,
0,
0
]
}
],
"materials":[
{
"alphaCutoff":0.5,
"alphaMode":"MASK",
"extensions":{
"KHR_materials_specular":{
"specularColorFactor":[
0.474271529955476,
0.474271529955476,
0.474271529955476
]
},
"KHR_materials_ior":{
"ior":1.4500000476837158
}
},
"name":"material_atlas_36953_1",
"pbrMetallicRoughness":{
"baseColorTexture":{
"index":0
},
"metallicFactor":0
}
}
],
"meshes":[
{
"name":"Cube.002",
"primitives":[
{
"attributes":{
"POSITION":0,
"NORMAL":1,
"TEXCOORD_0":2
},
"indices":3,
"material":0
}
]
}
],
"textures":[
{
"sampler":0,
"source":0
}
],
"images":[
{
"mimeType":"image/png",
"name":"Atlas_36953",
"uri":"Atlas_36953.png"
}
],
"accessors":[
{
"bufferView":0,
"componentType":5126,
"count":34,
"max":[
12.723405838012695,
2,
4
],
"min":[
-12.276594161987305,
0,
-4
],
"type":"VEC3"
},
{
"bufferView":1,
"componentType":5126,
"count":34,
"type":"VEC3"
},
{
"bufferView":2,
"componentType":5126,
"count":34,
"type":"VEC2"
},
{
"bufferView":3,
"componentType":5123,
"count":60,
"type":"SCALAR"
}
],
"bufferViews":[
{
"buffer":0,
"byteLength":408,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":408,
"byteOffset":408,
"target":34962
},
{
"buffer":0,
"byteLength":272,
"byteOffset":816,
"target":34962
},
{
"buffer":0,
"byteLength":120,
"byteOffset":1088,
"target":34963
}
],
"samplers":[
{
"magFilter":9729,
"minFilter":9987
}
],
"buffers":[
{
"byteLength":1208,
"uri":"residental-garage-roof1.bin"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,25 +12,14 @@
{
"name":"Scene",
"nodes":[
1,
2
0
]
}
],
"nodes":[
{
"mesh":0,
"name":"garage-col-colonly"
},
{
"children":[
0
],
"mesh":1,
"name":"garage"
},
{
"name":"NurbsPath"
"name":"parking--col"
}
],
"materials":[
@@ -60,7 +49,7 @@
],
"meshes":[
{
"name":"Cube",
"name":"Cube.002",
"primitives":[
{
"attributes":{
@@ -68,20 +57,7 @@
"NORMAL":1,
"TEXCOORD_0":2
},
"indices":3
}
]
},
{
"name":"Cube.014",
"primitives":[
{
"attributes":{
"POSITION":4,
"NORMAL":5,
"TEXCOORD_0":6
},
"indices":7,
"indices":3,
"material":0
}
]
@@ -106,14 +82,14 @@
"componentType":5126,
"count":160,
"max":[
19,
6,
4.5
3,
0.09999999403953552,
2
],
"min":[
-12.100000381469727,
-0.5,
-4.5
-3,
-0.019999999552965164,
-2
],
"type":"VEC3"
},
@@ -132,41 +108,7 @@
{
"bufferView":3,
"componentType":5123,
"count":420,
"type":"SCALAR"
},
{
"bufferView":4,
"componentType":5126,
"count":129,
"max":[
19,
6,
4.500000953674316
],
"min":[
-12.100000381469727,
-0.5,
-4.499999046325684
],
"type":"VEC3"
},
{
"bufferView":5,
"componentType":5126,
"count":129,
"type":"VEC3"
},
{
"bufferView":6,
"componentType":5126,
"count":129,
"type":"VEC2"
},
{
"bufferView":7,
"componentType":5123,
"count":306,
"count":372,
"type":"SCALAR"
}
],
@@ -191,33 +133,9 @@
},
{
"buffer":0,
"byteLength":840,
"byteLength":744,
"byteOffset":5120,
"target":34963
},
{
"buffer":0,
"byteLength":1548,
"byteOffset":5960,
"target":34962
},
{
"buffer":0,
"byteLength":1548,
"byteOffset":7508,
"target":34962
},
{
"buffer":0,
"byteLength":1032,
"byteOffset":9056,
"target":34962
},
{
"buffer":0,
"byteLength":612,
"byteOffset":10088,
"target":34963
}
],
"samplers":[
@@ -228,7 +146,7 @@
],
"buffers":[
{
"byteLength":10700,
"byteLength":5864,
"uri":"residental-garage.bin"
}
]

View File

@@ -1,6 +1,8 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://astream/terrain/details/residental-garage.gltf" type="PackedScene" id=1]
[ext_resource path="res://astream/terrain/details/residental-garage-roof1.gltf" type="PackedScene" id=2]
[ext_resource path="res://astream/terrain/details/residental-garage-door.gltf" type="PackedScene" id=3]
[sub_resource type="CubeMesh" id=1]
size = Vector3( 27, 1, 10 )
@@ -23,10 +25,11 @@ lod_range = 35.0
[node name="residental-garage" parent="LOD/MergeGroup" instance=ExtResource( 1 )]
[node name="MeshInstance" type="MeshInstance" parent="LOD/MergeGroup"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.427596, 6.49411, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="residental-garage-roof1" parent="LOD/MergeGroup" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0 )
[node name="residental-garage-door" parent="LOD/MergeGroup" instance=ExtResource( 3 )]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 12.7459, 1, 0 )
[node name="MergeGroup1" type="MergeGroup" parent="LOD"]
visible = false

View File

@@ -80,61 +80,61 @@
{
"bufferView":0,
"componentType":5126,
"count":778,
"count":1148,
"max":[
15.457839012145996,
0.18514837324619293,
13.391965866088867
11.783405303955078,
0.1851484179496765,
9.890567779541016
],
"min":[
-15.484124183654785,
-3.5783910751342773,
-13.159601211547852
-11.841397285461426,
-4.024284839630127,
-9.954931259155273
],
"type":"VEC3"
},
{
"bufferView":1,
"componentType":5126,
"count":778,
"count":1148,
"type":"VEC3"
},
{
"bufferView":2,
"componentType":5126,
"count":778,
"count":1148,
"type":"VEC2"
},
{
"bufferView":3,
"componentType":5123,
"count":1176,
"count":1728,
"type":"SCALAR"
}
],
"bufferViews":[
{
"buffer":0,
"byteLength":9336,
"byteLength":13776,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":9336,
"byteOffset":9336,
"byteLength":13776,
"byteOffset":13776,
"target":34962
},
{
"buffer":0,
"byteLength":6224,
"byteOffset":18672,
"byteLength":9184,
"byteOffset":27552,
"target":34962
},
{
"buffer":0,
"byteLength":2352,
"byteOffset":24896,
"byteLength":3456,
"byteOffset":36736,
"target":34963
}
],
@@ -146,7 +146,7 @@
],
"buffers":[
{
"byteLength":27248,
"byteLength":40192,
"uri":"sideroad-short1.bin"
}
]

View File

@@ -38,6 +38,7 @@ building_data = {
"foundation60": "res://astream/terrain/details/foundation60.tscn",
"bus-stop": "res://astream/terrain/details/bus-stop.tscn",
"lot-small0": "res://astream/terrain/details/lot-small0.tscn",
"lot-small-m0": "res://astream/terrain/details/lot-small-m0.tscn",
"lot-small1": "res://astream/terrain/details/lot-small1.tscn",
"lot-small2": "res://astream/terrain/details/lot-small2.tscn",
"lot-large1": "res://astream/terrain/details/lot-large1.tscn",
@@ -75,12 +76,22 @@ lot_offset = 33.8
lot_y_rotation = 90.0
[lines/edges/lot-small0/left]
lot_offset = 26.5
lot_offset = 33.0
lot_y_rotation = 0
lot_y_offset = 0
[lines/edges/lot-small0/right]
lot_offset = 26.5
lot_offset = 33.0
lot_y_rotation = 180
lot_y_offset = 0
[lines/edges/lot-small-m0/left]
lot_offset = 24.8
lot_y_rotation = 0
lot_y_offset = 0
[lines/edges/lot-small-m0/right]
lot_offset = 25.5
lot_y_rotation = 180
lot_y_offset = 0
@@ -90,7 +101,7 @@ lot_y_rotation = 0
lot_y_offset = 0
[lines/edges/lot-small1/right]
lot_offset = 36
lot_offset = 37.5
lot_y_rotation = 180
lot_y_offset = 0

View File

@@ -20,6 +20,9 @@
struct CLine {
struct RoadLinesData::road_line line;
};
struct CLineIndex {
struct RoadLinesData::road_line_index index;
};
class LinesAccessor {
public:
@@ -121,17 +124,6 @@ public:
struct CLine *cl = e.get_mut<CLine>();
cl->line.points[index].origin = position;
}
inline void clear_all_line_indices()
{
BaseData::get_singleton()->get_singleton()->get().each(
[](CLine &cl) { cl.line.indices.clear(); });
}
inline void clear_line_indices(const String &key)
{
flecs::entity e = lookup(key);
struct CLine *cl = e.get_mut<CLine>();
cl->line.indices.clear();
}
inline int get_line_points_count(const String &key) const
{
flecs::entity e = lookup(key);
@@ -145,18 +137,6 @@ public:
const struct CLine *cl = e.get<CLine>();
return cl->line.points[index].origin;
}
inline void add_line_index(const String &key, int id)
{
flecs::entity e = lookup(key);
struct CLine *cl = e.get_mut<CLine>();
cl->line.indices.push_back(id);
}
inline void insert_line_index(const String &key, int index, int id)
{
flecs::entity e = lookup(key);
struct CLine *cl = e.get_mut<CLine>();
cl->line.indices.insert(cl->line.indices.begin() + index, id);
}
inline void clear_line_segments(const String &key)
{
flecs::entity e = lookup(key);
@@ -224,7 +204,82 @@ public:
}
};
class IndexAccessor {
public:
IndexAccessor()
{
BaseData::get_singleton()->get().component<CLineIndex>();
}
inline const struct RoadLinesData::road_line_index &
operator[](const String &key) const
{
flecs::entity e = lookup(key);
const struct CLineIndex *cl = e.get<CLineIndex>();
return cl->index;
}
const flecs::world &get() const
{
return BaseData::get_singleton()->get();
}
flecs::world &get()
{
return BaseData::get_singleton()->get();
}
template <typename F> void each(F &&func) const
{
get().each<F>(func);
}
inline flecs::entity lookup(const String &key) const
{
String ename = "line:" + key;
flecs::entity e = get().lookup(ename.ascii().ptr());
if (!e.is_valid())
print_line("can't find: " + key);
assert(e.is_valid());
return e;
}
inline void clear_all_line_indices()
{
BaseData::get_singleton()->get_singleton()->get().each(
[](CLineIndex &cl) { cl.index.indices.clear(); });
}
inline void clear_line_indices(const String &key)
{
flecs::entity e = lookup(key);
struct CLineIndex *cl = e.get_mut<CLineIndex>();
assert(cl);
cl->index.indices.clear();
}
inline void add_line_index(const String &key, int id)
{
flecs::entity e = lookup(key);
struct CLineIndex *cl = e.get_mut<CLineIndex>();
cl->index.indices.push_back(id);
}
inline void insert_line_index(const String &key, int index, int id)
{
flecs::entity e = lookup(key);
struct CLineIndex *cl = e.get_mut<CLineIndex>();
cl->index.indices.insert(cl->index.indices.begin() + index, id);
}
inline void
set_index(const String &key,
const struct RoadLinesData::road_line_index &index)
{
flecs::entity e = lookup_create(key);
e.set<CLineIndex>({ index });
}
inline flecs::entity lookup_create(const String &key) const
{
String ename = "line:" + key;
flecs::entity e = get().entity(ename.ascii().ptr());
assert(e.is_valid());
return e;
}
};
static LinesAccessor lines;
static IndexAccessor indices;
ImmediateGeometry *RoadLinesData::debug_im = nullptr;
static Ref<Material> debug_material;
@@ -243,6 +298,11 @@ const RoadLinesData::road_line &RoadLinesData::lines(const String &key) const
{
return ::lines[key];
}
const RoadLinesData::road_line_index &
RoadLinesData::indices(const String &key) const
{
return ::indices[key];
}
void RoadLinesData::set_line(const String &key, const road_line &line)
{
::lines.set_line(key, line);
@@ -267,11 +327,11 @@ void RoadLinesData::set_line_point_position(const String &key, int index,
}
void RoadLinesData::clear_all_line_indices()
{
::lines.clear_all_line_indices();
::indices.clear_all_line_indices();
}
void RoadLinesData::clear_line_indices(const String &key)
{
::lines.clear_line_indices(key);
::indices.clear_line_indices(key);
}
void RoadLinesData::set_line_metadata(const String &key,
const Dictionary &metadata)
@@ -366,7 +426,6 @@ void RoadLinesData::load_data()
rline.pattern = pattern;
rline.points.resize(points.size());
rline.edges.resize(edges.size());
rline.indices.resize(indices.size());
for (i = 0; i < (int)points.size(); i++) {
String point_s = points[i];
rline.points[i] = from_string<Transform>(point_s);
@@ -375,13 +434,11 @@ void RoadLinesData::load_data()
const Dictionary &d = edges[i];
rline.edges[i].from_dict(rline.edges[i], d);
}
for (i = 0; i < (int)indices.size(); i++) {
int index = indices[i];
rline.indices[i] = index;
}
// TODO: wtf is flags?
rline.lanes = lanes;
set_line(key, rline);
RoadLinesData::road_line_index index;
::indices.set_index(key, index);
e = e->next();
}
{
@@ -414,9 +471,10 @@ void RoadLinesData::save_data()
points[i] = to_string(lines(e->get()).points[i]);
for (i = 0; i < (int)lines(e->get()).edges.size(); i++)
edges[i] = lines(e->get()).edges[i].to_dict();
indices.resize(lines(e->get()).indices.size());
for (i = 0; i < (int)lines(e->get()).indices.size(); i++)
indices[i] = lines(e->get()).indices[i];
indices.resize(this->indices(e->get()).indices.size());
for (i = 0; i < (int)this->indices(e->get()).indices.size();
i++)
indices[i] = this->indices(e->get()).indices[i];
pvalues["points"] = points;
pvalues["edges"] = edges;
// pvalues["indices"] = indices;
@@ -488,7 +546,7 @@ void RoadLinesData::road_lines_curve_index(
std::vector<Vector3> &road_lines_nodes)
{
int i, j;
::lines.clear_line_indices(key);
::indices.clear_line_indices(key);
for (i = 0; i < (int)::lines.get_line_points_count(key); i++) {
Vector3 pt = ::lines.get_line_point_position(key, i);
int pt_hash = road_lines_hash(pt);
@@ -518,7 +576,7 @@ void RoadLinesData::road_lines_curve_index(
road_lines_nodes.begin(), road_lines_nodes.end(), pt);
assert(it != road_lines_nodes.end());
int index = it - road_lines_nodes.begin();
::lines.add_line_index(key, index);
::indices.add_line_index(key, index);
}
}
void RoadLinesData::index_lines(
@@ -545,19 +603,20 @@ void RoadLinesData::index_lines(
static inline int get_segment_index(const String &road, int pos)
{
RoadLinesData *rld = RoadLinesData::get_singleton();
int idx = rld->get_line(road).indices[pos];
int idx = rld->indices(road).indices[pos];
return idx;
}
void RoadLinesData::create_segments(const String &road,
std::vector<int> &segments)
{
int i;
for (i = 0; i < (int)::lines[road].indices.size() - 1; i++) {
for (i = 0; i < (int)::indices[road].indices.size() - 1; i++) {
segments.push_back(i);
segments.push_back(i + 1);
}
}
/* add close points on each line to the line */
// FIXME: used?
void RoadLinesData::insert_close_points(std::vector<Vector3> &road_lines_nodes,
float distance_squared)
{
@@ -602,7 +661,7 @@ void RoadLinesData::insert_close_points(std::vector<Vector3> &road_lines_nodes,
distance_squared) {
/* split segment and replace road
point with a point on segment */
::lines.insert_line_index(rkey, idx,
::indices.insert_line_index(rkey, idx,
idx3);
road_lines_nodes[idx3] = closest;
}
@@ -648,12 +707,12 @@ void RoadLinesData::update_road_lines_nodes(
std::tuple<String, String> data = kcmp[it->first];
const String &k = std::get<0>(data);
const String &r = std::get<1>(data);
if (::lines[k].indices.size() < 2)
if (::indices[k].indices.size() < 2)
continue;
if (::lines[r].indices.size() < 2)
if (::indices[r].indices.size() < 2)
continue;
for (i = 0; i < (int)::lines[k].indices.size() - 1; i++) {
for (j = 0; j < (int)::lines[k].indices.size() - 1;
for (i = 0; i < (int)::indices[k].indices.size() - 1; i++) {
for (j = 0; j < (int)::indices[k].indices.size() - 1;
j++) {
uint32_t key = k.hash() ^ i ^ r.hash() ^ j ^
2147483137;
@@ -661,10 +720,12 @@ void RoadLinesData::update_road_lines_nodes(
2147463167;
if (checks.find(key) == checks.end() &&
checks.find(key2) == checks.end()) {
int idx_a1 = ::lines[k].indices[i];
int idx_a2 = ::lines[k].indices[i + 1];
int idx_b1 = ::lines[k].indices[j];
int idx_b2 = ::lines[k].indices[j + 1];
int idx_a1 = ::indices[k].indices[i];
int idx_a2 =
::indices[k].indices[i + 1];
int idx_b1 = ::indices[k].indices[j];
int idx_b2 =
::indices[k].indices[j + 1];
std::vector<int> cmp1 = { idx_a1,
idx_a2 };
if (std::find(cmp1.begin(), cmp1.end(),
@@ -730,14 +791,14 @@ void RoadLinesData::update_road_lines_nodes(
int nidx = road_lines_nodes.size();
road_lines_nodes.push_back(pxt);
// int il = (int)road_lines[k].indices.size();
assert(std::find(::lines[k].indices.begin(),
::lines[k].indices.end(),
nidx) == ::lines[k].indices.end());
assert(std::find(::lines[r].indices.begin(),
::lines[r].indices.end(),
nidx) == ::lines[r].indices.end());
::lines.insert_line_index(k, i + 1, nidx);
::lines.insert_line_index(r, j + 1, nidx);
assert(std::find(::indices[k].indices.begin(),
::indices[k].indices.end(),
nidx) == ::indices[k].indices.end());
assert(std::find(::indices[r].indices.begin(),
::indices[r].indices.end(),
nidx) == ::indices[r].indices.end());
::indices.insert_line_index(k, i + 1, nidx);
::indices.insert_line_index(r, j + 1, nidx);
}
}
}

View File

@@ -192,7 +192,6 @@ public:
struct road_line {
std::vector<Transform> points;
std::vector<struct road_edge> edges;
std::vector<int> indices;
std::vector<struct line_segment> segments;
int lanes;
int pattern;
@@ -200,6 +199,9 @@ public:
Dictionary metadata;
_Signal<void> line_updated;
};
struct road_line_index {
std::vector<int> indices;
};
public:
static ImmediateGeometry *get_debug_node();
@@ -210,6 +212,7 @@ private:
public:
const struct road_line &get_line(const String &key) const;
const struct road_line &lines(const String &key) const;
const struct road_line_index &indices(const String &key) const;
void set_line(const String &key, const struct road_line &line);
bool has_line(const String &key);
void insert_line_point(const String &key, int index,

View File

@@ -578,7 +578,6 @@ void RoadLinesEditor::create_new_line_at_cursor(const String &line_name)
RoadLinesData *rld = RoadLinesData::get_singleton();
struct RoadLinesData::road_line rline;
rline.flags = 0;
rline.indices.resize(0);
rline.lanes = -1;
if (line_name.ends_with("_road"))
rline.lanes = 4;
@@ -1197,6 +1196,38 @@ class EdgeEditorHandler {
}
return true;
}
void set_lot(RoadLinesData::road_edge_side &side, const String &pname,
float dir_offt)
{
side.lot_type = pname.replace("lot-", "");
if (side.lot == 0) {
side.lot = 1;
side.lot_offset = get_edge_conf<float>(pname, "left",
"lot_offset");
side.lot_y_rotation = get_edge_conf<float>(
pname, "left", "lot_y_rotation");
side.lot_offset = get_edge_conf<float>(pname, "left",
"lot_offset");
side.lot_dir_offset = dir_offt;
}
}
String get_pname(PopupMenu *menu, int id)
{
String pname;
switch (id) {
case 200:
pname = "clear";
break;
case 201:
pname = "clear-buildings";
break;
default: {
int item_index = menu->get_item_index(id);
pname = menu->get_item_metadata(item_index);
} break;
}
return pname;
}
void event_handler(const String &event, const Vector<Variant> &args)
{
if (event == "road_lines_edge_editor::edit") {
@@ -1234,44 +1265,13 @@ class EdgeEditorHandler {
RoadLinesData *rld = RoadLinesData::get_singleton();
RoadLinesData::road_line rl =
rld->get_line(current_line);
String pname;
switch (id) {
case 200:
pname = "clear";
break;
case 201:
pname = "clear-buildings";
break;
default:
pname = menu->get_item_metadata(item_index);
break;
}
String pname = get_pname(menu, id);
if (pname.begins_with("lot-")) {
rl.edges[index].left.lot_type =
pname.replace("lot-", "");
if (rl.edges[index].left.lot == 0) {
rl.edges[index].left.lot = 1;
rl.edges[index].left.lot_offset =
get_edge_conf<float>(
pname, "left",
"lot_offset");
rl.edges[index].left.lot_y_rotation =
get_edge_conf<float>(
pname, "left",
"lot_y_rotation");
rl.edges[index].left.lot_offset =
get_edge_conf<float>(
pname, "left",
"lot_offset");
float dir_offt =
rl.points[index + 1]
.origin.distance_to(
rl.points[index]
.origin) /
rl.points[index + 1].origin.distance_to(
rl.points[index].origin) /
2.0f;
rl.edges[index].left.lot_dir_offset =
dir_offt;
}
set_lot(rl.edges[index].left, pname, dir_offt);
} else if (pname.begins_with("residental-")) {
struct RoadLinesData::road_edge_side::buildings
b;
@@ -1291,17 +1291,20 @@ class EdgeEditorHandler {
->building_aabbs
["lot-" +
lot_id];
pack_buildings(
bool pack_result = pack_buildings(
aabb_lot,
rl.edges[index]
.left.buildings,
2.0f);
assert(pack_result);
}
}
} else if (pname == "clear") {
rl.edges[index].left.lot_type = "";
rl.edges[index].left.lot = 0;
rl.edges[index].left.buildings.clear();
} else if (pname == "clear-buildings") {
rl.edges[index].right.buildings.clear();
}
rld->set_line(current_line, rl);
editor->rebuild_roads();
@@ -1309,47 +1312,16 @@ class EdgeEditorHandler {
PopupMenu *menu = Object::cast_to<PopupMenu>(args[0]);
int id = args[1];
int item_index = menu->get_item_index(id);
String pname;
switch (id) {
case 200:
pname = "clear";
break;
case 201:
pname = "clear-buildings";
break;
default:
pname = menu->get_item_metadata(item_index);
break;
}
String pname = get_pname(menu, id);
RoadLinesData *rld = RoadLinesData::get_singleton();
RoadLinesData::road_line rl =
rld->get_line(current_line);
if (pname.begins_with("lot-")) {
rl.edges[index].right.lot_type =
pname.replace("lot-", "");
if (rl.edges[index].right.lot == 0) {
rl.edges[index].right.lot = 1;
rl.edges[index].right.lot_offset =
get_edge_conf<float>(
pname, "right",
"lot_offset");
rl.edges[index].right.lot_y_rotation =
get_edge_conf<float>(
pname, "right",
"lot_y_rotation");
rl.edges[index].right.lot_offset =
get_edge_conf<float>(
pname, "right",
"lot_offset");
float dir_offt =
rl.points[index + 1]
.origin.distance_to(
rl.points[index]
.origin) /
rl.points[index + 1].origin.distance_to(
rl.points[index].origin) /
2.0f;
rl.edges[index].right.lot_dir_offset =
dir_offt;
}
set_lot(rl.edges[index].right, pname, dir_offt);
} else if (pname.begins_with("residental-") ||
pname.begins_with("business-")) {
struct RoadLinesData::road_edge_side::buildings
@@ -1370,17 +1342,20 @@ class EdgeEditorHandler {
->building_aabbs
["lot-" +
lot_id];
pack_buildings(
bool pack_result = pack_buildings(
aabb_lot,
rl.edges[index]
.right.buildings,
2.0f);
assert(pack_result);
}
}
} else if (pname == "clear") {
rl.edges[index].right.lot_type = "";
rl.edges[index].right.lot = 0;
rl.edges[index].right.buildings.clear();
} else if (pname == "clear-buildings") {
rl.edges[index].right.buildings.clear();
}
rld->set_line(current_line, rl);
editor->rebuild_roads();

View File

@@ -24,14 +24,26 @@ struct wedge {
Vector3 p[3];
Vector3 y[3];
int width1, width2;
const RoadLinesData::road_edge_side *side1, *side2;
};
struct RoadLinesProcessing {
std::vector<Vector3> nodes;
struct edgedata {
std::vector<int> neighbors;
RoadLinesData::road_edge_side *side;
};
std::unordered_map<int, struct edgedata> edges;
struct side_hash {
std::size_t operator()(const std::pair<int, int> &key) const
{
return std::hash<int>()(key.first) ^
(std::hash<int>()(key.second) << 8);
}
};
std::unordered_map<std::pair<int, int>,
const RoadLinesData::road_edge_side *, side_hash>
sides;
std::unordered_map<uint32_t, std::vector<struct wedge> > wedges;
String road_center_mesh_path, road_mid_mesh_path,
road_sidewalk_mesh_path;
@@ -386,14 +398,16 @@ out2:;
List<String>::Element *e = keys.front();
while (e) {
const String &key = e->get();
if (rld->lines(key).indices.size() < 2) {
if (rld->indices(key).indices.size() < 2) {
e = e->next();
continue;
}
for (i = 0; i < (int)rld->lines(key).indices.size() - 1;
/* creating neighbor data */
for (i = 0;
i < (int)rld->indices(key).indices.size() - 1;
i++) {
int idx1 = rld->lines(key).indices[i];
int idx2 = rld->lines(key).indices[i + 1];
int idx1 = rld->indices(key).indices[i];
int idx2 = rld->indices(key).indices[i + 1];
if (edges.find(idx1) == edges.end()) {
struct edgedata ed;
ed.neighbors.clear();
@@ -407,13 +421,19 @@ out2:;
if (std::find(edges[idx1].neighbors.begin(),
edges[idx1].neighbors.end(),
idx2) ==
edges[idx1].neighbors.end())
edges[idx1].neighbors.end()) {
edges[idx1].neighbors.push_back(idx2);
sides[{ idx1, idx2 }] =
&rld->lines(key).edges[i].right;
}
if (std::find(edges[idx2].neighbors.begin(),
edges[idx2].neighbors.end(),
idx1) ==
edges[idx2].neighbors.end())
edges[idx2].neighbors.end()) {
edges[idx2].neighbors.push_back(idx1);
sides[{ idx2, idx1 }] =
&rld->lines(key).edges[i].left;
}
}
e = e->next();
}
@@ -476,6 +496,10 @@ out2:;
}
}
if (dst <= maxdst * maxdst) {
/* split edge too close to other node
replace node's position with point on the edge
we don't create any new nodes here, only new edges.
*/
nodes[k] = np;
edges[n2].neighbors.erase(std::remove(
edges[n2].neighbors.begin(),
@@ -485,20 +509,30 @@ out2:;
edges[n1].neighbors.end(), n2));
if (std::find(edges[k].neighbors.begin(),
edges[k].neighbors.end(),
n1) == edges[k].neighbors.end())
n1) == edges[k].neighbors.end()) {
edges[k].neighbors.push_back(n1);
assert(sides.find({ n2, n1 }) !=
sides.end());
sides[{ k, n1 }] = sides[{ n2, n1 }];
}
if (std::find(edges[k].neighbors.begin(),
edges[k].neighbors.end(),
n2) == edges[k].neighbors.end())
n2) == edges[k].neighbors.end()) {
edges[k].neighbors.push_back(n2);
sides[{ k, n2 }] = sides[{ n1, n2 }];
}
if (std::find(edges[n1].neighbors.begin(),
edges[n1].neighbors.end(),
k) == edges[n1].neighbors.end())
k) == edges[n1].neighbors.end()) {
edges[n1].neighbors.push_back(k);
sides[{ n1, k }] = sides[{ n1, n2 }];
}
if (std::find(edges[n2].neighbors.begin(),
edges[n2].neighbors.end(),
k) == edges[n2].neighbors.end())
k) == edges[n2].neighbors.end()) {
edges[n2].neighbors.push_back(k);
sides[{ n2, k }] = sides[{ n2, n1 }];
}
print_verbose("FIXED: " + itos(k) + ": " +
String::num(dst));
}
@@ -536,7 +570,20 @@ out2:;
for (j = 0; j < (int)edges[i].neighbors.size(); j++) {
if (edges[i].neighbors.size() == 0)
continue;
/* 1 = side to center, 2 - center to other side */
int idx1 = i;
int idx2 = edges[i].neighbors[j];
int onext = (j + 1) % edges[i].neighbors.size();
int idx3 = edges[i].neighbors[onext];
const RoadLinesData::road_edge_side *side1 =
sides[{ idx2, idx1 }];
const RoadLinesData::road_edge_side *side2 =
sides[{ idx1, idx3 }];
print_line(itos(sides.size()));
print_line(itos(idx2) + " " + itos(idx1));
print_line(itos(idx1) + " " + itos(idx3));
assert(side1);
assert(side2);
Vector3 n1 = normal(node - neighbors[j]);
Vector3 n2 = normal(neighbors[onext] - node);
float angle = n1.signed_angle_to(
@@ -604,6 +651,8 @@ out2:;
w.y[2] = o3;
w.width1 = 2.0f * 5.0f;
w.width2 = 2.0f * 5.0f;
w.side1 = side1;
w.side2 = side2;
wedges[i].push_back(w);
}
}