Jump to content

Remove surface from model


Brutile
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

  • Upvote 1
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

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/

  • Upvote 1

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

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.

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...