2012/6/5 Riccardo Corsi <
riccard...@kairos3d.it>:
> Hi Martin,
>
> I'd like to share some thoughts:
>
> 1. Changing the osg::VecX into a C array would require a cast between the
> two, not to copy values around. Even though the memory footprint should be
> the same, are you 100% sure that we can make that assumption for all the
> platforms?
>
Well, at the moment the return value of VecXProperty::Get() is
actually passed by copy, so performance could be improved by returning
a const reference.
http://en.wikipedia.org/wiki/C%2B%2B_classes#cite_note-C.2B.2B03_9.2.2F17-7
A pointer to a POD-struct object, suitably converted using a
reinterpret cast, points to its initial member and vice versa,
implying that there is no padding at the beginning of a POD-struct.[8]
So I believe reinterpret_casting between float[3] and osg::Vec3 should
be well.defined. I wrote those tests, they work for me:
TEST(ReinterpretCastsV3f)
{
float values[3] = {3.0f, -234.234f, 0.0f};
const osg::Vec3f& casted = reinterpret_cast<const osg::Vec3f&>(values);
CHECK_EQUAL(values[0], casted[0]);
CHECK_EQUAL(values[1], casted[1]);
CHECK_EQUAL(values[2], casted[2]);
}
TEST(ReinterpretCastsV4d)
{
double values[4] = {3.0f, -234.234f, 0.0f, 3254325.235325};
const osg::Vec4d& casted = reinterpret_cast<const osg::Vec4d&>(values);
CHECK_EQUAL(values[0], casted[0]);
CHECK_EQUAL(values[1], casted[1]);
CHECK_EQUAL(values[2], casted[2]);
CHECK_EQUAL(values[3], casted[3]);
}
TEST(ReinterpretCastsQuat)
{
double values[4] = {3.0f, -234.234f, 0.0f, 3254325.235325};
const osg::Quat& casted = reinterpret_cast<const osg::Quat&>(values);
CHECK_EQUAL(values[0], casted[0]);
CHECK_EQUAL(values[1], casted[1]);
CHECK_EQUAL(values[2], casted[2]);
CHECK_EQUAL(values[3], casted[3]);
}
> 2. Regarding the OnPropertyChanged(), what you suggest is basically that the
> method will disappear and instead a Dynamic Prop should be used whenever
> users needs to be notified about a prop change. And thus implement any
> reaction in the Get/Set functor instead of deriving OnPropertyChanged(). Is
> that correct? What about the Finished() method, will it remain there?
Correct. I am not yet sure if this will work, especially for
JavaScript properties.
The Finished() method has to stay so that the component can react to
changes in multple interdepenent properties.
> 3. This point is not about the changes you mention here, but about
> PropertyContainer now deriving from GroupProperty - sorry I didn't react
> before.
> I understand that it helped to remove a lot of duplicated code, but
> conceptually I don't like very much the fact that every container ISA
> Property itself. In particular a Component is now a Property as well, even
> though it represents something quite different.
> What do you think about this?
>
Hmm yes, a has-a relation would maybe be better than an is-a relation.
If you want you can try changing it, you will probably have to forward
most methods of GroupProperty through Component
Cheers,
Martin