martyj Posted October 2, 2016 Share Posted October 2, 2016 What is the best way to release an object loaded with Asset::Unmanaged? Using Object::Release() causes a crash in my game. Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 2, 2016 Share Posted October 2, 2016 Can you give more information? Example code showing the issue would help to see what is happening. All anyone can do is guess with so little information. example code in lua showing it working: window = Window:Create("example",0,0,800,600,513) context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:Move(0,0.5,-2) light = DirectionalLight:Create() light:SetRotation(35,35,0) drum1 = Model:Load("Models/barrel/barrel.mdl") drum2 = drum1:Copy() drum2:SetPosition(-1,0,0) drum3 = Model:Load("Models/barrel/barrel.mdl",Asset.Unmanaged) drum3:SetPosition(1,0,0) while window:KeyDown(Key.Escape)==false do if window:Closed() then break end if window:KeyHit(Key.D1) and drum1 then drum1:Release() drum1 = nil end if window:KeyHit(Key.D2) and drum2 then drum2:Release() drum2 = nil end if window:KeyHit(Key.D3) and drum3 then drum3:Release() drum3 = nil end Time:Update() world:Update() world:Render() context:Sync(true) end Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
martyj Posted October 2, 2016 Author Share Posted October 2, 2016 Here is the crash I receive: Creation: this->model = (Model*)Model::Load(item->GetModelPath(), Asset::Unmanaged); this->model->SetUserData(this); this->model->SetKeyValue("name", item->GetName()); this->model->SetVelocity(Vec3(0, 0, 0), true); this->model->SetCollisionType(Collision::Prop); this->model->SetPhysicsMode(Entity::RigidBodyPhysics); this->model->SetPickMode(Entity::SpherePick, true); this->model->SetMass(10); // TODO: real mass this->model->SetSweptCollisionMode(true); this->model->SetPosition(position, true); Destroy Code: ItemEntity::~ItemEntity() { this->model->SetParent(NULL); this->model->Hide(); // TODO: Delete me this->model->SetUserData(NULL); this->model->Release(); } I should mention, this doesn't happen on every map. Just the map of my demo. Quote 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.