Use a From implementation instead of manual conversion
If the contacts and intersects map ever change in the future to not be 1:1 with gaps but instead something else, this guarantees that this implicit use of the relationship will flag at a compiler level
This commit was merged in pull request #20.
This commit is contained in:
@@ -226,9 +226,9 @@ impl PhysicsModels{
|
||||
}
|
||||
fn get_model_transform(&self,model_id:ModelId)->Option<&PhysicsMeshTransform>{
|
||||
//ModelId can possibly be a decoration
|
||||
match self.contact_models.get(&ContactModelId::new(model_id.get())){
|
||||
match self.contact_models.get(&model_id.into()){
|
||||
Some(model)=>Some(&model.transform),
|
||||
None=>self.intersect_models.get(&IntersectModelId::new(model_id.get()))
|
||||
None=>self.intersect_models.get(&model_id.into())
|
||||
.map(|model|&model.transform),
|
||||
}
|
||||
}
|
||||
@@ -671,6 +671,11 @@ impl Into<ModelId> for ContactModelId{
|
||||
ModelId::new(self.get())
|
||||
}
|
||||
}
|
||||
impl From<ModelId> for ContactModelId{
|
||||
fn from(other: ModelId)->Self{
|
||||
Self::new(other.get())
|
||||
}
|
||||
}
|
||||
#[derive(Debug,Clone,Copy,Hash,id::Id,Eq,PartialEq)]
|
||||
struct IntersectModelId(u32);
|
||||
impl Into<ModelId> for IntersectModelId{
|
||||
@@ -678,6 +683,11 @@ impl Into<ModelId> for IntersectModelId{
|
||||
ModelId::new(self.get())
|
||||
}
|
||||
}
|
||||
impl From<ModelId> for IntersectModelId{
|
||||
fn from(other: ModelId)->Self{
|
||||
Self::new(other.get())
|
||||
}
|
||||
}
|
||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||
enum PhysicsModelId{
|
||||
Contact(ContactModelId),
|
||||
|
||||
Reference in New Issue
Block a user