Skip to content

Instantly share code, notes, and snippets.

use std::cmp::min;
use self::BitBufError::*;
pub struct BitBuf {
contents: Vec<u8>,
current_bit: u32,
bit_count: u32
}
#[derive(Debug, Copy, Clone, PartialEq)]
[wocky@XMPPwocky rustcrap]$ rustc -g -L . -o libplugin.so plugin.rs; rustc main.rs -L . -g -C prefer-dynamic
[wocky@XMPPwocky rustcrap]$ ./main
Got: 1024
Segmentation fault (core dumped)
fn gameloop() {
use shared::component::ComponentStore;
let mut entities = ComponentStore::new();
let mut renderables = ComponentStore::new();
let mut physicals = ComponentStore::new();
let ent = EntityComponent::new(&mut entities, Point3::new(0.0, 0.01, 0.0), Rotation3::from_euler(cgmath::rad(0.), cgmath::rad(0.), cgmath::rad(0.)));
renderables.add(RenderComponent { entity: ent });
pub fn apply_update<Component, MarshalledComponent, UpdatesIter: Iterator<ComponentUpdate<MarshalledComponent>>>(
mut updates: UpdatesIter,
hdict: &mut HashMap<RawComponentHandle, ComponentHandle<Component>>,
store: &mut ComponentStore<Component>,
unmarshaller: |MarshalledComponent, ComponentHandle<Component>| -> Component,
inserter: |MarshalledComponent, &mut ComponentStore<Component>| -> ComponentHandle<Component>)
{
for update in updates {
match update.data {
Change(comp) => match hdict.find_copy(&update.target) {
pub fn apply_update<Component, MarshalledComponent, UpdatesIter: Iterator<ComponentUpdate<MarshalledComponent>>>(
mut updates: UpdatesIter,
hdict: &mut HashMap<RawComponentHandle, ComponentHandle<Component>>,
store: &mut ComponentStore<Component>,
unmarshaller: |MarshalledComponent, ComponentHandle<Component>| -> Component,
inserter: |MarshalledComponent, &mut ComponentStore<Component>| -> ComponentHandle<Component>)
{
for update in updates {
match update.data {
Change(comp) => match hdict.find_copy(&update.target) {
@XMPPwocky
XMPPwocky / Client
Last active August 29, 2015 14:08
architectuuureeeeeee
For the world: BSP for collision
For the world: BSP of visibility regions
For each visleaf: Mesh for rendering
For each player: From the network: position, rotation, animation information, and history of that for interpolation
For local player: Predicted locally: position, rotation, animation information
For each player: AABB
struct Base<T: Derived> {
x: u32,
derived: T
}
trait Derived {
fn foo_the_bars(&mut self, base: &mut Base) -> u32;
}
broadphase: ncollide::broad_phase::DBVTBroadPhase<
f32,
na::Pnt3<f32>,
na::Vec3<f32>,
Box<Shape>,
ncollide::bounding_volume::AABB<na::Pnt3<f32>>,
ncollide::broad_phase::NoIdDispatcher<ncollide::bounding_volume::AABB<na::Pnt3<f32>>>,
>
#[test]
fn foo() {
let mut world = World::new();
let b1 = Rc::new(RefCell::new(Body::Static {
shape: box ncollide::shape::Ball::new(1.0),
transform: na::Iso3::new(na::zero(), na::zero())
}));
world.add(b1.clone());
let mut world = World::new();
let b1 = Shared::new(Body::Static {
shape: box ncollide::shape::Ball::new(0.5),
transform: na::Iso3::new(na::zero(), na::zero())
});
world.add(b1.clone());
let b2 = Shared::new(Body::Static {
shape: box ncollide::shape::Ball::new(0.5),
transform: na::Iso3::new(na::Vec3::new(0.0, 10.0, 0.0), na::zero())