Conversation
* Now Application::build() takes a Context as a paramater instead of Config * Now RenderingProcessor::new() takes scene_name and context as parameters and calls context.renderer.add_scene() * Add num_lights method to context::renderer::Renderer * Add num_fragments method to context::renderer::Renderer * Note: if you delete a Component associated Fragment or Light won't be deleted from the frame.
* Now Fragments and Ligts corresponding to deleted components are deleted from the frame
* Add RendererConfig config struct to the processors::rendering mod, it contains the pipeline (Forward or Deferred), the shading (Flat or Shaded), and the clear color. * Now RenderingProcessor::new takes RendererConfig as a parameter and creates and sets a pipeline according to this config * Add ACTIVE_SCENE_NAME and ACTIVE_CAMERA_NAME constants to processors::rendering mod * Now RenderingProcessor::new doesn't take scene_name as a parameter instead it adds the default scene with name = ACTIVE_SCENE_NAME to the frame
* Add translation, rotation_axis, rotation_angle, and scale fields to Renderable component
* Add amethyst::engine::Config containing ContextConfig and RendererConfig * Rename amethyst_context::Config to amethyst_context::ContextConfig
* Remove State::update impl from window.rs example * Remove State::update impl from sphere.rs example
* Don't register rendering processor Components in ApplicationBuilder::new.
* Now amethyst::processor::Camera::new takes Projection as an argument instead of fov, aspect, near, and far arguments. * Add amethyst::renderer::Camera::orthographic function, which returns an orthographic projection matrix.
* Add more doc comments to processors::rendering mod
use std::ops::Deref; | ||
|
||
// Get all needed component storages and resources | ||
let context = context.lock().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder... technically, why can't this context just be an ECS resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could work, but I haven't tried it yet. Probably it would make Application
code less ugly, since it would allow removing all context.lock.unwrap()
calls in Application
impl and only &mut World
would need to be passed to State
methods instead of &mut Context
and &mut World
. Also it would simplify Processor
implementation code, since you won't have to deal with Arc<Mutex<Context>>
argument in Processor::run
anymore.
But I think it would be better to put this change in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. What about println!
calls though - would you be able to fix them in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no propper logging yet, so it is either println!
or panic!
. And I think logging also should be added in a separate PR.
if let Some(transform) = context.renderer.mut_fragment_transform(ACTIVE_SCENE_NAME, idx) { | ||
*transform = renderable.transform; | ||
} else { | ||
println!("Error: entity with id = {0} is deleted, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, error!
Got a few notes on the PR, plus the cgmath dependency seems to be screwed up (according to Travis). |
* Panic if renderer_config.pipeline or renderer_config.shading field is invalid.
|
impl RenderingProcessor { | ||
pub fn new(renderer_config: RendererConfig, context: &mut Context) -> RenderingProcessor { | ||
let clear_color = renderer_config.clear_color; | ||
let pipeline = match renderer_config.pipeline.as_str() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ni: this might be tidier if you use a single match.
match (renderer_config.pipeline.as_str(), renderer_config.shading.as_str()) {
("Forward", "Flat") => forward_flat(clear_color),
("Forward", "Shaded") => forward_shaded(clear_color),
("Deferred", "Flat") => deferred_flat(clear_color),
("Deferred", "Shaded") => deferred_shaded(clear_color),
_ => panic!("Error: Can't provide rendering pipeline requested in renderer_config, \
renderer_config.shading field is invalid.")
}
Some minor nits, but otherwise it LGTM |
@nchashch ok, considering the logging is left out for another PR, could you please rebase the code (and may be fix a few @csherratt -noted nits) for the merge? |
@nchashch This looks pretty good to me! Hopefully we can get this in a mergeable state soon. |
* Derive Copy and Clone for Light, Projection and Camera types * Derive Clone for Renderable type
Thanks @nchashch, merging now! |
Changes:
processors::rendering
module containingRenderingProcessor
type, component types such asRenderable
,Light
,Camera
, and aRendererConfig
typeexamples/renderable.rs
andexamples/pong.rs
examplesApplicationBuilder::register
method to allow registering components with the application using the following syntax:amethyst_renderer::Camera::orthographic
method, which returns an orthographic projection matrix with the given parametersamethyst_context::Config
toamethyst_context::ContextConfig
amethyst::engine::Config
, which containsContextConfig
andRendererConfig