-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace make_float4
with Float4::expr
, etc.
#7
Conversation
I'd like to know if there's a way people want me to submit pull requests, and also what types of pull requests people are interested in accepting (eg. breaking changes)? I'm going to be using this for my application, so I'll probably have more things along these lines. |
2ecbff2
to
12c9f10
Compare
Thank you for your interest in our project. Yes I agree with your point. The current design was to keep the DSL similar to its C++ counterpart. However, as your pointed out, it may not be optimal for Rust. |
Feel free to open whatever pull request you want, even if it includes breaking changes. We welcome new ideas! |
@shiinamiyuki Hmm, I'm unsure. Part of the issue is that people wouldn't necessarily want to create a large struct with a really large series of
Although this is rather verbose. Edit: Because of the It also might make sense to replace Anyways, I think I'll try a couple of different ways of doing this. |
Also, would anybody be opposed to splitting up the |
Correct me if I'm wrong, I don't think it is possible to make
There is a
Feel free to do so. |
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b8c9ede544802d6f39e1827cf87c5318 this seems to work
compiles, but adding And hmm, I'll check the Also rust-analyzer generally just doesn't work within macros for displaying the type inference things at all; that's pretty much unfixable on this end. By the way, is there any place where you use (or intend to use) a |
Alternatively, if we're willing to make a mess of things and use nightly, it'd be possible to use |
Thank you! This looks great! One question remains: how to handle method defined on #[derive(Value, Clone, Copy)]
#[repr(C)]
pub struct Onb {
tangent: Float3,
binormal: Float3,
normal: Float3,
}
impl OnbExpr {
fn to_world(&self, v: Expr<Float3>) -> Expr<Float3> {
self.tangent() * v.x() + self.binormal() * v.y() + self.normal() * v.z()
}
}
trait ToWorld {
fn to_world(&self, v: Expr<Float3>) -> Expr<Float3>;
}
impl ToWorld for Expr<Onb> {
fn to_world(&self, v: Expr<Float3>) -> Expr<Float3> {
self.tangent() * v.x() + self.binormal() * v.y() + self.normal() * v.z()
}
} while I can use proc-macro to make it less verbose. It requires a new trait to be generated for each
It works to some extent. Sorry, I should make a correction that I originally meant it breaks rustfmt.
Maybe? The main reason behind current design is to enable |
Ah yeah, being able to add impls would be kind of important. Although I don't think that adding external trait impls might be the most important. Whatever, the current version seems to work well enough. Also, for the |
@shiinamiyuki closing because it's incorporated into #10. |
Summary of Changes:
This pull request changes all use of
make_xxxxN(...)
withXxxxN::expr(...)
.Why?
The primary reason for this is that the
make_float4
type functions are rather deceptive - the direct reading would imply that it'd make aFloat4
, but it actually makes aFloat4Expr
. Additionally, it was rather inconvenient to discover how to createFloat4Expr
s out of normal values, as theFloat4Expr::new
didn't support takingInto<F32>
types. Replacing these functions withFloat4::expr
functions fixes this issue, as well as decreases number of imports necessary (if not using a globluisa::*
import) and namespace pollution, and also cleans up the code, as themake_xxxxN
functions had to be special-coded.Concerns:
Float4Expr::new(
function remaining. I kept this as a way of buildingFloat4Expr
s without having a possibility for side effects due to theInto
type might be useful occasionally, but removing it might be helpful.