mirror of
https://github.com/Relintai/props.git
synced 2025-02-04 16:05:54 +01:00
More cleanups/initial setup for TiledWall.
This commit is contained in:
parent
e2916f12b3
commit
2e4ab17d2e
@ -75,16 +75,12 @@ AABB TiledWall::get_aabb() const {
|
|||||||
PoolVector<Face3> TiledWall::get_faces(uint32_t p_usage_flags) const {
|
PoolVector<Face3> TiledWall::get_faces(uint32_t p_usage_flags) const {
|
||||||
PoolVector<Face3> faces;
|
PoolVector<Face3> faces;
|
||||||
|
|
||||||
/*
|
if (_mesh_array.size() != Mesh::ARRAY_MAX) {
|
||||||
if (_mesh.is_valid()) {
|
|
||||||
Array arrs = _mesh->get_array_const();
|
|
||||||
|
|
||||||
if (arrs.size() != Mesh::ARRAY_MAX) {
|
|
||||||
return faces;
|
return faces;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolVector<Vector3> vertices = arrs[Mesh::ARRAY_VERTEX];
|
PoolVector<Vector3> vertices = _mesh_array[Mesh::ARRAY_VERTEX];
|
||||||
PoolVector<int> indices = arrs[Mesh::ARRAY_INDEX];
|
PoolVector<int> indices = _mesh_array[Mesh::ARRAY_INDEX];
|
||||||
|
|
||||||
int ts = indices.size() / 3;
|
int ts = indices.size() / 3;
|
||||||
faces.resize(ts);
|
faces.resize(ts);
|
||||||
@ -102,8 +98,7 @@ PoolVector<Face3> TiledWall::get_faces(uint32_t p_usage_flags) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.release();
|
w.release();
|
||||||
}
|
|
||||||
*/
|
|
||||||
return faces;
|
return faces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,35 +150,39 @@ void TiledWall::generate_mesh() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//data->mesh()
|
if (!_cache.is_valid()) {
|
||||||
|
|
||||||
//_mesher->
|
|
||||||
|
|
||||||
/*
|
|
||||||
Array arr = _mesher->get_array();
|
|
||||||
|
|
||||||
if (arr.size() != Mesh::ARRAY_MAX) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolVector<Vector3> vertices = arr[Mesh::ARRAY_VERTEX];
|
//_mesher->tiled wall mesh_wimple(w, h, TWD, cache)
|
||||||
|
|
||||||
|
_mesh_array = _mesher->build_mesh();
|
||||||
|
|
||||||
|
if (_mesh_array.size() != Mesh::ARRAY_MAX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolVector<Vector3> vertices = _mesh_array[Mesh::ARRAY_VERTEX];
|
||||||
|
|
||||||
if (vertices.size() == 0) {
|
if (vertices.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, arr);
|
VisualServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, _mesh_array);
|
||||||
|
|
||||||
if (_material.is_valid()) {
|
Ref<Material> material = _cache->material_lod_get(0);
|
||||||
VisualServer::get_singleton()->mesh_surface_set_material(_mesh_rid, 0, _material->get_rid());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//setup new aabb
|
if (material.is_valid()) {
|
||||||
|
VisualServer::get_singleton()->mesh_surface_set_material(_mesh_rid, 0, material->get_rid());
|
||||||
|
}
|
||||||
|
|
||||||
|
_aabb.size = Vector3(_width, _height, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TiledWall::clear_mesh() {
|
void TiledWall::clear_mesh() {
|
||||||
_mesher->reset();
|
_mesher->reset();
|
||||||
_aabb = AABB();
|
_aabb = AABB();
|
||||||
|
_mesh_array.clear();
|
||||||
|
|
||||||
if (_mesh_rid != RID()) {
|
if (_mesh_rid != RID()) {
|
||||||
if (VS::get_singleton()->mesh_get_surface_count(_mesh_rid) > 0)
|
if (VS::get_singleton()->mesh_get_surface_count(_mesh_rid) > 0)
|
||||||
|
@ -86,6 +86,8 @@ private:
|
|||||||
AABB _aabb;
|
AABB _aabb;
|
||||||
|
|
||||||
RID _mesh_rid;
|
RID _mesh_rid;
|
||||||
|
|
||||||
|
Array _mesh_array;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,6 +48,7 @@ SOFTWARE.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
class PropMaterialCache;
|
class PropMaterialCache;
|
||||||
|
class PropMesher;
|
||||||
|
|
||||||
class TiledWallData : public Resource {
|
class TiledWallData : public Resource {
|
||||||
GDCLASS(TiledWallData, Resource);
|
GDCLASS(TiledWallData, Resource);
|
||||||
@ -109,10 +110,6 @@ public:
|
|||||||
|
|
||||||
//Ref<Shape> get_collider_shape();
|
//Ref<Shape> get_collider_shape();
|
||||||
|
|
||||||
//generate mesh -> add mesh into
|
|
||||||
//genmerate_mesh() -> generate_mesh() PropMesher
|
|
||||||
//PropMesher->tiled wall mesh_wimple(w, h, TWD, cache)
|
|
||||||
|
|
||||||
TiledWallData();
|
TiledWallData();
|
||||||
~TiledWallData();
|
~TiledWallData();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user