Brutile Posted May 20, 2014 Share Posted May 20, 2014 I've been having all sorts of problems with procedurally generated mesh not being updated. I found the cause, but don't know how to fix it. Basically, I want to update a model and replace the existing surface with a new one, but there is no remove surface command. I've tried Surface->Clear() and I've tried Surface->Release() then created a new surface, but it doesn't get rid of the surface, I'm still left with the surface I can't remove. I could just make a whole new model, but it seems logical to be able to remove a surface and create a new one in its place. Quote Link to comment Share on other sites More sharing options...
Joshua Posted May 22, 2014 Share Posted May 22, 2014 Could you please share the code you use to create the new surface and add it to the model? There are some possibilities I can think of for the cause of your problem but without seeing this section of the source I would just be speaking without any real direction. I have been working with models and custom surfaces and may be able to help. Quote Link to comment Share on other sites More sharing options...
Brutile Posted May 22, 2014 Author Share Posted May 22, 2014 void Build() { if (model == NULL) { model = Model::Create(); model->Move(xPosition, 0, zPosition); surface = model->AddSurface(); surface->SetMaterial(material); } else { surface->Clear(); } CreateSurface(); // adds verts and tris to the surface model->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB | Entity::RecursiveAABB); } That's the basic logic of it. The model starts off NULL, then it is created. Then when it is rebuilt, it should clear the surface, then start adding verts and tris to it. Quote Link to comment Share on other sites More sharing options...
shadmar Posted May 22, 2014 Share Posted May 22, 2014 You can't (that I know of..), you have to Release() the entire model/entity Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
klepto2 Posted May 22, 2014 Share Posted May 22, 2014 As you're using c++ you should have access to the lower members of the model. There should be a vector (or smth. like that) containing the surfaces. In theory you should remove them from there and then a call of model->Update should do the rest. I can't tell you the correct member in the model class, as i have no access to the headers at work, but i would suggest to look into the headers yourself. I found a lot of knowledge about the engine-internals just by studying the headers. 1 Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
shadmar Posted May 22, 2014 Share Posted May 22, 2014 The only thing keeping that surface in memory is a reference count and a link in the model surface list. Since the surface has no knowledge of models it's attached to, it should be safe to call model->surfaces.remove(surface) and then surface->Release(). Just don't do it in a rendering callback http://www.leadwerks.com/werkspace/statuses/id/6741/ 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Josh Posted May 22, 2014 Share Posted May 22, 2014 Keep in mind this is not the way it's supposed to work, and it is possible a hack like this could stop working in the future. Models can't remove surfaces. It's just not supported. You can clear a surface and start adding geometry back into it. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.