void VsCone::ResizePhysicsGeometry()
{
	if(m_vxGeometry && m_vxCollisionGeometry && m_vxSensor)
	{
		if(!m_vxSensor->removeCollisionGeometry(m_vxCollisionGeometry))
			THROW_PARAM_ERROR(Vs_Err_lRemovingCollisionGeometry, Vs_Err_strRemovingCollisionGeometry, "ID: ", m_strID);

		delete m_vxCollisionGeometry;
		m_vxCollisionGeometry = NULL;

		CreatePhysicsGeometry();
		int iMaterialID = m_lpSim->GetMaterialID(MaterialID());
		CollisionGeometry(m_vxSensor->addGeometry(m_vxGeometry, iMaterialID, 0, m_lpThisRB->Density()));

        CalculateEstimatedMassAndVolume();
	}
}
Example #2
0
void SubMesh::set_material_id(MaterialID mat) {
    auto old_material = (material_) ? material_->id() : MaterialID();

    if(old_material == mat) {
        // Don't do anything, don't fire the changed signal
        return;
    }

    if(mat) {
        // Set the material, store the shared_ptr to increment the ref count
        material_ = parent_->resource_manager().material(mat);
        if(!material_) {
            throw std::runtime_error("Tried to set invalid material on submesh");
        }

        material_change_connection_ = material_->signal_material_pass_changed().connect(
            [=](MaterialID, MaterialPassChangeEvent evt) {
                /* FIXME: This is a hack! We want material_changed event to take some kind of event
                 * structure so we can signal different types of event changes. Here we are signaling that
                 * the material passes changed so the material itself changed - not that it we changed from
                 * one material to another. Still, we need to make sure that we trigger the signal so that the
                 * render queue updates. */
                signal_material_changed_(this, material_->id(), material_->id());
            }
        );
    } else {
        // Reset the material
        material_.reset();
    }

    signal_material_changed_(this, old_material, mat);
    parent_->signal_submesh_material_changed_(
        parent_->id(),
        this,
        old_material,
        mat
    );
}