Skip to content

Commit 3f10610

Browse files
committed
Tinkering
1 parent 234e516 commit 3f10610

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ sdl = { package = "surreal-backend-sdl", path = "./backends/sdl", optional = tru
4141
audio = { package = "surreal-audio", path = "./modules/audio", optional = true }
4242
graphics = { package = "surreal-graphics", path = "./modules/graphics", optional = true }
4343
input = { package = "surreal-input", path = "./modules/input", optional = true }
44+
scripting = { package = "surreal-scripting", path = "./modules/scripting", optional = true }
4445

4546
[[example]]
4647
name = "hello-world"

modules/graphics/src/meshes.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Meshes abstract over vertex and index data on the GPU as well, and
44
//! provide utilities for constructing data from pieces.
55
6-
use std::{cell::RefCell, rc::Rc};
6+
use std::sync::{Arc, Mutex};
77

88
use common::{vec2, Size, Vec2, Vec3};
99
pub use macros::Vertex;
@@ -124,7 +124,7 @@ impl Vertex3 {
124124
/// for rendering at any time, provided a valid [`Material`] is available.
125125
#[derive(Clone)]
126126
pub struct Mesh<V> {
127-
state: Rc<RefCell<MeshState<V>>>,
127+
state: Arc<Mutex<MeshState<V>>>,
128128
}
129129

130130
/// The internal state for a mesh.
@@ -148,7 +148,7 @@ impl<V: Vertex> Mesh<V> {
148148
let indices = Buffer::new(BufferKind::Index, usage).map_err(|_| MeshError::FailedToCreate)?;
149149

150150
Ok(Self {
151-
state: Rc::new(RefCell::new(MeshState {
151+
state: Arc::new(Mutex::new(MeshState {
152152
id: graphics().mesh_create(vertices.id(), indices.id(), V::DESCRIPTORS)?,
153153
vertices,
154154
indices,
@@ -181,22 +181,22 @@ impl<V: Vertex> Mesh<V> {
181181

182182
/// Returns the identifier of this mesh.
183183
pub fn id(&self) -> MeshId {
184-
self.state.borrow().id
184+
self.state.lock().unwrap().id
185185
}
186186

187187
/// Returns the number of vertices in the mesh.
188188
pub fn vertices(&self) -> usize {
189-
self.state.borrow().vertices.len()
189+
self.state.lock().unwrap().vertices.len()
190190
}
191191

192192
/// Returns the number of indices in the mesh.
193193
pub fn indices(&self) -> usize {
194-
self.state.borrow().indices.len()
194+
self.state.lock().unwrap().indices.len()
195195
}
196196

197197
/// Draws this mesh with the given material and topology.
198198
pub fn draw(&self, material: &Material, topology: PrimitiveTopology) {
199-
let state = self.state.borrow();
199+
let state = self.state.lock().unwrap();
200200

201201
self.draw_sub(material, topology, state.vertices.len(), state.indices.len());
202202
}
@@ -205,7 +205,7 @@ impl<V: Vertex> Mesh<V> {
205205
pub fn draw_sub(&self, material: &Material, topology: PrimitiveTopology, vertex_count: usize, index_count: usize) {
206206
material.bind();
207207

208-
let state = self.state.borrow();
208+
let state = self.state.lock().unwrap();
209209

210210
graphics()
211211
.mesh_draw(state.id, topology, vertex_count, index_count)
@@ -216,7 +216,7 @@ impl<V: Vertex> Mesh<V> {
216216

217217
/// Acquires mutable write access the mesh buffers.
218218
pub fn with_buffers(&mut self, body: impl FnOnce(&mut Buffer<V>, &mut Buffer<Index>)) {
219-
let state = &mut self.state.borrow_mut();
219+
let state = &mut self.state.lock().unwrap();
220220
let (vertices, indices) = state.borrow_buffers_mut();
221221

222222
body(vertices, indices);

modules/scripting/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
//! Scripting engine for Surreal
2+
3+
pub trait ScriptBackend {}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub extern crate editor;
2222
pub extern crate graphics;
2323
#[cfg(feature = "input")]
2424
pub extern crate input;
25+
#[cfg(feature = "scripting")]
26+
pub extern crate scripting;
2527

2628
pub mod backends {
2729
#[cfg(feature = "sdl")]

0 commit comments

Comments
 (0)