mirror of
https://github.com/godotengine/godot.git
synced 2024-11-11 14:43:44 +00:00
Unify naming of blendshape / morphtarget into just "Blend Shape"
This commit is contained in:
parent
5afaf84ae1
commit
35b404ba08
@ -1251,9 +1251,9 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e) {
|
||||
|
||||
RasterizerStorageGLES3::Surface *s = static_cast<RasterizerStorageGLES3::Surface*>(e->geometry);
|
||||
|
||||
if (s->morph_targets.size() && e->instance->morph_values.size()) {
|
||||
if (s->blend_shapes.size() && e->instance->blend_values.size()) {
|
||||
//blend shapes, use transform feedback
|
||||
storage->mesh_render_blend_shapes(s,e->instance->morph_values.ptr());
|
||||
storage->mesh_render_blend_shapes(s,e->instance->blend_values.ptr());
|
||||
//rebind shader
|
||||
state.scene_shader.bind();
|
||||
} else {
|
||||
|
@ -2480,7 +2480,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||
}
|
||||
|
||||
|
||||
bool has_morph = p_blend_shapes.size();
|
||||
//bool has_morph = p_blend_shapes.size();
|
||||
|
||||
Surface::Attrib attribs[VS::ARRAY_MAX];
|
||||
|
||||
@ -2702,7 +2702,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||
|
||||
ERR_FAIL_COND(p_index_array.size()!=index_array_size);
|
||||
|
||||
ERR_FAIL_COND(p_blend_shapes.size()!=mesh->morph_target_count);
|
||||
ERR_FAIL_COND(p_blend_shapes.size()!=mesh->blend_shape_count);
|
||||
|
||||
for(int i=0;i<p_blend_shapes.size();i++) {
|
||||
ERR_FAIL_COND(p_blend_shapes[i].size()!=array_size);
|
||||
@ -2807,7 +2807,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||
|
||||
for(int i=0;i<p_blend_shapes.size();i++) {
|
||||
|
||||
Surface::MorphTarget mt;
|
||||
Surface::BlendShape mt;
|
||||
|
||||
PoolVector<uint8_t>::Read vr = p_blend_shapes[i].read();
|
||||
|
||||
@ -2837,7 +2837,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0); //unbind
|
||||
|
||||
surface->morph_targets.push_back(mt);
|
||||
surface->blend_shapes.push_back(mt);
|
||||
|
||||
}
|
||||
}
|
||||
@ -2846,7 +2846,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
|
||||
mesh->instance_change_notify();
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES3::mesh_set_morph_target_count(RID p_mesh,int p_amount){
|
||||
void RasterizerStorageGLES3::mesh_set_blend_shape_count(RID p_mesh,int p_amount){
|
||||
|
||||
Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
@ -2855,32 +2855,32 @@ void RasterizerStorageGLES3::mesh_set_morph_target_count(RID p_mesh,int p_amount
|
||||
ERR_FAIL_COND(mesh->surfaces.size()!=0);
|
||||
ERR_FAIL_COND(p_amount<0);
|
||||
|
||||
mesh->morph_target_count=p_amount;
|
||||
mesh->blend_shape_count=p_amount;
|
||||
|
||||
}
|
||||
int RasterizerStorageGLES3::mesh_get_morph_target_count(RID p_mesh) const{
|
||||
int RasterizerStorageGLES3::mesh_get_blend_shape_count(RID p_mesh) const{
|
||||
|
||||
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh,0);
|
||||
|
||||
return mesh->morph_target_count;
|
||||
return mesh->blend_shape_count;
|
||||
}
|
||||
|
||||
|
||||
void RasterizerStorageGLES3::mesh_set_morph_target_mode(RID p_mesh,VS::MorphTargetMode p_mode){
|
||||
void RasterizerStorageGLES3::mesh_set_blend_shape_mode(RID p_mesh,VS::BlendShapeMode p_mode){
|
||||
|
||||
Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||
ERR_FAIL_COND(!mesh);
|
||||
|
||||
mesh->morph_target_mode=p_mode;
|
||||
mesh->blend_shape_mode=p_mode;
|
||||
|
||||
}
|
||||
VS::MorphTargetMode RasterizerStorageGLES3::mesh_get_morph_target_mode(RID p_mesh) const{
|
||||
VS::BlendShapeMode RasterizerStorageGLES3::mesh_get_blend_shape_mode(RID p_mesh) const{
|
||||
|
||||
const Mesh *mesh = mesh_owner.getornull(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh,VS::MORPH_MODE_NORMALIZED);
|
||||
ERR_FAIL_COND_V(!mesh,VS::BLEND_SHAPE_MODE_NORMALIZED);
|
||||
|
||||
return mesh->morph_target_mode;
|
||||
return mesh->blend_shape_mode;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES3::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material){
|
||||
@ -3027,9 +3027,9 @@ Vector<PoolVector<uint8_t> > RasterizerStorageGLES3::mesh_surface_get_blend_shap
|
||||
|
||||
Vector<PoolVector<uint8_t> > bsarr;
|
||||
|
||||
for(int i=0;i<mesh->surfaces[p_surface]->morph_targets.size();i++) {
|
||||
for(int i=0;i<mesh->surfaces[p_surface]->blend_shapes.size();i++) {
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,mesh->surfaces[p_surface]->morph_targets[i].vertex_id);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,mesh->surfaces[p_surface]->blend_shapes[i].vertex_id);
|
||||
void * data = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER,0,mesh->surfaces[p_surface]->array_byte_size,GL_MAP_READ_BIT);
|
||||
|
||||
ERR_FAIL_COND_V(!data,Vector<PoolVector<uint8_t> >());
|
||||
@ -3081,10 +3081,10 @@ void RasterizerStorageGLES3::mesh_remove_surface(RID p_mesh, int p_surface){
|
||||
|
||||
glDeleteVertexArrays(1,&surface->array_id);
|
||||
|
||||
for(int i=0;i<surface->morph_targets.size();i++) {
|
||||
for(int i=0;i<surface->blend_shapes.size();i++) {
|
||||
|
||||
glDeleteBuffers(1,&surface->morph_targets[i].vertex_id);
|
||||
glDeleteVertexArrays(1,&surface->morph_targets[i].array_id);
|
||||
glDeleteBuffers(1,&surface->blend_shapes[i].vertex_id);
|
||||
glDeleteVertexArrays(1,&surface->blend_shapes[i].array_id);
|
||||
}
|
||||
|
||||
mesh->instance_material_change_notify();
|
||||
@ -3290,9 +3290,9 @@ void RasterizerStorageGLES3::mesh_render_blend_shapes(Surface *s, float *p_weigh
|
||||
//copy all first
|
||||
float base_weight=1.0;
|
||||
|
||||
int mtc = s->morph_targets.size();
|
||||
int mtc = s->blend_shapes.size();
|
||||
|
||||
if (s->mesh->morph_target_mode==VS::MORPH_MODE_NORMALIZED) {
|
||||
if (s->mesh->blend_shape_mode==VS::BLEND_SHAPE_MODE_NORMALIZED) {
|
||||
|
||||
for(int i=0;i<mtc;i++) {
|
||||
base_weight-=p_weights[i];
|
||||
@ -3324,7 +3324,7 @@ void RasterizerStorageGLES3::mesh_render_blend_shapes(Surface *s, float *p_weigh
|
||||
if (weight<0.001) //not bother with this one
|
||||
continue;
|
||||
|
||||
glBindVertexArray(s->morph_targets[ti].array_id);
|
||||
glBindVertexArray(s->blend_shapes[ti].array_id);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, resources.transform_feedback_buffers[0]);
|
||||
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, resources.transform_feedback_buffers[1]);
|
||||
|
||||
|
@ -531,12 +531,12 @@ public:
|
||||
|
||||
//bool packed;
|
||||
|
||||
struct MorphTarget {
|
||||
struct BlendShape {
|
||||
GLuint vertex_id;
|
||||
GLuint array_id;
|
||||
};
|
||||
|
||||
Vector<MorphTarget> morph_targets;
|
||||
Vector<BlendShape> blend_shapes;
|
||||
|
||||
Rect3 aabb;
|
||||
|
||||
@ -583,13 +583,13 @@ public:
|
||||
|
||||
bool active;
|
||||
Vector<Surface*> surfaces;
|
||||
int morph_target_count;
|
||||
VS::MorphTargetMode morph_target_mode;
|
||||
int blend_shape_count;
|
||||
VS::BlendShapeMode blend_shape_mode;
|
||||
Rect3 custom_aabb;
|
||||
mutable uint64_t last_pass;
|
||||
Mesh() {
|
||||
morph_target_mode=VS::MORPH_MODE_NORMALIZED;
|
||||
morph_target_count=0;
|
||||
blend_shape_mode=VS::BLEND_SHAPE_MODE_NORMALIZED;
|
||||
blend_shape_count=0;
|
||||
last_pass=0;
|
||||
active=false;
|
||||
}
|
||||
@ -601,12 +601,12 @@ public:
|
||||
|
||||
virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<Rect3>& p_bone_aabbs=Vector<Rect3>());
|
||||
|
||||
virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount);
|
||||
virtual int mesh_get_morph_target_count(RID p_mesh) const;
|
||||
virtual void mesh_set_blend_shape_count(RID p_mesh,int p_amount);
|
||||
virtual int mesh_get_blend_shape_count(RID p_mesh) const;
|
||||
|
||||
|
||||
virtual void mesh_set_morph_target_mode(RID p_mesh,VS::MorphTargetMode p_mode);
|
||||
virtual VS::MorphTargetMode mesh_get_morph_target_mode(RID p_mesh) const;
|
||||
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 void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material);
|
||||
virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const;
|
||||
|
@ -42,10 +42,10 @@ bool MeshInstance::_set(const StringName& p_name, const Variant& p_value) {
|
||||
return false;
|
||||
|
||||
|
||||
Map<StringName,MorphTrack>::Element *E = morph_tracks.find(p_name);
|
||||
Map<StringName,BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
|
||||
if (E) {
|
||||
E->get().value=p_value;
|
||||
VisualServer::get_singleton()->instance_set_morph_target_weight(get_instance(),E->get().idx,E->get().value);
|
||||
VisualServer::get_singleton()->instance_set_blend_shape_weight(get_instance(),E->get().idx,E->get().value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ bool MeshInstance::_get(const StringName& p_name,Variant &r_ret) const {
|
||||
if (!get_instance().is_valid())
|
||||
return false;
|
||||
|
||||
const Map<StringName,MorphTrack>::Element *E = morph_tracks.find(p_name);
|
||||
const Map<StringName,BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
|
||||
if (E) {
|
||||
r_ret = E->get().value;
|
||||
return true;
|
||||
@ -86,7 +86,7 @@ bool MeshInstance::_get(const StringName& p_name,Variant &r_ret) const {
|
||||
void MeshInstance::_get_property_list( List<PropertyInfo> *p_list) const {
|
||||
|
||||
List<String> ls;
|
||||
for(const Map<StringName,MorphTrack>::Element *E=morph_tracks.front();E;E=E->next()) {
|
||||
for(const Map<StringName,BlendShapeTrack>::Element *E=blend_shape_tracks.front();E;E=E->next()) {
|
||||
|
||||
ls.push_back(E->key());
|
||||
}
|
||||
@ -119,16 +119,16 @@ void MeshInstance::set_mesh(const Ref<Mesh>& p_mesh) {
|
||||
|
||||
mesh=p_mesh;
|
||||
|
||||
morph_tracks.clear();
|
||||
blend_shape_tracks.clear();
|
||||
if (mesh.is_valid()) {
|
||||
|
||||
|
||||
for(int i=0;i<mesh->get_morph_target_count();i++) {
|
||||
for(int i=0;i<mesh->get_blend_shape_count();i++) {
|
||||
|
||||
MorphTrack mt;
|
||||
BlendShapeTrack mt;
|
||||
mt.idx=i;
|
||||
mt.value=0;
|
||||
morph_tracks["morph/"+String(mesh->get_morph_target_name(i))]=mt;
|
||||
blend_shape_tracks["blend_shapes/"+String(mesh->get_blend_shape_name(i))]=mt;
|
||||
}
|
||||
|
||||
mesh->connect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_mesh_changed);
|
||||
|
@ -42,14 +42,14 @@ class MeshInstance : public GeometryInstance {
|
||||
Ref<Mesh> mesh;
|
||||
NodePath skeleton_path;
|
||||
|
||||
struct MorphTrack {
|
||||
struct BlendShapeTrack {
|
||||
|
||||
int idx;
|
||||
float value;
|
||||
MorphTrack() { idx=0; value=0; }
|
||||
BlendShapeTrack() { idx=0; value=0; }
|
||||
};
|
||||
|
||||
Map<StringName,MorphTrack> morph_tracks;
|
||||
Map<StringName,BlendShapeTrack> blend_shape_tracks;
|
||||
Vector<Ref<Material> > materials;
|
||||
|
||||
void _mesh_changed();
|
||||
|
@ -77,19 +77,19 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
|
||||
|
||||
String sname=p_name;
|
||||
|
||||
if (p_name=="morph_target/names") {
|
||||
if (p_name=="blend_shape/names") {
|
||||
|
||||
PoolVector<String> sk=p_value;
|
||||
int sz = sk.size();
|
||||
PoolVector<String>::Read r = sk.read();
|
||||
for(int i=0;i<sz;i++)
|
||||
add_morph_target(r[i]);
|
||||
add_blend_shape(r[i]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p_name=="morph_target/mode") {
|
||||
if (p_name=="blend_shape/mode") {
|
||||
|
||||
set_morph_target_mode(MorphTargetMode(int(p_value)));
|
||||
set_blend_shape_mode(BlendShapeMode(int(p_value)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -128,8 +128,8 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
|
||||
|
||||
if (d.has("arrays")) {
|
||||
//old format
|
||||
ERR_FAIL_COND_V(!d.has("morph_arrays"),false);
|
||||
add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"]);
|
||||
ERR_FAIL_COND_V(!d.has("blend_shape_arrays"),false);
|
||||
add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["blend_shape_arrays"]);
|
||||
|
||||
} else if (d.has("array_data")) {
|
||||
|
||||
@ -151,13 +151,13 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
|
||||
if (d.has("index_count"))
|
||||
index_count=d["index_count"];
|
||||
|
||||
Vector< PoolVector<uint8_t> > morphs;
|
||||
Vector< PoolVector<uint8_t> > blend_shapes;
|
||||
|
||||
if (d.has("morph_data")) {
|
||||
Array morph_data=d["morph_data"];
|
||||
for(int i=0;i<morph_data.size();i++) {
|
||||
PoolVector<uint8_t> morph = morph_data[i];
|
||||
morphs.push_back(morph_data[i]);
|
||||
if (d.has("blend_shape_data")) {
|
||||
Array blend_shape_data=d["blend_shape_data"];
|
||||
for(int i=0;i<blend_shape_data.size();i++) {
|
||||
PoolVector<uint8_t> shape = blend_shape_data[i];
|
||||
blend_shapes.push_back(shape);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
|
||||
}
|
||||
}
|
||||
|
||||
add_surface(format,PrimitiveType(primitive),array_data,vertex_count,array_index_data,index_count,aabb,morphs,bone_aabb);
|
||||
add_surface(format,PrimitiveType(primitive),array_data,vertex_count,array_index_data,index_count,aabb,blend_shapes,bone_aabb);
|
||||
} else {
|
||||
ERR_FAIL_V(false);
|
||||
}
|
||||
@ -199,16 +199,16 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
|
||||
|
||||
String sname=p_name;
|
||||
|
||||
if (p_name=="morph_target/names") {
|
||||
if (p_name=="blend_shape/names") {
|
||||
|
||||
PoolVector<String> sk;
|
||||
for(int i=0;i<morph_targets.size();i++)
|
||||
sk.push_back(morph_targets[i]);
|
||||
for(int i=0;i<blend_shapes.size();i++)
|
||||
sk.push_back(blend_shapes[i]);
|
||||
r_ret=sk;
|
||||
return true;
|
||||
} else if (p_name=="morph_target/mode") {
|
||||
} else if (p_name=="blend_shape/mode") {
|
||||
|
||||
r_ret = get_morph_target_mode();
|
||||
r_ret = get_blend_shape_mode();
|
||||
return true;
|
||||
} else if (sname.begins_with("surface_")) {
|
||||
|
||||
@ -251,14 +251,14 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
|
||||
}
|
||||
d["skeleton_aabb"]=arr;
|
||||
|
||||
Vector< PoolVector<uint8_t> > morph_data = VS::get_singleton()->mesh_surface_get_blend_shapes(mesh,idx);
|
||||
Vector< PoolVector<uint8_t> > blend_shape_data = VS::get_singleton()->mesh_surface_get_blend_shapes(mesh,idx);
|
||||
|
||||
Array md;
|
||||
for(int i=0;i<morph_data.size();i++) {
|
||||
md.push_back(morph_data[i]);
|
||||
for(int i=0;i<blend_shape_data.size();i++) {
|
||||
md.push_back(blend_shape_data[i]);
|
||||
}
|
||||
|
||||
d["morph_data"]=md;
|
||||
d["blend_shape_data"]=md;
|
||||
|
||||
Ref<Material> m = surface_get_material(idx);
|
||||
if (m.is_valid())
|
||||
@ -274,9 +274,9 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
|
||||
|
||||
void Mesh::_get_property_list( List<PropertyInfo> *p_list) const {
|
||||
|
||||
if (morph_targets.size()) {
|
||||
p_list->push_back(PropertyInfo(Variant::POOL_STRING_ARRAY,"morph_target/names",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
|
||||
p_list->push_back(PropertyInfo(Variant::INT,"morph_target/mode",PROPERTY_HINT_ENUM,"Normalized,Relative"));
|
||||
if (blend_shapes.size()) {
|
||||
p_list->push_back(PropertyInfo(Variant::POOL_STRING_ARRAY,"blend_shape/names",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
|
||||
p_list->push_back(PropertyInfo(Variant::INT,"blend_shape/mode",PROPERTY_HINT_ENUM,"Normalized,Relative"));
|
||||
}
|
||||
|
||||
for (int i=0;i<surfaces.size();i++) {
|
||||
@ -364,7 +364,7 @@ Array Mesh::surface_get_arrays(int p_surface) const {
|
||||
return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh,p_surface);
|
||||
|
||||
}
|
||||
Array Mesh::surface_get_morph_arrays(int p_surface) const {
|
||||
Array Mesh::surface_get_blend_shape_arrays(int p_surface) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
|
||||
return Array();
|
||||
@ -379,7 +379,7 @@ int Mesh::get_surface_count() const {
|
||||
return surfaces.size();
|
||||
}
|
||||
|
||||
void Mesh::add_morph_target(const StringName& p_name) {
|
||||
void Mesh::add_blend_shape(const StringName& p_name) {
|
||||
|
||||
if (surfaces.size()) {
|
||||
ERR_EXPLAIN("Can't add a shape key count if surfaces are already created.");
|
||||
@ -388,49 +388,49 @@ void Mesh::add_morph_target(const StringName& p_name) {
|
||||
|
||||
StringName name=p_name;
|
||||
|
||||
if (morph_targets.find(name)!=-1 ) {
|
||||
if (blend_shapes.find(name)!=-1 ) {
|
||||
|
||||
int count=2;
|
||||
do {
|
||||
|
||||
name = String(p_name) + " " + itos(count);
|
||||
count++;
|
||||
} while(morph_targets.find(name)!=-1);
|
||||
} while(blend_shapes.find(name)!=-1);
|
||||
}
|
||||
|
||||
morph_targets.push_back(name);
|
||||
VS::get_singleton()->mesh_set_morph_target_count(mesh,morph_targets.size());
|
||||
blend_shapes.push_back(name);
|
||||
VS::get_singleton()->mesh_set_blend_shape_count(mesh,blend_shapes.size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
int Mesh::get_morph_target_count() const {
|
||||
int Mesh::get_blend_shape_count() const {
|
||||
|
||||
return morph_targets.size();
|
||||
return blend_shapes.size();
|
||||
}
|
||||
StringName Mesh::get_morph_target_name(int p_index) const {
|
||||
ERR_FAIL_INDEX_V( p_index, morph_targets.size(),StringName() );
|
||||
return morph_targets[p_index];
|
||||
StringName Mesh::get_blend_shape_name(int p_index) const {
|
||||
ERR_FAIL_INDEX_V( p_index, blend_shapes.size(),StringName() );
|
||||
return blend_shapes[p_index];
|
||||
}
|
||||
void Mesh::clear_morph_targets() {
|
||||
void Mesh::clear_blend_shapes() {
|
||||
|
||||
if (surfaces.size()) {
|
||||
ERR_EXPLAIN("Can't set shape key count if surfaces are already created.");
|
||||
ERR_FAIL_COND(surfaces.size());
|
||||
}
|
||||
|
||||
morph_targets.clear();
|
||||
blend_shapes.clear();
|
||||
}
|
||||
|
||||
void Mesh::set_morph_target_mode(MorphTargetMode p_mode) {
|
||||
void Mesh::set_blend_shape_mode(BlendShapeMode p_mode) {
|
||||
|
||||
morph_target_mode=p_mode;
|
||||
VS::get_singleton()->mesh_set_morph_target_mode(mesh,(VS::MorphTargetMode)p_mode);
|
||||
blend_shape_mode=p_mode;
|
||||
VS::get_singleton()->mesh_set_blend_shape_mode(mesh,(VS::BlendShapeMode)p_mode);
|
||||
}
|
||||
|
||||
Mesh::MorphTargetMode Mesh::get_morph_target_mode() const {
|
||||
Mesh::BlendShapeMode Mesh::get_blend_shape_mode() const {
|
||||
|
||||
return morph_target_mode;
|
||||
return blend_shape_mode;
|
||||
}
|
||||
|
||||
|
||||
@ -1019,12 +1019,12 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
|
||||
|
||||
void Mesh::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(_MD("add_morph_target","name"),&Mesh::add_morph_target);
|
||||
ClassDB::bind_method(_MD("get_morph_target_count"),&Mesh::get_morph_target_count);
|
||||
ClassDB::bind_method(_MD("get_morph_target_name","index"),&Mesh::get_morph_target_name);
|
||||
ClassDB::bind_method(_MD("clear_morph_targets"),&Mesh::clear_morph_targets);
|
||||
ClassDB::bind_method(_MD("set_morph_target_mode","mode"),&Mesh::set_morph_target_mode);
|
||||
ClassDB::bind_method(_MD("get_morph_target_mode"),&Mesh::get_morph_target_mode);
|
||||
ClassDB::bind_method(_MD("add_blend_shape","name"),&Mesh::add_blend_shape);
|
||||
ClassDB::bind_method(_MD("get_blend_shape_count"),&Mesh::get_blend_shape_count);
|
||||
ClassDB::bind_method(_MD("get_blend_shape_name","index"),&Mesh::get_blend_shape_name);
|
||||
ClassDB::bind_method(_MD("clear_blend_shapes"),&Mesh::clear_blend_shapes);
|
||||
ClassDB::bind_method(_MD("set_blend_shape_mode","mode"),&Mesh::set_blend_shape_mode);
|
||||
ClassDB::bind_method(_MD("get_blend_shape_mode"),&Mesh::get_blend_shape_mode);
|
||||
|
||||
ClassDB::bind_method(_MD("add_surface_from_arrays","primitive","arrays","blend_shapes","compress_flags"),&Mesh::add_surface_from_arrays,DEFVAL(Array()),DEFVAL(ARRAY_COMPRESS_DEFAULT));
|
||||
ClassDB::bind_method(_MD("get_surface_count"),&Mesh::get_surface_count);
|
||||
@ -1084,7 +1084,7 @@ void Mesh::_bind_methods() {
|
||||
Mesh::Mesh() {
|
||||
|
||||
mesh=VisualServer::get_singleton()->mesh_create();
|
||||
morph_target_mode=MORPH_MODE_RELATIVE;
|
||||
blend_shape_mode=BLEND_SHAPE_MODE_RELATIVE;
|
||||
|
||||
}
|
||||
|
||||
|
@ -105,10 +105,10 @@ public:
|
||||
PRIMITIVE_TRIANGLE_FAN=VisualServer::PRIMITIVE_TRIANGLE_FAN,
|
||||
};
|
||||
|
||||
enum MorphTargetMode {
|
||||
enum BlendShapeMode {
|
||||
|
||||
MORPH_MODE_NORMALIZED=VS::MORPH_MODE_NORMALIZED,
|
||||
MORPH_MODE_RELATIVE=VS::MORPH_MODE_RELATIVE,
|
||||
BLEND_SHAPE_MODE_NORMALIZED=VS::BLEND_SHAPE_MODE_NORMALIZED,
|
||||
BLEND_SHAPE_MODE_RELATIVE=VS::BLEND_SHAPE_MODE_RELATIVE,
|
||||
};
|
||||
|
||||
private:
|
||||
@ -120,8 +120,8 @@ private:
|
||||
Vector<Surface> surfaces;
|
||||
RID mesh;
|
||||
Rect3 aabb;
|
||||
MorphTargetMode morph_target_mode;
|
||||
Vector<StringName> morph_targets;
|
||||
BlendShapeMode blend_shape_mode;
|
||||
Vector<StringName> blend_shapes;
|
||||
Rect3 custom_aabb;
|
||||
|
||||
mutable Ref<TriangleMesh> triangle_mesh;
|
||||
@ -142,15 +142,15 @@ public:
|
||||
void add_surface(uint32_t p_format,PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<Rect3>& p_bone_aabbs=Vector<Rect3>());
|
||||
|
||||
Array surface_get_arrays(int p_surface) const;
|
||||
virtual Array surface_get_morph_arrays(int p_surface) const;
|
||||
virtual Array surface_get_blend_shape_arrays(int p_surface) const;
|
||||
|
||||
void add_morph_target(const StringName& p_name);
|
||||
int get_morph_target_count() const;
|
||||
StringName get_morph_target_name(int p_index) const;
|
||||
void clear_morph_targets();
|
||||
void add_blend_shape(const StringName& p_name);
|
||||
int get_blend_shape_count() const;
|
||||
StringName get_blend_shape_name(int p_index) const;
|
||||
void clear_blend_shapes();
|
||||
|
||||
void set_morph_target_mode(MorphTargetMode p_mode);
|
||||
MorphTargetMode get_morph_target_mode() const;
|
||||
void set_blend_shape_mode(BlendShapeMode p_mode);
|
||||
BlendShapeMode get_blend_shape_mode() const;
|
||||
|
||||
int get_surface_count() const;
|
||||
void surface_remove(int p_idx);
|
||||
@ -196,6 +196,6 @@ public:
|
||||
|
||||
VARIANT_ENUM_CAST( Mesh::ArrayType );
|
||||
VARIANT_ENUM_CAST( Mesh::PrimitiveType );
|
||||
VARIANT_ENUM_CAST( Mesh::MorphTargetMode );
|
||||
VARIANT_ENUM_CAST( Mesh::BlendShapeMode );
|
||||
|
||||
#endif
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
Vector<RID> reflection_probe_instances;
|
||||
Vector<RID> gi_probe_instances;
|
||||
|
||||
Vector<float> morph_values;
|
||||
Vector<float> blend_values;
|
||||
|
||||
//BakedLightData *baked_light;
|
||||
VS::ShadowCastingSetting cast_shadows;
|
||||
@ -244,12 +244,12 @@ public:
|
||||
|
||||
virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<Rect3>& p_bone_aabbs=Vector<Rect3>())=0;
|
||||
|
||||
virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount)=0;
|
||||
virtual int mesh_get_morph_target_count(RID p_mesh) const=0;
|
||||
virtual void mesh_set_blend_shape_count(RID p_mesh,int p_amount)=0;
|
||||
virtual int mesh_get_blend_shape_count(RID p_mesh) const=0;
|
||||
|
||||
|
||||
virtual void mesh_set_morph_target_mode(RID p_mesh,VS::MorphTargetMode p_mode)=0;
|
||||
virtual VS::MorphTargetMode mesh_get_morph_target_mode(RID p_mesh) const=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 void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material)=0;
|
||||
virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const=0;
|
||||
|
@ -673,12 +673,12 @@ public:
|
||||
|
||||
BIND10(mesh_add_surface,RID,uint32_t,PrimitiveType,const PoolVector<uint8_t>&,int ,const PoolVector<uint8_t>& ,int ,const Rect3&,const Vector<PoolVector<uint8_t> >&,const Vector<Rect3>& )
|
||||
|
||||
BIND2(mesh_set_morph_target_count,RID,int)
|
||||
BIND1RC(int,mesh_get_morph_target_count,RID)
|
||||
BIND2(mesh_set_blend_shape_count,RID,int)
|
||||
BIND1RC(int,mesh_get_blend_shape_count,RID)
|
||||
|
||||
|
||||
BIND2(mesh_set_morph_target_mode,RID,MorphTargetMode)
|
||||
BIND1RC(MorphTargetMode, mesh_get_morph_target_mode,RID )
|
||||
BIND2(mesh_set_blend_shape_mode,RID,BlendShapeMode)
|
||||
BIND1RC(BlendShapeMode, mesh_get_blend_shape_mode,RID )
|
||||
|
||||
BIND3(mesh_surface_set_material,RID, int , RID )
|
||||
BIND2RC(RID,mesh_surface_get_material,RID, int )
|
||||
@ -976,7 +976,7 @@ public:
|
||||
BIND2(instance_set_layer_mask,RID, uint32_t )
|
||||
BIND2(instance_set_transform,RID, const Transform& )
|
||||
BIND2(instance_attach_object_instance_ID,RID,ObjectID )
|
||||
BIND3(instance_set_morph_target_weight,RID,int , float )
|
||||
BIND3(instance_set_blend_shape_weight,RID,int , float )
|
||||
BIND3(instance_set_surface_material,RID,int , RID )
|
||||
BIND2(instance_set_visible,RID ,bool)
|
||||
|
||||
|
@ -470,7 +470,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base){
|
||||
instance->base_data=NULL;
|
||||
}
|
||||
|
||||
instance->morph_values.clear();
|
||||
instance->blend_values.clear();
|
||||
|
||||
for(int i=0;i<instance->materials.size();i++) {
|
||||
if (instance->materials[i].is_valid()) {
|
||||
@ -829,7 +829,7 @@ void VisualServerScene::instance_attach_object_instance_ID(RID p_instance,Object
|
||||
instance->object_ID=p_ID;
|
||||
|
||||
}
|
||||
void VisualServerScene::instance_set_morph_target_weight(RID p_instance,int p_shape, float p_weight){
|
||||
void VisualServerScene::instance_set_blend_shape_weight(RID p_instance,int p_shape, float p_weight){
|
||||
|
||||
Instance *instance = instance_owner.get( p_instance );
|
||||
ERR_FAIL_COND( !instance );
|
||||
@ -838,8 +838,8 @@ void VisualServerScene::instance_set_morph_target_weight(RID p_instance,int p_sh
|
||||
_update_dirty_instance(instance);
|
||||
}
|
||||
|
||||
ERR_FAIL_INDEX(p_shape,instance->morph_values.size());
|
||||
instance->morph_values[p_shape]=p_weight;
|
||||
ERR_FAIL_INDEX(p_shape,instance->blend_values.size());
|
||||
instance->blend_values[p_shape]=p_weight;
|
||||
}
|
||||
|
||||
void VisualServerScene::instance_set_surface_material(RID p_instance,int p_surface, RID p_material){
|
||||
@ -3409,11 +3409,11 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
|
||||
}
|
||||
p_instance->materials.resize(new_mat_count);
|
||||
|
||||
int new_morph_count = VSG::storage->mesh_get_morph_target_count(p_instance->base);
|
||||
if (new_morph_count!=p_instance->morph_values.size()) {
|
||||
p_instance->morph_values.resize(new_morph_count);
|
||||
for(int i=0;i<new_morph_count;i++) {
|
||||
p_instance->morph_values[i]=0;
|
||||
int new_blend_shape_count = VSG::storage->mesh_get_blend_shape_count(p_instance->base);
|
||||
if (new_blend_shape_count!=p_instance->blend_values.size()) {
|
||||
p_instance->blend_values.resize(new_blend_shape_count);
|
||||
for(int i=0;i<new_blend_shape_count;i++) {
|
||||
p_instance->blend_values[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ public:
|
||||
virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask);
|
||||
virtual void instance_set_transform(RID p_instance, const Transform& p_transform);
|
||||
virtual void instance_attach_object_instance_ID(RID p_instance,ObjectID p_ID);
|
||||
virtual void instance_set_morph_target_weight(RID p_instance,int p_shape, float p_weight);
|
||||
virtual void instance_set_blend_shape_weight(RID p_instance,int p_shape, float p_weight);
|
||||
virtual void instance_set_surface_material(RID p_instance,int p_surface, RID p_material);
|
||||
virtual void instance_set_visible(RID p_instance,bool p_visible);
|
||||
|
||||
|
@ -246,16 +246,16 @@ public:
|
||||
virtual void mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),uint32_t p_compress_format=ARRAY_COMPRESS_DEFAULT);
|
||||
virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<Rect3>& p_bone_aabbs=Vector<Rect3>())=0;
|
||||
|
||||
virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount)=0;
|
||||
virtual int mesh_get_morph_target_count(RID p_mesh) const=0;
|
||||
virtual void mesh_set_blend_shape_count(RID p_mesh,int p_amount)=0;
|
||||
virtual int mesh_get_blend_shape_count(RID p_mesh) const=0;
|
||||
|
||||
enum MorphTargetMode {
|
||||
MORPH_MODE_NORMALIZED,
|
||||
MORPH_MODE_RELATIVE,
|
||||
enum BlendShapeMode {
|
||||
BLEND_SHAPE_MODE_NORMALIZED,
|
||||
BLEND_SHAPE_MODE_RELATIVE,
|
||||
};
|
||||
|
||||
virtual void mesh_set_morph_target_mode(RID p_mesh,MorphTargetMode p_mode)=0;
|
||||
virtual MorphTargetMode mesh_get_morph_target_mode(RID p_mesh) const=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 void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material)=0;
|
||||
virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const=0;
|
||||
@ -714,7 +714,7 @@ public:
|
||||
virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask)=0;
|
||||
virtual void instance_set_transform(RID p_instance, const Transform& p_transform)=0;
|
||||
virtual void instance_attach_object_instance_ID(RID p_instance,ObjectID p_ID)=0;
|
||||
virtual void instance_set_morph_target_weight(RID p_instance,int p_shape, float p_weight)=0;
|
||||
virtual void instance_set_blend_shape_weight(RID p_instance,int p_shape, float p_weight)=0;
|
||||
virtual void instance_set_surface_material(RID p_instance,int p_surface, RID p_material)=0;
|
||||
virtual void instance_set_visible(RID p_instance,bool p_visible)=0;
|
||||
|
||||
|
@ -624,12 +624,12 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
|
||||
ERR_FAIL_COND_V( !collada.state.mesh_data_map.has(target), ERR_INVALID_DATA );
|
||||
String name = collada.state.mesh_data_map[target].name;
|
||||
|
||||
p_mesh->add_morph_target(name);
|
||||
p_mesh->add_blend_shape(name);
|
||||
}
|
||||
if (p_morph_data->mode=="RELATIVE")
|
||||
p_mesh->set_morph_target_mode(Mesh::MORPH_MODE_RELATIVE);
|
||||
p_mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_RELATIVE);
|
||||
else if (p_morph_data->mode=="NORMALIZED")
|
||||
p_mesh->set_morph_target_mode(Mesh::MORPH_MODE_NORMALIZED);
|
||||
p_mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user