added logger, added hrtf

This commit is contained in:
Dmitry
2019-12-23 20:45:05 +03:00
parent 34c3ab281b
commit b4a9de57dd
19 changed files with 315 additions and 153 deletions
+57 -27
View File
@@ -6,11 +6,23 @@
<component name="ChangeListManager">
<list default="true" id="1932b2c4-d6ff-413c-9558-19959667326b" name="Default Changelist" comment="scene graph">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/animation/machine.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/animation/machine.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/animation/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/animation/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/engine/resource_manager.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/engine/resource_manager.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/gui/draw.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/gui/draw.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/renderer/gpu_program.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/renderer/gpu_program.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/renderer/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/renderer/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/resource/fbx/geometry.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/resource/fbx/geometry.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/resource/fbx/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/resource/fbx/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/resource/model.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/resource/model.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/resource/texture.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/resource/texture.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/resource/ttf.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/resource/ttf.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scene/graph.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/scene/graph.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scene/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/scene/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/scene/transform.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/scene/transform.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/utils/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/mod.rs" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -37,6 +49,11 @@
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
@@ -51,19 +68,7 @@
<property name="settings.editor.selected.configurable" value="editor.preferences.fonts.default" />
<property name="settings.editor.splitter.proportion" value="0.23435949" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Cargo Command.Clippy">
<component name="RunManager" selected="Cargo Command.Release">
<configuration name="Clippy" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="DEFAULT" />
<option name="command" value="clippy" />
@@ -129,24 +134,23 @@
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="Cargo Command.Clippy" />
<item itemvalue="Cargo Command.Release" />
<item itemvalue="Cargo Command.Test" />
<item itemvalue="Cargo Command.Debug" />
<item itemvalue="Cargo Command.Run window" />
</list>
<recent_temporary>
<list>
<item itemvalue="Cargo Command.Run window" />
<item itemvalue="Cargo Command.Debug" />
</list>
</recent_temporary>
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
<option name="version" value="2" />
</component>
<component name="ServiceViewManager">
<option name="viewStates">
<list>
<serviceView>
<treeState>
<expand />
<select />
</treeState>
</serviceView>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
@@ -201,6 +205,32 @@
<MESSAGE value="scene graph" />
<option name="LAST_COMMIT_MESSAGE" value="scene graph" />
</component>
<component name="WindowStateProjectService">
<state x="872" y="357" key="#Plugins" timestamp="1575656762221">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="872" y="357" key="#Plugins/[email protected]" timestamp="1575656762221" />
<state width="1220" height="280" key="GridCell.Tab.0.bottom" timestamp="1575661833621">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state width="1220" height="280" key="GridCell.Tab.0.bottom/[email protected]" timestamp="1575661833621" />
<state width="1220" height="280" key="GridCell.Tab.0.center" timestamp="1575661833621">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state width="1220" height="280" key="GridCell.Tab.0.center/[email protected]" timestamp="1575661833621" />
<state width="1220" height="280" key="GridCell.Tab.0.left" timestamp="1575661833621">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state width="1220" height="280" key="GridCell.Tab.0.left/[email protected]" timestamp="1575661833621" />
<state width="1220" height="280" key="GridCell.Tab.0.right" timestamp="1575661833621">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state width="1220" height="280" key="GridCell.Tab.0.right/[email protected]" timestamp="1575661833621" />
<state x="975" y="522" key="com.intellij.ide.util.TipDialog" timestamp="1575656772147">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="975" y="522" key="com.intellij.ide.util.TipDialog/[email protected]" timestamp="1575656772147" />
</component>
<component name="antWorkspaceConfiguration">
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
<option name="FILTER_TARGETS" value="false" />
Generated
+56 -11
View File
@@ -37,7 +37,7 @@ name = "approx"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -48,6 +48,11 @@ dependencies = [
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "autocfg"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "base64"
version = "0.10.1"
@@ -386,7 +391,7 @@ dependencies = [
"lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"tiff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -487,7 +492,7 @@ name = "line_drawing"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -599,6 +604,15 @@ name = "nodrop"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "num-complex"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-derive"
version = "0.2.4"
@@ -614,7 +628,7 @@ name = "num-integer"
version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -623,7 +637,7 @@ version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -632,13 +646,16 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-traits"
version = "0.2.6"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num_cpus"
@@ -661,7 +678,7 @@ name = "ordered-float"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -811,7 +828,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rg3d"
version = "0.5.0"
version = "0.5.1"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.22.0-alpha5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -849,6 +866,7 @@ dependencies = [
"alsa-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rg3d-core 0.2.2",
"rustfft 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -860,6 +878,18 @@ dependencies = [
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustfft"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"strength_reduce 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"transpose 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rusttype"
version = "0.7.5"
@@ -968,6 +998,11 @@ dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "strength_reduce"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
version = "0.15.29"
@@ -986,9 +1021,14 @@ dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-derive 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "transpose"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.1.0"
@@ -1177,6 +1217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"
"checksum approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"
"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71"
"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
@@ -1242,11 +1283,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb0cf31fb3ff77e6d2a6ebd6800df7fdcd106f2ad89113c9130bcd07f93dffc"
"checksum num-derive 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d9fe8fcafd1b86a37ce8a1cfa15ae504817e0c8c2e7ad42767371461ac1d316d"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
"checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
"checksum num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e96f040177bb3da242b5b1ecf3f54b5d5af3efbbfb18608977a5d2767b22f10"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
"checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4"
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
"checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d"
"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518"
@@ -1268,6 +1310,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356"
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rustfft 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c86a9dc178e87c7933f6e79bb93fa26c27548d551ab022b7f24ee2117aa4cb3"
"checksum rusttype 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ce3926a2057b315b3e8bca6d1cec1e97f19436a8f9127621cd538cda9c96a38b"
"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997"
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
@@ -1283,8 +1326,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum stackvector 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1c4725650978235083241fab0fdc8e694c3de37821524e7534a1a9061d1068af"
"checksum static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3"
"checksum stb_truetype 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "69b7df505db8e81d54ff8be4693421e5b543e08214bd8d99eb761fcb4d5668ba"
"checksum strength_reduce 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "965b1bd4ba2fafdbfe9e0e5432b758e4fdbc8c705e6d436a4a5927207de8e96e"
"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2"
"checksum tiff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b7c2cfc4742bd8a32f2e614339dd8ce30dbcf676bb262bd63a2327bc5df57d"
"checksum transpose 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "643e21580bb0627c7bb09e5cedbb42c8705b19d012de593ed6b0309270b3cd1e"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "rg3d"
version = "0.5.1"
version = "0.5.2"
authors = ["Dmitry Stepanov <[email protected]>"]
edition = "2018"
license = "MIT"
+13 -18
View File
@@ -106,7 +106,7 @@ use std::{
VecDeque,
},
};
use crate::animation::machine::PoseNode::BlendAnimations;
use crate::utils::log::Log;
pub enum Event {
StateEnter(Handle<State>),
@@ -139,6 +139,7 @@ impl Visit for PlayAnimation {
}
}
#[derive(Copy, Clone)]
pub enum Parameter {
Weight(f32),
Rule(bool),
@@ -528,7 +529,7 @@ impl Default for LimitedEventQueue {
impl LimitedEventQueue {
fn new(limit: u32) -> Self {
Self {
queue: Default::default(),
queue: VecDeque::with_capacity(limit as usize),
limit
}
}
@@ -563,14 +564,11 @@ impl Machine {
self.nodes.spawn(node)
}
pub fn add_parameter(&mut self, id: &str, parameter: Parameter) {
self.parameters.insert(id.to_owned(), parameter);
}
pub fn set_parameter(&mut self, id: &str, parameter: Parameter) {
if let Some(param) = self.parameters.get_mut(id) {
*param = parameter;
}
pub fn set_parameter(&mut self, id: &str, parameter: Parameter) -> &mut Self {
self.parameters.entry(id.to_owned())
.and_modify(|p| *p = parameter)
.or_insert(parameter);
self
}
pub fn set_entry_state(&mut self, entry_state: Handle<State>) {
@@ -589,18 +587,15 @@ impl Machine {
state
}
pub fn add_transition(&mut self, transition: Transition) {
pub fn add_transition(&mut self, transition: Transition) -> &mut Self {
let _ = self.transitions.spawn(transition);
self
}
pub fn get_state(&self, state: Handle<State>) -> &State {
self.states.borrow(state)
}
pub fn get_transition(&self, transition: Handle<Transition>) -> &Transition {
self.transitions.borrow(transition)
}
pub fn pop_event(&mut self) -> Option<Event> {
self.events.pop()
}
@@ -625,12 +620,12 @@ impl Machine {
if *active {
self.events.push(Event::StateLeave(self.active_state));
if self.debug {
println!("Leaving state: {}", self.states.borrow(self.active_state).name);
Log::writeln(format!("Leaving state: {}", self.states.borrow(self.active_state).name));
}
self.events.push(Event::StateEnter(transition.source));
if self.debug {
println!("Entering state: {}", self.states.borrow(transition.source).name);
Log::writeln(format!("Entering state: {}", self.states.borrow(transition.source).name));
}
self.active_state = Handle::NONE;
@@ -660,7 +655,7 @@ impl Machine {
self.events.push(Event::ActiveStateChanged(self.active_state));
if self.debug {
println!("Active state changed: {}", self.states.borrow(self.active_state).name);
Log::writeln(format!("Active state changed: {}", self.states.borrow(self.active_state).name));
}
}
} else {
+28 -8
View File
@@ -34,6 +34,7 @@ use std::{
sync::{Mutex, Arc},
collections::HashMap,
};
use crate::utils::log::Log;
#[derive(Copy, Clone)]
pub struct KeyFrame {
@@ -314,7 +315,7 @@ impl AnimationPose {
pub fn apply(&self, graph: &mut Graph) {
for (node, local_pose) in self.local_poses.iter() {
if node.is_none() {
println!("Invalid node handle found for animation pose, most likely it means that animation retargetting failed!");
Log::writeln("Invalid node handle found for animation pose, most likely it means that animation retargetting failed!".to_owned());
} else {
let local_transform = graph.get_mut(*node).base_mut().get_local_transform_mut();
local_transform.set_position(local_pose.position);
@@ -355,12 +356,17 @@ impl Animation {
&self.tracks
}
pub fn set_time_position(&mut self, time: f32) {
pub fn set_time_position(&mut self, time: f32) -> &mut Self {
if self.looped {
self.time_position = wrapf(time, 0.0, self.length);
} else {
self.time_position = clampf(time, 0.0, self.length);
}
self
}
pub fn rewind(&mut self) -> &mut Self {
self.set_time_position(0.0)
}
pub fn get_time_position(&self) -> f32 {
@@ -371,16 +377,31 @@ impl Animation {
self.speed
}
pub fn set_enabled(&mut self, enabled: bool) {
pub fn set_loop(&mut self, state: bool) -> &mut Self {
self.looped = state;
self
}
pub fn is_loop(&self) -> bool {
self.looped
}
pub fn has_ended(&self) -> bool {
!self.looped && self.time_position == self.length
}
pub fn set_enabled(&mut self, enabled: bool) -> &mut Self {
self.enabled = enabled;
self
}
pub fn is_enabled(&self) -> bool {
self.enabled
}
pub fn set_speed(&mut self, speed: f32) {
pub fn set_speed(&mut self, speed: f32) -> &mut Self {
self.speed = speed;
self
}
pub fn get_tracks_mut(&mut self) -> &mut [Track] {
@@ -457,7 +478,7 @@ impl Animation {
}
}
if !found {
println!("Failed to copy key frames for node {}!", track_node.get_name());
Log::write(format!("Failed to copy key frames for node {}!", track_node.get_name()));
}
}
}
@@ -511,7 +532,6 @@ impl Visit for Animation {
}
}
pub struct AnimationContainer {
pool: Pool<Animation>
}
@@ -582,11 +602,11 @@ impl AnimationContainer {
}
pub fn resolve(&mut self, graph: &Graph) {
println!("Resolving animations...");
Log::writeln("Resolving animations...".to_owned());
for animation in self.pool.iter_mut() {
animation.resolve(graph)
}
println!("Animations resolved successfully!");
Log::writeln("Animations resolved successfully!".to_owned());
}
pub fn update_animations(&mut self, dt: f32) {
+14 -12
View File
@@ -11,6 +11,7 @@ use crate::core::{
visitor::{Visitor, VisitResult, Visit}
};
use crate::sound::buffer::{Buffer, BufferKind};
use crate::utils::log::Log;
pub struct ResourceManager {
textures: Vec<Arc<Mutex<Texture>>>,
@@ -45,16 +46,16 @@ impl ResourceManager {
Ok(texture) => {
let shared_texture = Arc::new(Mutex::new(texture));
self.textures.push(shared_texture.clone());
println!("Texture {} is loaded!", path.display());
Log::writeln(format!("Texture {} is loaded!", path.display()));
Some(shared_texture)
}
Err(e) => {
println!("Unable to load texture {}! Reason {}", path.display(), e);
Log::writeln(format!("Unable to load texture {}! Reason {}", path.display(), e));
None
}
}
_ => {
println!("Unsupported texture type {}!", path.display());
Log::writeln(format!("Unsupported texture type {}!", path.display()));
None
}
}
@@ -73,17 +74,18 @@ impl ResourceManager {
"fbx" => match Model::load(path, self) {
Ok(model) => {
let model = Arc::new(Mutex::new(model));
model.lock().unwrap().self_weak_ref = Some(Arc::downgrade(&model));
self.models.push(model.clone());
println!("Model {} is loaded!", path.display());
Log::writeln(format!("Model {} is loaded!", path.display()));
Some(model)
}
Err(e) => {
println!("Unable to load model from {}! Reason {}", path.display(), e);
Log::writeln(format!("Unable to load model from {}! Reason {}", path.display(), e));
None
}
},
_ => {
println!("Unsupported model type {}!", path.display());
Log::writeln(format!("Unsupported model type {}!", path.display()));
None
}
}
@@ -103,16 +105,16 @@ impl ResourceManager {
Ok(sound_buffer) => {
let sound_buffer = Arc::new(Mutex::new(sound_buffer));
self.sound_buffers.push(sound_buffer.clone());
println!("Sound buffer {} is loaded!", path.display());
Log::writeln(format!("Sound buffer {} is loaded!", path.display()));
Some(sound_buffer)
}
Err(e) => {
println!("Unable to load sound buffer from {}! Reason {}", path.display(), e);
Log::writeln(format!("Unable to load sound buffer from {}! Reason {}", path.display(), e));
None
}
},
_ => {
println!("Unsupported sound buffer type {}!", path.display());
Log::writeln(format!("Unsupported sound buffer type {}!", path.display()));
None
}
}
@@ -185,7 +187,7 @@ impl ResourceManager {
let new_texture = match Texture::load_from_file(old_texture.path.as_path(), old_texture.kind) {
Ok(texture) => texture,
Err(e) => {
println!("Unable to reload {:?} texture! Reason: {}", old_texture.path, e);
Log::writeln(format!("Unable to reload {:?} texture! Reason: {}", old_texture.path, e));
continue;
}
};
@@ -198,7 +200,7 @@ impl ResourceManager {
let new_model = match Model::load(old_model.path.as_path(), self) {
Ok(new_model) => new_model,
Err(e) => {
println!("Unable to reload {:?} model! Reason: {}", old_model.path, e);
Log::writeln(format!("Unable to reload {:?} model! Reason: {}", old_model.path, e));
continue;
}
};
@@ -211,7 +213,7 @@ impl ResourceManager {
let new_sound_buffer = match Buffer::new(old_sound_buffer.get_source_path(), old_sound_buffer.get_kind()) {
Ok(new_sound_buffer) => new_sound_buffer,
Err(e) => {
println!("Unable to reload {:?} sound buffer! Reason: {}", old_sound_buffer.get_source_path(), e);
Log::writeln(format!("Unable to reload {:?} sound buffer! Reason: {}", old_sound_buffer.get_source_path(), e));
continue;
}
};
+2 -1
View File
@@ -21,6 +21,7 @@ use std::{
cell::RefCell,
sync::{Arc, Mutex},
};
use crate::utils::log::Log;
#[repr(C)]
pub struct Vertex {
@@ -316,7 +317,7 @@ impl DrawingContext {
let font = if let Some(font) = formatted_text.get_font() {
font
} else {
println!("Trying to draw text without font!");
Log::writeln("Trying to draw text without font!".to_owned());
return;
};
+14 -13
View File
@@ -1,21 +1,22 @@
use std::ffi::CStr;
use crate::{
core::{
math::{
vec4::Vec4,
mat4::Mat4,
vec3::Vec3,
vec2::Vec2,
},
},
renderer::{
error::RendererError,
gl::types::GLuint,
gl,
gl::types::GLint,
gl::types::GLfloat,
},
};
use crate::renderer::error::RendererError;
use crate::core::{
math::{
vec4::Vec4,
mat4::Mat4,
vec3::Vec3,
vec2::Vec2,
gl::types::GLfloat
},
utils::log::Log
};
pub struct GpuProgram {
@@ -44,13 +45,13 @@ impl GpuProgram {
buffer.set_len(log_len as usize);
gl::GetShaderInfoLog(shader, log_len, std::ptr::null_mut(), buffer.as_mut_ptr() as *mut i8);
let compilation_message = String::from_utf8_unchecked(buffer);
println!("Failed to compile {} shader: {}", name, compilation_message);
Log::writeln(format!("Failed to compile {} shader: {}", name, compilation_message));
Err(RendererError::ShaderCompilationFailed {
shader_name: name,
error_message: compilation_message,
})
} else {
println!("Shader {} compiled!", name);
Log::writeln(format!("Shader {} compiled!", name));
Ok(shader)
}
}
+19 -18
View File
@@ -51,6 +51,7 @@ use crate::{
node::Node,
},
};
use crate::utils::log::Log;
#[repr(C)]
pub struct TriangleDefinition {
@@ -371,7 +372,7 @@ impl Renderer {
self.statistics.end_frame();
if context.swap_buffers().is_err() {
println!("Failed to swap buffers!");
Log::writeln("Failed to swap buffers!".to_owned());
}
check_gl_error!();
@@ -386,17 +387,17 @@ fn check_gl_error_internal(line: u32, file: &str) {
unsafe {
let error_code = gl::GetError();
if error_code != gl::NO_ERROR {
match error_code {
gl::INVALID_ENUM => print!("GL_INVALID_ENUM"),
gl::INVALID_VALUE => print!("GL_INVALID_VALUE"),
gl::INVALID_OPERATION => print!("GL_INVALID_OPERATION"),
gl::STACK_OVERFLOW => print!("GL_STACK_OVERFLOW"),
gl::STACK_UNDERFLOW => print!("GL_STACK_UNDERFLOW"),
gl::OUT_OF_MEMORY => print!("GL_OUT_OF_MEMORY"),
_ => (),
let code = match error_code {
gl::INVALID_ENUM => "GL_INVALID_ENUM",
gl::INVALID_VALUE => "GL_INVALID_VALUE",
gl::INVALID_OPERATION => "GL_INVALID_OPERATION",
gl::STACK_OVERFLOW => "GL_STACK_OVERFLOW",
gl::STACK_UNDERFLOW => "GL_STACK_UNDERFLOW",
gl::OUT_OF_MEMORY => "GL_OUT_OF_MEMORY",
_ => "Unknown",
};
println!(" error has occurred! At line {} in file {}, stability is not guaranteed!", line, file);
Log::writeln(format!("{} error has occurred! At line {} in file {}, stability is not guaranteed!", code, line, file));
if gl::GetDebugMessageLog::is_loaded() {
let mut max_message_length = 0;
@@ -437,7 +438,7 @@ fn check_gl_error_internal(line: u32, file: &str) {
);
if message_count == 0 {
println!("Debug info is not available - run with OpenGL debug flag!");
Log::writeln("Debug info is not available - run with OpenGL debug flag!".to_owned());
}
let mut message = message_buffer.as_ptr();
@@ -482,17 +483,17 @@ fn check_gl_error_internal(line: u32, file: &str) {
let str_msg = CStr::from_ptr(message);
println!("OpenGL message\nSource: {}\nType: {}\nId: {}\nSeverity: {}\nMessage: {:?}\n",
source_str,
type_str,
id,
severity_str,
str_msg);
Log::writeln(format!("OpenGL message\nSource: {}\nType: {}\nId: {}\nSeverity: {}\nMessage: {:?}\n",
source_str,
type_str,
id,
severity_str,
str_msg));
message = message.add(len);
}
} else {
println!("Debug info is not available - glGetDebugMessageLog is not available!");
Log::writeln("Debug info is not available - glGetDebugMessageLog is not available!".to_owned());
}
}
}
+2 -1
View File
@@ -19,6 +19,7 @@ use crate::core::{
},
pool::{Pool, Handle},
};
use crate::utils::log::Log;
pub struct FbxGeometry {
pub vertices: Vec<Vec3>,
@@ -174,7 +175,7 @@ impl FbxGeometry {
effector: sub_deformer.model.into(),
}) {
// TODO: Maybe gather all weights, but then re-normalize them to 4-bones?
println!("FBX: More than 4 bones per vertex?! Excess will be discarded");
Log::writeln("FBX: More than 4 bones per vertex?! Excess will be discarded".to_owned());
}
}
}
+8 -7
View File
@@ -63,6 +63,7 @@ use crate::{
},
};
use crate::resource::fbx::geometry::FbxGeometry;
use crate::utils::log::Log;
// https://help.autodesk.com/view/FBX/2016/ENU/?guid=__cpp_ref_class_fbx_anim_curve_html
const FBX_TIME_UNIT: f64 = 1.0 / 46_186_158_000.0;
@@ -182,7 +183,7 @@ impl FbxAnimationCurve {
fn eval(&self, time: f32) -> f32 {
if self.keys.is_empty() {
println!("FBX: Trying to evaluate curve with no keys!");
Log::writeln("FBX: Trying to evaluate curve with no keys!".to_owned());
return 0.0;
}
@@ -395,7 +396,7 @@ impl FbxLight {
3 => FbxLightType::Area,
4 => FbxLightType::Volume,
_ => {
println!("FBX: Unknown light type {}, fallback to Point!", type_code);
Log::writeln(format!("FBX: Unknown light type {}, fallback to Point!", type_code));
FbxLightType::Point
}
};
@@ -1192,7 +1193,7 @@ pub fn load_to_scene(scene: &mut Scene, resource_manager: &mut ResourceManager,
let mut file = File::open(path)?;
println!("FBX: Trying to load {:?}", path);
Log::writeln(format!("FBX: Trying to load {:?}", path));
let now = Instant::now();
let is_bin = fbx_binary::is_binary(path)?;
@@ -1207,17 +1208,17 @@ pub fn load_to_scene(scene: &mut Scene, resource_manager: &mut ResourceManager,
} else {
fbx_ascii::read_ascii(&mut reader, buf_len as u64)?
};
println!("\tFBX: Parsing - {} ms", now.elapsed().as_millis());
Log::writeln(format!("\tFBX: Parsing - {} ms", now.elapsed().as_millis()));
let now = Instant::now();
fbx.prepare()?;
println!("\tFBX: DOM Prepare - {} ms", now.elapsed().as_millis());
Log::writeln(format!("\tFBX: DOM Prepare - {} ms", now.elapsed().as_millis()));
let now = Instant::now();
let result = fbx.convert(resource_manager, scene);
println!("\tFBX: Conversion - {} ms", now.elapsed().as_millis());
Log::writeln(format!("\tFBX: Conversion - {} ms", now.elapsed().as_millis()));
println!("\tFBX: {:?} loaded in {} ms", path, start_time.elapsed().as_millis());
Log::writeln(format!("\tFBX: {:?} loaded in {} ms", path, start_time.elapsed().as_millis()));
result
}
+43 -16
View File
@@ -12,14 +12,20 @@ use crate::{
core::{
pool::Handle,
visitor::{Visit, VisitResult, Visitor},
}
},
utils::log::Log
};
use std::{
path::{Path, PathBuf},
sync::{Arc, Mutex},
sync::{
Arc,
Mutex,
Weak
}
};
pub struct Model {
pub(in crate) self_weak_ref: Option<Weak<Mutex<Model>>>,
pub(in crate) path: PathBuf,
scene: Scene,
}
@@ -27,6 +33,7 @@ pub struct Model {
impl Default for Model {
fn default() -> Self {
Self {
self_weak_ref: None,
path: PathBuf::new(),
scene: Scene::new(),
}
@@ -37,6 +44,7 @@ impl Visit for Model {
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult {
visitor.enter_region(name)?;
self.self_weak_ref.visit("SelfWeakRef", visitor)?;
self.path.visit("Path", visitor)?;
visitor.leave_region()
@@ -48,11 +56,25 @@ pub struct ModelInstance {
pub animations: Vec<Handle<Animation>>,
}
fn upgrade_self_weak_ref(self_weak_ref: &Option<Weak<Mutex<Model>>>) -> Arc<Mutex<Model>> {
// This .expect will never be triggered in normal conditions because there is only
// one way to get resource - through resource manager which always returns Arc and
// sets correct self ref.
let self_weak_ref = self_weak_ref
.as_ref()
.expect("Model self weak ref cannon be None!");
self_weak_ref
.upgrade()
.expect("Model self weak ref must be valid!")
}
impl Model {
pub(in crate) fn load(path: &Path, resource_manager: &mut ResourceManager) -> Result<Model, FbxError> {
let mut scene = Scene::new();
fbx::load_to_scene(&mut scene, resource_manager, path)?;
Ok(Model {
self_weak_ref: None,
path: PathBuf::from(path),
scene,
})
@@ -60,11 +82,9 @@ impl Model {
/// Tries to instantiate model from given resource. Does not retarget available
/// animations from model to its instance. Can be helpful if you only need geometry.
pub fn instantiate_geometry(model_rc: Arc<Mutex<Model>>, dest_scene: &mut Scene) -> Handle<Node> {
let model = model_rc.lock().unwrap();
pub fn instantiate_geometry(&self, dest_scene: &mut Scene) -> Handle<Node> {
let SceneInterfaceMut { graph: dest_graph, .. } = dest_scene.interface_mut();
let SceneInterface { graph: resource_graph, .. } = model.scene.interface();
let SceneInterface { graph: resource_graph, .. } = self.scene.interface();
let root = resource_graph.copy_node(resource_graph.get_root(), dest_graph);
dest_graph.get_mut(root).base_mut().is_resource_instance = true;
@@ -74,7 +94,8 @@ impl Model {
stack.push(root);
while let Some(node_handle) = stack.pop() {
let node = dest_graph.get_mut(node_handle);
node.base_mut().resource = Some(Arc::clone(&model_rc));
node.base_mut().resource = Some(upgrade_self_weak_ref(&self.self_weak_ref));
// Continue on children.
for child_handle in node.base().get_children() {
@@ -87,11 +108,11 @@ impl Model {
/// Tries to instantiate model from given resource.
/// Returns root handle to node of model instance along with available animations
pub fn instantiate(model: Arc<Mutex<Model>>, dest_scene: &mut Scene) -> ModelInstance {
let root = Self::instantiate_geometry(model.clone(), dest_scene);
pub fn instantiate(&self, dest_scene: &mut Scene) -> ModelInstance {
let root = self.instantiate_geometry(dest_scene);
ModelInstance {
root,
animations: Self::retarget_animations(model, root, dest_scene),
animations: self.retarget_animations(root, dest_scene),
}
}
@@ -116,22 +137,20 @@ impl Model {
///
/// Most of the 3d model formats can contain only one animation, so in most cases
/// this function will return vector with only one animation.
pub fn retarget_animations(model_rc: Arc<Mutex<Model>>, root: Handle<Node>, dest_scene: &mut Scene) -> Vec<Handle<Animation>> {
let model = model_rc.lock().unwrap();
pub fn retarget_animations(&self, root: Handle<Node>, dest_scene: &mut Scene) -> Vec<Handle<Animation>> {
let mut animation_handles = Vec::new();
let SceneInterface {
animations: resource_animations,
graph: resource_graph, ..
} = model.scene.interface();
} = self.scene.interface();
for ref_anim in resource_animations.iter() {
let mut anim_copy = ref_anim.clone();
// Keep reference to resource from which this animation was taken from. This will help
// us to correctly reload keyframes for each track when we'll be loading a save file.
anim_copy.resource = Some(model_rc.clone());
anim_copy.resource = Some(upgrade_self_weak_ref(&self.self_weak_ref));
let SceneInterfaceMut {
animations: dest_animations,
@@ -146,7 +165,7 @@ impl Model {
// Find instantiated node that corresponds to node in resource
let instance_node = dest_graph.find_by_name(root, ref_node.base().get_name());
if instance_node.is_none() {
println!("Failed to retarget animation for node {}", ref_node.base().get_name())
Log::writeln(format!("Failed to retarget animation for node {}", ref_node.base().get_name()));
}
// One-to-one track mapping so there is [i] indexing.
anim_copy.get_tracks_mut()[i].set_node(instance_node);
@@ -167,4 +186,12 @@ impl Model {
let SceneInterface { graph, .. } = self.scene.interface();
graph.find_by_name_from_root(name)
}
}
impl Drop for Model {
fn drop(&mut self) {
if self.path.exists() {
Log::writeln(format!("Model resource {:?} destroyed!", self.path));
}
}
}
+13 -2
View File
@@ -1,6 +1,9 @@
use std::path::*;
use crate::core::visitor::{Visit, VisitResult, Visitor};
use crate::renderer::gpu_texture::GpuTexture;
use crate::{
renderer::gpu_texture::GpuTexture,
core::visitor::{Visit, VisitResult, Visitor},
utils::log::Log
};
use image::GenericImageView;
pub struct Texture {
@@ -89,4 +92,12 @@ impl Texture {
gpu_tex: None,
})
}
}
impl Drop for Texture {
fn drop(&mut self) {
if self.path.exists() {
Log::writeln(format!("Texture resource {:?} destroyed!", self.path));
}
}
}
+6 -5
View File
@@ -8,7 +8,8 @@ use crate::{
},
pool::{Pool, Handle},
},
renderer::gpu_texture::GpuTexture
renderer::gpu_texture::GpuTexture,
utils::log::Log
};
use std::{
cmp::Ordering,
@@ -16,8 +17,8 @@ use std::{
path::Path,
fs::File,
io::Read,
ops::Range
};
use std::ops::Range;
const ON_CURVE_POINT: u8 = 1;
const REPEAT_FLAG: u8 = 8;
@@ -378,7 +379,7 @@ fn polygons_to_scanlines(polys: &[Polygon], width: f32, height: f32, scale: f32)
});
if intersections.len() % 2 != 0 {
println!("scanline rasterization failed {:?}", intersections);
Log::writeln(format!("Font: Scanline rasterization failed {:?}", intersections));
}
/* Convert intersection points into scanlines */
@@ -764,7 +765,7 @@ impl TtfGlyph {
j += 1
} else {
j += 2;
println!("Invalid point sequence! Probably a bug in de_ttf_prepare_contours");
Log::writeln("Invalid point sequence! Probably a bug in de_ttf_prepare_contours".to_owned());
}
}
}
@@ -994,7 +995,7 @@ impl Font {
src_row += 1;
}
} else {
println!("Insufficient atlas size!");
Log::writeln("Insufficient atlas size!".to_owned());
}
}
}
+4 -3
View File
@@ -10,6 +10,7 @@ use crate::scene::{
base::AsBase,
};
use std::collections::HashMap;
use crate::utils::log::Log;
pub struct Graph {
root: Handle<Node>,
@@ -235,7 +236,7 @@ impl Graph {
}
pub(in crate) fn resolve(&mut self) {
println!("Resolving graph...");
Log::writeln("Resolving graph...".to_owned());
self.update_transforms();
// Resolve original handles. Original handle is a handle to a node in resource from which
@@ -258,7 +259,7 @@ impl Graph {
}
}
println!("Original handles resolved!");
Log::writeln("Original handles resolved!".to_owned());
// Then iterate over all scenes and resolve changes in surface data, remap bones, etc.
// This step is needed to take correct graphical data from resource, we do not store
@@ -305,7 +306,7 @@ impl Graph {
}
}
}
println!("Graph resolved successfully!");
Log::writeln("Graph resolved successfully!".to_owned());
}
pub fn update_transforms(&mut self) {
+3 -2
View File
@@ -28,6 +28,7 @@ use crate::{
animation::AnimationContainer
};
use std::collections::HashMap;
use crate::utils::log::Log;
pub struct Scene {
graph: Graph,
@@ -127,10 +128,10 @@ impl Scene {
}
pub fn resolve(&mut self) {
println!("Starting resolve...");
Log::writeln("Starting resolve...".to_owned());
self.graph.resolve();
self.animations.resolve(&self.graph);
println!("Resolve succeeded!");
Log::writeln("Resolve succeeded!".to_owned());
}
pub fn update(&mut self, aspect_ratio: f32, dt: f32) {
+4 -3
View File
@@ -7,6 +7,7 @@ use crate::core::{
},
visitor::{Visit, VisitResult, Visitor},
};
use crate::utils::log::Log;
#[derive(Clone)]
pub struct Transform {
@@ -175,7 +176,7 @@ impl Transform {
fn calculate_local_transform(&self) -> Mat4 {
let pre_rotation = Mat4::from_quat(self.pre_rotation);
let post_rotation = Mat4::from_quat(self.post_rotation).inverse().unwrap_or_else(|_| {
println!("Unable to inverse post rotation matrix! Fallback to identity matrix.");
Log::writeln("Unable to inverse post rotation matrix! Fallback to identity matrix.".to_owned());
Mat4::IDENTITY
});
let rotation = Mat4::from_quat(self.local_rotation);
@@ -184,13 +185,13 @@ impl Transform {
let rotation_offset = Mat4::translate(self.rotation_offset);
let rotation_pivot = Mat4::translate(self.rotation_pivot);
let rotation_pivot_inv = rotation_pivot.inverse().unwrap_or_else(|_| {
println!("Unable to inverse rotation pivot matrix! Fallback to identity matrix.");
Log::writeln("Unable to inverse rotation pivot matrix! Fallback to identity matrix.".to_owned());
Mat4::IDENTITY
});
let scale_offset = Mat4::translate(self.scaling_offset);
let scale_pivot = Mat4::translate(self.scaling_pivot);
let scale_pivot_inv = scale_pivot.inverse().unwrap_or_else(|_| {
println!("Unable to inverse scale pivot matrix! Fallback to identity matrix.");
Log::writeln("Unable to inverse scale pivot matrix! Fallback to identity matrix.".to_owned());
Mat4::IDENTITY
});
+24
View File
@@ -0,0 +1,24 @@
use std::{
sync::Mutex, fs::File,
io::{Write, self},
};
lazy_static! {
static ref LOG_FILE: Mutex<File> = {
Mutex::new(File::create("rg3d.log").unwrap())
};
}
pub struct Log {}
impl Log {
pub fn write(msg: String) {
let _ = io::stdout().write_all(msg.as_bytes());
let _ = LOG_FILE.lock().unwrap().write_all(msg.as_bytes());
}
pub fn writeln(mut msg: String) {
msg.push('\n');
Self::write(msg)
}
}
+4 -5
View File
@@ -1,11 +1,11 @@
pub mod astar;
pub mod log;
use std::marker::PhantomData;
use crate::{
scene::mesh::Mesh,
scene::base::AsBase
scene::{mesh::Mesh, base::AsBase},
physics::static_geometry::{StaticGeometry, StaticTriangle},
};
use crate::physics::static_geometry::{StaticGeometry, StaticTriangle};
pub struct UnsafeCollectionView<T> {
items: *const T,
@@ -85,10 +85,9 @@ pub fn mesh_to_static_geometry(mesh: &Mesh) -> StaticGeometry {
let b = global_transform.transform_vector(vertices[indices[i + 1] as usize].position);
let c = global_transform.transform_vector(vertices[indices[i + 2] as usize].position);
// Silently ignore degenerated triangles.
if let Some(triangle) = StaticTriangle::from_points(&a, &b, &c) {
triangles.push(triangle);
} else {
println!("degenerated triangle!");
}
i += 3;