Added some API to visual server so from control VRAM buffer is more easy
This commit is contained in:
parent
b204389762
commit
fbf3ad2841
|
@ -3229,6 +3229,24 @@ VS::BlendShapeMode RasterizerStorageGLES3::mesh_get_blend_shape_mode(RID p_mesh)
|
||||||
return mesh->blend_shape_mode;
|
return mesh->blend_shape_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t RasterizerStorageGLES3::mesh_surface_get_stride_in_array(RID p_mesh, int p_surface, int p_array_index) const {
|
||||||
|
Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!mesh, 0);
|
||||||
|
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), 0);
|
||||||
|
ERR_FAIL_INDEX_V(p_array_index, VS::ARRAY_MAX, 0);
|
||||||
|
|
||||||
|
return mesh->surfaces[p_surface]->attribs[p_array_index].stride;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RasterizerStorageGLES3::mesh_surface_get_offset_in_array(RID p_mesh, int p_surface, int p_array_index) const {
|
||||||
|
Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
|
ERR_FAIL_COND_V(!mesh, 0);
|
||||||
|
ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), 0);
|
||||||
|
ERR_FAIL_INDEX_V(p_array_index, VS::ARRAY_MAX, 0);
|
||||||
|
|
||||||
|
return mesh->surfaces[p_surface]->attribs[p_array_index].offset;
|
||||||
|
}
|
||||||
|
|
||||||
void RasterizerStorageGLES3::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {
|
void RasterizerStorageGLES3::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {
|
||||||
|
|
||||||
Mesh *mesh = mesh_owner.getornull(p_mesh);
|
Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
|
@ -3240,7 +3258,7 @@ void RasterizerStorageGLES3::mesh_surface_update_region(RID p_mesh, int p_surfac
|
||||||
|
|
||||||
PoolVector<uint8_t>::Read r = p_data.read();
|
PoolVector<uint8_t>::Read r = p_data.read();
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mesh->surfaces[p_surface]->array_id);
|
glBindBuffer(GL_ARRAY_BUFFER, mesh->surfaces[p_surface]->vertex_id);
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, p_offset, total_size, r.ptr());
|
glBufferSubData(GL_ARRAY_BUFFER, p_offset, total_size, r.ptr());
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
|
glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind
|
||||||
}
|
}
|
||||||
|
@ -3404,6 +3422,7 @@ Vector<PoolVector<uint8_t> > RasterizerStorageGLES3::mesh_surface_get_blend_shap
|
||||||
|
|
||||||
return bsarr;
|
return bsarr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<AABB> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
|
Vector<AABB> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
|
||||||
|
|
||||||
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
|
@ -3455,6 +3474,7 @@ void RasterizerStorageGLES3::mesh_remove_surface(RID p_mesh, int p_surface) {
|
||||||
|
|
||||||
mesh->instance_change_notify();
|
mesh->instance_change_notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const {
|
int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const {
|
||||||
|
|
||||||
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||||
|
@ -3468,6 +3488,7 @@ void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb
|
||||||
ERR_FAIL_COND(!mesh);
|
ERR_FAIL_COND(!mesh);
|
||||||
|
|
||||||
mesh->custom_aabb = p_aabb;
|
mesh->custom_aabb = p_aabb;
|
||||||
|
mesh->instance_change_notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const {
|
AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const {
|
||||||
|
|
|
@ -693,7 +693,6 @@ public:
|
||||||
AABB custom_aabb;
|
AABB custom_aabb;
|
||||||
mutable uint64_t last_pass;
|
mutable uint64_t last_pass;
|
||||||
SelfList<MultiMesh>::List multimeshes;
|
SelfList<MultiMesh>::List multimeshes;
|
||||||
|
|
||||||
_FORCE_INLINE_ void update_multimeshes() {
|
_FORCE_INLINE_ void update_multimeshes() {
|
||||||
|
|
||||||
SelfList<MultiMesh> *mm = multimeshes.first();
|
SelfList<MultiMesh> *mm = multimeshes.first();
|
||||||
|
@ -723,6 +722,8 @@ public:
|
||||||
virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode);
|
virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode);
|
||||||
virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const;
|
virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const;
|
||||||
|
|
||||||
|
virtual uint32_t mesh_surface_get_stride_in_array(RID p_mesh, int p_surface, int p_array_index) const;
|
||||||
|
virtual uint32_t mesh_surface_get_offset_in_array(RID p_mesh, int p_surface, int p_array_index) const;
|
||||||
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data);
|
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data);
|
||||||
|
|
||||||
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material);
|
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material);
|
||||||
|
|
|
@ -252,6 +252,8 @@ public:
|
||||||
virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) = 0;
|
virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) = 0;
|
||||||
virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
|
virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
|
||||||
|
|
||||||
|
virtual uint32_t mesh_surface_get_stride_in_array(RID p_mesh, int p_surface, int p_array_index) const = 0;
|
||||||
|
virtual uint32_t mesh_surface_get_offset_in_array(RID p_mesh, int p_surface, int p_array_index) const = 0;
|
||||||
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) = 0;
|
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) = 0;
|
||||||
|
|
||||||
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
|
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
|
||||||
|
@ -277,6 +279,7 @@ public:
|
||||||
virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0;
|
virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0;
|
||||||
|
|
||||||
virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0;
|
virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0;
|
||||||
|
|
||||||
virtual void mesh_clear(RID p_mesh) = 0;
|
virtual void mesh_clear(RID p_mesh) = 0;
|
||||||
|
|
||||||
/* MULTIMESH API */
|
/* MULTIMESH API */
|
||||||
|
|
|
@ -97,6 +97,7 @@ public:
|
||||||
#define DISPLAY_CHANGED \
|
#define DISPLAY_CHANGED \
|
||||||
changes++;
|
changes++;
|
||||||
#endif
|
#endif
|
||||||
|
// print_line(String("CHANGED: ") + __FUNCTION__);
|
||||||
|
|
||||||
#define BIND0R(m_r, m_name) \
|
#define BIND0R(m_r, m_name) \
|
||||||
m_r m_name() { return BINDBASE->m_name(); }
|
m_r m_name() { return BINDBASE->m_name(); }
|
||||||
|
@ -218,6 +219,8 @@ public:
|
||||||
BIND2(mesh_set_blend_shape_mode, RID, BlendShapeMode)
|
BIND2(mesh_set_blend_shape_mode, RID, BlendShapeMode)
|
||||||
BIND1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID)
|
BIND1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID)
|
||||||
|
|
||||||
|
BIND3RC(uint32_t, mesh_surface_get_stride_in_array, RID, int, int)
|
||||||
|
BIND3RC(uint32_t, mesh_surface_get_offset_in_array, RID, int, int)
|
||||||
BIND4(mesh_surface_update_region, RID, int, int, const PoolVector<uint8_t> &)
|
BIND4(mesh_surface_update_region, RID, int, int, const PoolVector<uint8_t> &)
|
||||||
|
|
||||||
BIND3(mesh_surface_set_material, RID, int, RID)
|
BIND3(mesh_surface_set_material, RID, int, RID)
|
||||||
|
|
|
@ -64,7 +64,7 @@ class VisualServerWrapMT : public VisualServer {
|
||||||
|
|
||||||
int pool_max_size;
|
int pool_max_size;
|
||||||
|
|
||||||
//#define DEBUG_SYNC
|
//#define DEBUG_SYNC
|
||||||
|
|
||||||
static VisualServerWrapMT *singleton_mt;
|
static VisualServerWrapMT *singleton_mt;
|
||||||
|
|
||||||
|
@ -152,6 +152,8 @@ public:
|
||||||
FUNC2(mesh_set_blend_shape_mode, RID, BlendShapeMode)
|
FUNC2(mesh_set_blend_shape_mode, RID, BlendShapeMode)
|
||||||
FUNC1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID)
|
FUNC1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID)
|
||||||
|
|
||||||
|
FUNC3RC(uint32_t, mesh_surface_get_stride_in_array, RID, int, int)
|
||||||
|
FUNC3RC(uint32_t, mesh_surface_get_offset_in_array, RID, int, int)
|
||||||
FUNC4(mesh_surface_update_region, RID, int, int, const PoolVector<uint8_t> &)
|
FUNC4(mesh_surface_update_region, RID, int, int, const PoolVector<uint8_t> &)
|
||||||
|
|
||||||
FUNC3(mesh_surface_set_material, RID, int, RID)
|
FUNC3(mesh_surface_set_material, RID, int, RID)
|
||||||
|
|
|
@ -1569,6 +1569,9 @@ void VisualServer::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count);
|
ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count);
|
||||||
ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode);
|
ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode);
|
||||||
ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode);
|
ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode);
|
||||||
|
ClassDB::bind_method(D_METHOD("mesh_surface_get_stride_in_array", "mesh", "surface", "array_index"), &VisualServer::mesh_surface_get_stride_in_array);
|
||||||
|
ClassDB::bind_method(D_METHOD("mesh_surface_get_offset_in_array", "mesh", "surface", "array_index"), &VisualServer::mesh_surface_get_offset_in_array);
|
||||||
|
ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &VisualServer::mesh_surface_update_region);
|
||||||
ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material);
|
ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material);
|
||||||
ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material);
|
ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material);
|
||||||
ClassDB::bind_method(D_METHOD("mesh_surface_get_array_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_len);
|
ClassDB::bind_method(D_METHOD("mesh_surface_get_array_len", "mesh", "surface"), &VisualServer::mesh_surface_get_array_len);
|
||||||
|
|
|
@ -265,6 +265,8 @@ public:
|
||||||
virtual void mesh_set_blend_shape_mode(RID p_mesh, BlendShapeMode p_mode) = 0;
|
virtual void mesh_set_blend_shape_mode(RID p_mesh, BlendShapeMode p_mode) = 0;
|
||||||
virtual BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
|
virtual BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
|
||||||
|
|
||||||
|
virtual uint32_t mesh_surface_get_stride_in_array(RID p_mesh, int p_surface, int p_array_index) const = 0;
|
||||||
|
virtual uint32_t mesh_surface_get_offset_in_array(RID p_mesh, int p_surface, int p_array_index) const = 0;
|
||||||
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) = 0;
|
virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) = 0;
|
||||||
|
|
||||||
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
|
virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
|
||||||
|
|
Loading…
Reference in New Issue