Refactor Live2D plugin and renderer for improved clarity and performance

- Updated EGL and OpenGL ES integration in gl.rs for better context management.
- Simplified error handling and logging in model.rs and plugin.rs.
- Enhanced texture handling and rendering logic in renderer.rs.
- Added a script to find Cargo configuration files for easier debugging.
- Removed unused imports and dead code to clean up the codebase.
This commit is contained in:
2026-07-07 16:47:28 +08:00
parent 86e36aa677
commit 8f2ff558eb
8 changed files with 215 additions and 334 deletions

View File

@@ -6,7 +6,6 @@
use crate::core::config::RenderType;
use crate::core::message::{Destination, Envelope, Message};
use crate::core::plugin::{Platform, Plugin, PluginContext, PluginInfo};
use crate::core::plugin_ids;
use anyhow::{Context, Result};
use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, Ordering};
@@ -103,7 +102,7 @@ impl Plugin for Live2DPlugin {
}
impl Live2DPlugin {
fn start_live2d(&mut self, config: &crate::core::config::Config) -> Result<()> {
fn start_live2d(&mut self, config: &crate::core::config::AppConfig) -> Result<()> {
// 先停止旧的渲染
self.stop_live2d();
@@ -155,8 +154,8 @@ impl Live2DPlugin {
from: "live2d".to_string(),
to: Destination::Manager,
message: Message::StateChanged {
old_state: Some("live2d_running".into()),
new_state: Some("live2d_error".into()),
old_state: "live2d_running".into(),
new_state: "live2d_error".into(),
},
});
break;
@@ -206,7 +205,7 @@ fn find_core_so() -> Result<String> {
}
/// 查找 live2d 资源根目录
fn find_live2d_base(config: &crate::core::config::Config) -> Result<PathBuf> {
fn find_live2d_base(config: &crate::core::config::AppConfig) -> Result<PathBuf> {
let candidates = [
PathBuf::from("configs/live2d"),
PathBuf::from("/home/showen/Showen/ShowenV2/configs/live2d"),
@@ -219,7 +218,3 @@ fn find_live2d_base(config: &crate::core::config::Config) -> Result<PathBuf> {
}
anyhow::bail!("找不到 configs/live2d 目录")
}
// 保留 plugin_ids 引用避免 unused
#[allow(unused_imports)]
use plugin_ids as _;