...
 
Commits (2)
......@@ -5,7 +5,7 @@ def configure(env):
pass
def get_doc_classes():
#return [ "FutariParticles", "FutariWind" ]
#return [ "Softskin", "SoftskinProxy", "SoftskinMesh", "SoftskinGroupDot", "SoftskinGroupEdge", "SoftskinGroupFiber", "SoftskinGroupLigament" ]
return []
def get_doc_path():
......
......@@ -55,9 +55,19 @@
#include "softskin_io_mesh.h"
static Ref<ResourceFormatSaverSoftskinCache> softskin_cache_saver;
static ResourceFormatLoaderSoftskinCache *softskin_cache_loader = NULL;
static Ref<ResourceFormatLoaderSoftskinCache> softskin_cache_loader;
static Ref<ResourceFormatSaverSoftskinMesh> softskin_mesh_saver;
static ResourceFormatLoaderSoftskinMesh *softskin_mesh_loader = NULL;
static Ref<ResourceFormatLoaderSoftskinMesh> softskin_mesh_loader;
#ifdef TOOLS_ENABLED
static void _editor_init() {
// Ref<EditorSceneImporterAssimp> import_assimp;
// import_assimp.instance();
// ResourceImporterScene::get_singleton()->add_importer(import_assimp);
std::cout << "softskin >> _editor_init" << std::endl;
}
#endif
void register_softskin_types() {
......@@ -66,31 +76,54 @@ void register_softskin_types() {
ClassDB::register_class<SoftskinProxy>();
ClassDB::register_class<SoftskinDebug>();
ClassDB::register_class<Softskin>();
ClassDB::register_class<SoftskinGroupDot>();
ClassDB::register_class<SoftskinGroupFiber>();
ClassDB::register_class<SoftskinGroupLigament>();
softskin_cache_saver.instance();
ResourceSaver::add_resource_format_saver(softskin_cache_saver);
softskin_cache_loader = memnew(ResourceFormatLoaderSoftskinCache);
softskin_cache_loader.instance();
ResourceLoader::add_resource_format_loader(softskin_cache_loader);
softskin_mesh_saver.instance();
ResourceSaver::add_resource_format_saver(softskin_mesh_saver);
softskin_mesh_loader = memnew(ResourceFormatLoaderSoftskinMesh);
softskin_mesh_loader.instance();
ResourceLoader::add_resource_format_loader(softskin_mesh_loader);
#ifdef TOOLS_ENABLED
// ClassDB::APIType prev_api = ClassDB::get_current_api();
// ClassDB::set_current_api(ClassDB::API_EDITOR);
// ClassDB::register_class<EditorSceneImporterAssimp>();
// ClassDB::set_current_api(prev_api);
// EditorNode::add_init_callback(_editor_init);
#endif
// softskin_cache_saver.instance();
// ResourceSaver::add_resource_format_saver(softskin_cache_saver);
// softskin_cache_loader = memnew(ResourceFormatLoaderSoftskinCache);
// ResourceLoader::add_resource_format_loader(softskin_cache_loader);
// softskin_mesh_saver.instance();
// ResourceSaver::add_resource_format_saver(softskin_mesh_saver);
// softskin_mesh_loader = memnew(ResourceFormatLoaderSoftskinMesh);
// ResourceLoader::add_resource_format_loader(softskin_mesh_loader);
}
void unregister_softskin_types() {
ResourceSaver::remove_resource_format_saver(softskin_cache_saver);
// softskin_cache_saver.unref();
memdelete(softskin_cache_loader);
softskin_cache_saver.unref();
ResourceLoader::remove_resource_format_loader(softskin_cache_loader);
softskin_cache_loader.unref();
ResourceSaver::remove_resource_format_saver(softskin_mesh_saver);
// softskin_cache_saver.unref();
memdelete(softskin_mesh_loader);
softskin_mesh_saver.unref();
ResourceLoader::remove_resource_format_loader(softskin_mesh_loader);
softskin_mesh_loader.unref();
// ResourceSaver::remove_resource_format_saver(softskin_cache_saver);
// softskin_cache_saver.unref();
// memdelete(softskin_cache_loader);
// ResourceSaver::remove_resource_format_saver(softskin_mesh_saver);
// softskin_cache_saver.unref();
// memdelete(softskin_mesh_loader);
}
......@@ -115,7 +115,7 @@ void Softskin::update_internal(const float& delta_time) {
Color head(1.0, 0.0, 1.0);
Color tail(0.0, 1.0, 1.0);
_debug_ligaments->start();
for (int i = 0; i < _data.ligaments_num; ++i) {
for (uint32_t i = 0; i < _data.ligaments_num; ++i) {
SoftskinLigament& sl = _data.ligaments[i];
_debug_ligaments->push(
sl.get_head()->anchor().ref(),
......@@ -129,7 +129,7 @@ void Softskin::update_internal(const float& delta_time) {
Color head(1.0, 0.0, 1.0);
Color tail(0.0, 1.0, 1.0);
_debug_normals->start();
for (int i = 0; i < _data.normals_num; ++i) {
for (uint32_t i = 0; i < _data.normals_num; ++i) {
Vector3 n = _data.normals[i].get_normal() * _normal_length;
for (int f = 0, fnum = _data.normals[i].get_face_size(); f < fnum; ++f) {
Vector3 v = _data.normals[i].dot(f)->vert().ref();
......@@ -141,7 +141,7 @@ void Softskin::update_internal(const float& delta_time) {
if (_debug_egdes != 0) {
_debug_egdes->start();
for (int i = 0; i < _data.fibers_num; ++i) {
for (uint32_t i = 0; i < _data.fibers_num; ++i) {
SoftskinFiber& sf = _data.fibers[i];
_debug_egdes->push(sf.get_head()->vert().ref(), sf.get_tail()->vert().ref());
}
......@@ -159,12 +159,12 @@ void Softskin::commit_changes() {
return;
}
for (int i = 0; i < _data.geom_buffer_num; ++i) {
for (uint32_t i = 0; i < _data.geom_buffer_num; ++i) {
copymem(&_write_buffer[i * _data.stride + _data.offset_vertices], _data.vert_buffer[i], sizeof (float) * 3);
}
if (_data.surface_format & VS::ARRAY_COMPRESS_NORMAL) {
for (int i = 0; i < _data.geom_buffer_num; ++i) {
for (uint32_t i = 0; i < _data.geom_buffer_num; ++i) {
int8_t vector[4] = {
(int8_t) CLAMP(_data.norm_buffer[i][0] * 127, -128, 127),
(int8_t) CLAMP(_data.norm_buffer[i][1] * 127, -128, 127),
......@@ -174,7 +174,7 @@ void Softskin::commit_changes() {
copymem(&_write_buffer[i * _data.stride + _data.offset_normal], vector, 4);
}
} else {
for (int i = 0; i < _data.geom_buffer_num; ++i) {
for (uint32_t i = 0; i < _data.geom_buffer_num; ++i) {
copymem(&_write_buffer[i * _data.stride + _data.offset_normal], _data.norm_buffer[i], sizeof (float) * 3);
}
}
......@@ -206,13 +206,13 @@ void Softskin::generate_default_groups() {
if (_data.groups_num > 0) {
_data.groups = memnew_arr(SoftskinGroup*, _data.groups_num);
}
for (int i = 0; i < _data.groups_num; ++i) {
for (uint32_t i = 0; i < _data.groups_num; ++i) {
switch (i) {
case ID_GROUP_ALL_FIBERS:
{
SoftskinGroupFiber* sgf = new SoftskinGroupFiber();
sgf->set_name(NAME_GROUP_ALL_FIBERS);
for (int f = 0; f < _data.fibers_num; ++f) {
for (uint32_t f = 0; f < _data.fibers_num; ++f) {
if (!_data.fibers[f].get_muscle()) {
sgf->push_back(&_data.fibers[f]);
}
......@@ -225,7 +225,7 @@ void Softskin::generate_default_groups() {
{
SoftskinGroupLigament* sgl = new SoftskinGroupLigament();
sgl->set_name(NAME_GROUP_ALL_LIGAMENTS);
for (int l = 0; l < _data.ligaments_num; ++l) {
for (uint32_t l = 0; l < _data.ligaments_num; ++l) {
if (!_data.ligaments[l].get_muscle()) {
sgl->push_back(&_data.ligaments[l]);
}
......@@ -238,7 +238,7 @@ void Softskin::generate_default_groups() {
{
SoftskinGroupDot* sgd = new SoftskinGroupDot();
sgd->set_name(NAME_GROUP_ALL_DOTS);
for (int d = 0; d < _data.verts_num; ++d) {
for (uint32_t d = 0; d < _data.verts_num; ++d) {
sgd->push_back(&_data.dots[d]);
}
sgd->pack();
......@@ -289,7 +289,7 @@ void Softskin::generate_skinmesh() {
if (_data.dots_num > 0) {
_data.dots = memnew_arr(SoftskinDot, _data.dots_num);
}
for (int i = 0; i < _data.verts_num; ++i) {
for (uint32_t i = 0; i < _data.verts_num; ++i) {
_data.verts[i] = _unique_vertices[i].xyz;
_data.dots[i].init(&_data.verts[i], &_data.forces[i]);
}
......@@ -305,7 +305,7 @@ void Softskin::generate_skinmesh() {
if (_data.fibers_num > 0) {
_data.fibers = memnew_arr(SoftskinFiber, _data.fibers_num);
}
for (int i = 0; i < _data.fibers_num; ++i) {
for (uint32_t i = 0; i < _data.fibers_num; ++i) {
edge_ref& er = _unique_edges[i];
_data.fibers[i].init(&_data.dots[er.v3_ref_0], &_data.dots[er.v3_ref_1]);
}
......@@ -318,12 +318,12 @@ void Softskin::generate_skinmesh() {
}
// linking stuff : DOTS > VERTICES
for (int i = 0; i < _data.geom_buffer_num; ++i) {
for (uint32_t i = 0; i < _data.geom_buffer_num; ++i) {
_data.vert_buffer[i] = _data.verts[_all2unique[i]].coord;
}
// linking stuff : SOFTSKIN NORMALS > DOTS & NORMAL BUFFER
for (int i = 0; i < _data.normals_num; ++i) {
for (uint32_t i = 0; i < _data.normals_num; ++i) {
normal_ref& nr = _unique_normals[i];
if (nr.dot_id == -1) {
......@@ -579,7 +579,7 @@ void Softskin::set_generate_ligaments(const bool& b) {
_data.anchors = memnew_arr(SkinAnchor, _data.verts_num);
}
// generation of anchors
for (int i = 0; i < _data.verts_num; ++i) {
for (uint32_t i = 0; i < _data.verts_num; ++i) {
_data.anchors[i].init(_data.dots[i].origin(), this);
}
// generation of ligaments
......@@ -587,7 +587,7 @@ void Softskin::set_generate_ligaments(const bool& b) {
if (_data.verts_num > 0) {
_data.ligaments = memnew_arr(SoftskinLigament, _data.verts_num);
}
for (int i = 0; i < _data.verts_num; ++i) {
for (uint32_t i = 0; i < _data.verts_num; ++i) {
_data.ligaments[i].init(&_data.anchors[i], &_data.dots[i]);
if (_data.groups_num >= ID_GROUP_ALL_LIGAMENTS) {
((SoftskinGroupLigament*) _data.groups[ID_GROUP_ALL_LIGAMENTS])->push_back(&_data.ligaments[i]);
......@@ -732,7 +732,7 @@ SoftskinGroupLigament* Softskin::get_ligaments(const String& name) {
Vector<String> Softskin::get_group_names(const softskin_type_t& t) {
Vector<String> l;
for (int i = 0; i < _data.groups_num; ++i) {
for (uint32_t i = 0; i < _data.groups_num; ++i) {
if (_data.groups[i]->get_type() == t) {
l.push_back( _data.groups[i]->get_name() );
}
......@@ -781,7 +781,7 @@ Vector3 Softskin::get_local_barycenter(const String& name) {
SoftskinGroup* Softskin::get_group(const String& name, const softskin_type_t& t) const {
SoftskinGroup* sg = 0;
for (int i = 0; i < _data.groups_num; ++i) {
for (uint32_t i = 0; i < _data.groups_num; ++i) {
if (
_data.groups[i]->get_name() == name &&
(
......@@ -1049,7 +1049,7 @@ bool Softskin::_get(const StringName &p_path, Variant &r_ret) const {
void Softskin::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < _data.groups_num; ++i) {
for (uint32_t i = 0; i < _data.groups_num; ++i) {
SoftskinGroup* sg = _data.groups[i];
......
......@@ -22,7 +22,6 @@
class Softskin : public VisualInstance {
GDCLASS(Softskin, VisualInstance);
OBJ_CATEGORY("3D Skin");
public:
......
......@@ -12,6 +12,7 @@
*/
#include "softskin_cache.h"
#include "thirdparty/bullet/LinearMath/btAlignedAllocator.h"
SoftskinCache::SoftskinCache() {
purge();
......@@ -189,7 +190,7 @@ bool SoftskinCache::compare(const SoftskinCache* src) {
return false;
}
for (int i = 0, imax = _surfaces.size(); i < imax; ++i) {
for (size_t i = 0, imax = _surfaces.size(); i < imax; ++i) {
MeshArray* foreign_ma = src->_surfaces[i];
if (!SkinResource::compare(_surfaces[i]->verts, foreign_ma->verts)) {
return false;
......@@ -222,7 +223,7 @@ void SoftskinCache::dump() {
std::cout << "SkinCache dump ********************** " << std::endl;
std::cout << "\tsurfaces: " << _surfaces.size() << std::endl;
for (int i = 0; i < _surfaces.size(); ++i) {
for (size_t i = 0; i < _surfaces.size(); ++i) {
std::cout << "\t\t**" << i << " ***" << std::endl;
std::cout << "\t\t" << "surface_format: " << _surfaces[i]->surface_format << std::endl;
std::cout << "\t\t" << "primitive_type: " << _surfaces[i]->primitive_type << std::endl;
......
......@@ -133,13 +133,13 @@ void SoftskinData::purge_anchors() {
void SoftskinData::purge_ligaments() {
if (groups) {
for (int g = 0; g < groups_num; ++g) {
for (uint32_t g = 0; g < groups_num; ++g) {
const softskin_type_t& t = groups[g]->get_type();
switch (t) {
case sf_EDGE:
{
SoftskinGroupEdge* sge = (SoftskinGroupEdge*) groups[g];
for (int i = 0; i < ligaments_num; ++i) {
for (uint32_t i = 0; i < ligaments_num; ++i) {
sge->erase(&ligaments[i]);
}
}
......@@ -148,7 +148,7 @@ void SoftskinData::purge_ligaments() {
case sf_MUSCLE:
{
SoftskinGroupLigament* sgl = (SoftskinGroupLigament*) groups[g];
for (int i = 0; i < ligaments_num; ++i) {
for (uint32_t i = 0; i < ligaments_num; ++i) {
sgl->erase(&ligaments[i]);
}
}
......@@ -188,7 +188,7 @@ void SoftskinData::purge() {
memdelete_arr(normals);
}
if (groups) {
for (int i = 0; i < groups_num; ++i) {
for (uint32_t i = 0; i < groups_num; ++i) {
delete groups[i];
}
memdelete_arr(groups);
......
......@@ -58,7 +58,7 @@ float SoftskinGroupDot::get_damping() const {
void SoftskinGroupDot::set_damping(const float& f) {
_damping = f;
for (int i = 0; i < _data_num; ++i) {
for (uint32_t i = 0; i < _data_num; ++i) {
_data[i]->set_damping(f * _weights[i]);
}
}
......@@ -69,7 +69,7 @@ float SoftskinGroupDot::get_pressure() const {
void SoftskinGroupDot::set_pressure(const float& f) {
_pressure = f;
for (int i = 0; i < _data_num; ++i) {
for (uint32_t i = 0; i < _data_num; ++i) {
_data[i]->set_pressure(f * _weights[i]);
}
}
......@@ -99,7 +99,7 @@ Vector3 SoftskinGroupEdge::get_barycenter() {
}
Vector3 out;
int div = 0;
for (int i = 0; i < _data_num; ++i) {
for (uint32_t i = 0; i < _data_num; ++i) {
SoftskinEdge* se = _data[i];
switch (se->get_type()) {
case sf_FIBER:
......@@ -184,7 +184,7 @@ Vector3 SoftskinGroupFiber::get_barycenter() {
return Vector3(0, 0, 0);
}
Vector3 out;
for (int i = 0; i < _data_num; ++i) {
for (uint32_t i = 0; i < _data_num; ++i) {
out += _data[i]->get_middle();
}
return out / _data_num;
......
......@@ -194,7 +194,7 @@ public:
void set_stiffness(float f) {
_stiffness = f;
for (int i = 0; i < SoftskinGList<T>::_data_num; ++i) {
for (uint32_t i = 0; i < SoftskinGList<T>::_data_num; ++i) {
SoftskinGList<T>::_data[i]->set_stiffness(f * SoftskinGList<T>::_weights[i]);
}
}
......@@ -205,7 +205,7 @@ public:
void set_rest_len_multiplier(float f) {
_rest_len_multiplier = f;
for (int i = 0; i < SoftskinGList<T>::_data_num; ++i) {
for (uint32_t i = 0; i < SoftskinGList<T>::_data_num; ++i) {
SoftskinGList<T>::_data[i]->set_rest_len_multiplier(f * SoftskinGList<T>::_weights[i]);
}
}
......@@ -216,7 +216,7 @@ public:
void set_muscle_frequency(float f) {
_muscle_frequency = f;
for (int i = 0; i < SoftskinGList<T>::_data_num; ++i) {
for (uint32_t i = 0; i < SoftskinGList<T>::_data_num; ++i) {
SoftskinGList<T>::_data[i]->set_muscle_frequency(f);
}
}
......@@ -227,7 +227,7 @@ public:
void set_muscle_min(float f) {
_muscle_min = f;
for (int i = 0; i < SoftskinGList<T>::_data_num; ++i) {
for (uint32_t i = 0; i < SoftskinGList<T>::_data_num; ++i) {
SoftskinGList<T>::_data[i]->set_muscle_min(f);
}
}
......@@ -238,7 +238,7 @@ public:
void set_muscle_max(float f) {
_muscle_max = f;
for (int i = 0; i < SoftskinGList<T>::_data_num; ++i) {
for (uint32_t i = 0; i < SoftskinGList<T>::_data_num; ++i) {
SoftskinGList<T>::_list[i]->set_muscle_max(f);
}
}
......
......@@ -24,7 +24,6 @@
class SoftskinProxy : public Resource {
GDCLASS(SoftskinProxy, Resource);
OBJ_CATEGORY("Skin");
public:
......