Skip to content

Instantly share code, notes, and snippets.

@XMPPwocky
XMPPwocky / gist:8689214
Created January 29, 2014 14:33
backlight
<TaskerData sr="" dvi="1" tv="4.2u3m">
<Task sr="task29">
<cdate>1390938448937</cdate>
<edate>1390951832560</edate>
<id>29</id>
<nme>Set Brightness</nme>
<pri>10</pri>
<Action sr="act0" ve="3">
<code>417</code>
<Str sr="arg0" ve="3">backlight.cfg</Str>
[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())