small style changes
This commit is contained in:
parent
ce00dc2f5b
commit
c1d21415ba
35
src/lib.rs
35
src/lib.rs
|
@ -136,7 +136,7 @@ impl VmcMessage for VmcExtOk {
|
||||||
return OscMessage { addr, args };
|
return OscMessage { addr, args };
|
||||||
}
|
}
|
||||||
fn from_osc_message(msg: OscMessage) -> Result<Box<dyn VmcMessage>, FromMessageErr> {
|
fn from_osc_message(msg: OscMessage) -> Result<Box<dyn VmcMessage>, FromMessageErr> {
|
||||||
let mut result = VmcExtOk {
|
let mut result = Self {
|
||||||
loaded: -1,
|
loaded: -1,
|
||||||
calibration_state: None,
|
calibration_state: None,
|
||||||
calibration_mode: None,
|
calibration_mode: None,
|
||||||
|
@ -194,8 +194,7 @@ impl VmcMessage for VmcExtOk {
|
||||||
return Err(FromMessageErr::IntRange(FromIntRangeErr { expected_lower: 0, expected_upper: 1, actual: result.loaded, addr: msg.addr, arg_count: 3}));
|
return Err(FromMessageErr::IntRange(FromIntRangeErr { expected_lower: 0, expected_upper: 1, actual: result.loaded, addr: msg.addr, arg_count: 3}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let boxed_result = Box::new(result);
|
return Ok(Box::new(result));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
fn get_addr(&self) -> String {
|
fn get_addr(&self) -> String {
|
||||||
return String::from("/VMC/Ext/OK");
|
return String::from("/VMC/Ext/OK");
|
||||||
|
@ -239,8 +238,7 @@ impl VmcExtOk {
|
||||||
pub fn new_vmc_message(loaded: i32, calibration_state: Option<i32>, calibration_mode: Option<i32>, tracking_status: Option<i32>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
|
pub fn new_vmc_message(loaded: i32, calibration_state: Option<i32>, calibration_mode: Option<i32>, tracking_status: Option<i32>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
|
||||||
let msg = Self::new(loaded, calibration_state, calibration_mode, tracking_status);
|
let msg = Self::new(loaded, calibration_state, calibration_mode, tracking_status);
|
||||||
if msg.is_ok() {
|
if msg.is_ok() {
|
||||||
let boxed_result = Box::new(msg.ok().unwrap());
|
return Ok(Box::new(msg.ok().unwrap()));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
return Err(msg.err().unwrap());
|
return Err(msg.err().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -267,8 +265,7 @@ impl VmcMessage for VmcExtT {
|
||||||
OscType::Float(f) => time = f,
|
OscType::Float(f) => time = f,
|
||||||
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})),
|
||||||
}
|
}
|
||||||
let boxed_result = Box::new(VmcExtT{time});
|
return Ok(Box::new(Self{time}));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
fn get_addr(&self) -> String {
|
fn get_addr(&self) -> String {
|
||||||
return String::from("/VMC/Ext/T");
|
return String::from("/VMC/Ext/T");
|
||||||
|
@ -282,8 +279,7 @@ impl VmcExtT {
|
||||||
pub fn new_vmc_message(time: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
|
pub fn new_vmc_message(time: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
|
||||||
let msg = Self::new(time);
|
let msg = Self::new(time);
|
||||||
if msg.is_ok() {
|
if msg.is_ok() {
|
||||||
let boxed_result = Box::new(msg.ok().unwrap());
|
return Ok(Box::new(msg.ok().unwrap()));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
return Err(msg.err().unwrap());
|
return Err(msg.err().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -324,7 +320,7 @@ impl VmcMessage for VmcExtRootPos {
|
||||||
return OscMessage { addr, args };
|
return OscMessage { addr, args };
|
||||||
}
|
}
|
||||||
fn from_osc_message(msg: OscMessage) -> Result<Box<dyn VmcMessage>, FromMessageErr> {
|
fn from_osc_message(msg: OscMessage) -> Result<Box<dyn VmcMessage>, FromMessageErr> {
|
||||||
let mut result: VmcExtRootPos;
|
let mut result: Self;
|
||||||
if msg.args.len() == 8 || msg.args.len() == 14 {
|
if msg.args.len() == 8 || msg.args.len() == 14 {
|
||||||
let mut origin = Vector3::new(0.0, 0.0, 0.0);
|
let mut origin = Vector3::new(0.0, 0.0, 0.0);
|
||||||
let name: String;
|
let name: String;
|
||||||
|
@ -411,8 +407,7 @@ impl VmcMessage for VmcExtRootPos {
|
||||||
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[13].to_owned(), addr: msg.addr, arg_count: 13})),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[13].to_owned(), addr: msg.addr, arg_count: 13})),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let boxed_result = Box::new(result);
|
return Ok(Box::new(result));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
fn get_addr(&self) -> String {
|
fn get_addr(&self) -> String {
|
||||||
return String::from("/VMC/Ext/Root/Pos");
|
return String::from("/VMC/Ext/Root/Pos");
|
||||||
|
@ -432,8 +427,7 @@ impl VmcExtRootPos {
|
||||||
pub fn new_vmc_message(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
|
pub fn new_vmc_message(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
|
||||||
let message = Self::new(name, transform, mr_scale, mr_offset);
|
let message = Self::new(name, transform, mr_scale, mr_offset);
|
||||||
if message.is_ok() {
|
if message.is_ok() {
|
||||||
let boxed_result = Box::new(message.ok().unwrap());
|
return Ok(Box::new(message.ok().unwrap()));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
return Err(message.err().unwrap());
|
return Err(message.err().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -506,11 +500,10 @@ impl VmcMessage for VmcExtBonePos {
|
||||||
OscType::Float(f) => quat.w = f,
|
OscType::Float(f) => quat.w = f,
|
||||||
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[7].to_owned(), addr: msg.addr, arg_count: 7})),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[7].to_owned(), addr: msg.addr, arg_count: 7})),
|
||||||
}
|
}
|
||||||
let boxed_result = Box::new(VmcExtBonePos {
|
return Ok(Box::new(Self {
|
||||||
name,
|
name,
|
||||||
transform: Transform3D::new(Basis::from_quat(quat), origin),
|
transform: Transform3D::new(Basis::from_quat(quat), origin),
|
||||||
});
|
}));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
fn get_addr(&self) -> String {
|
fn get_addr(&self) -> String {
|
||||||
return String::from("/VMC/Ext/Bone/Pos");
|
return String::from("/VMC/Ext/Bone/Pos");
|
||||||
|
@ -524,8 +517,7 @@ impl VmcExtBonePos {
|
||||||
pub fn new_vmc_message(name: String, transform: Transform3D) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
|
pub fn new_vmc_message(name: String, transform: Transform3D) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
|
||||||
let message = Self::new(name, transform);
|
let message = Self::new(name, transform);
|
||||||
if message.is_ok() {
|
if message.is_ok() {
|
||||||
let boxed_result = Box::new(message.ok().unwrap());
|
return Ok(Box::new(message.ok().unwrap()));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
return Err(message.err().unwrap());
|
return Err(message.err().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -561,8 +553,7 @@ impl VmcMessage for VmcExtBlendVal {
|
||||||
OscType::Float(f) => value = f,
|
OscType::Float(f) => value = f,
|
||||||
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})),
|
||||||
}
|
}
|
||||||
let boxed_result = Box::new(VmcExtBlendVal { name, value });
|
return Ok(Box::new(Self { name, value }));
|
||||||
return Ok(boxed_result);
|
|
||||||
}
|
}
|
||||||
fn get_addr(&self) -> String {
|
fn get_addr(&self) -> String {
|
||||||
return String::from("/VMC/Ext/Blend/Val");
|
return String::from("/VMC/Ext/Blend/Val");
|
||||||
|
@ -765,7 +756,7 @@ impl VmcMessage for VmcExtCon {
|
||||||
OscType::Float(f) => axis.z = f,
|
OscType::Float(f) => axis.z = f,
|
||||||
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[6].to_owned(), addr: msg.addr, arg_count: 6})),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[6].to_owned(), addr: msg.addr, arg_count: 6})),
|
||||||
}
|
}
|
||||||
return Ok(Box::new(VmcExtCon {
|
return Ok(Box::new(Self {
|
||||||
active,
|
active,
|
||||||
name,
|
name,
|
||||||
is_left,
|
is_left,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user