[Bf-committers] Particle system / Material choice / implementation of do_versions : problem with preview.blend

trouble daemon troubledaemon at gmail.com
Sat Mar 30 17:42:28 CET 2013


Hi,

While I don't know the how the blender devs usually tackle this problem, I
can say that in many other areas of computers, this is pretty common
practice.

Some examples where this is done would be web forms and databases. In web
forms, you might pass a list of items with some numerical, or abbreviated
form of a value, along with a textual representation. eg., "1" -> "Canada",
"2" -> "USA", etc.

In databases, this value would be the primary key. While it isn't unheard
of to use the string value itself (natural key) as a primary key, many
schema use a numeric auto-increment value, which iirc is called a surrogate
key when used in this number->name fashion, if only since many libraries
and frameworks that work with databases depend on only numeric values for
easy mapping for their ORM. See
http://en.wikipedia.org/wiki/Surrogate_keyfor more.

In the case of blender, sticking to using a number only would avoid
breaking any existing files (since it would use the current value still),
and would be smaller to store a number versus storing text, in addition to
avoiding a do_versions requirement. I guess I am wondering why a if up of
the current name by passing the material slot number to a function is hard
to do in blender?


Dan


On Sat, Mar 30, 2013 at 12:11 PM, Julien Duroure
<julien.duroure at gmail.com>wrote:

> Hello,
>
> I don't think it a good idea to display material, and to store only
> integer. I think ( but I am not a regular blender dev ) it must be
> consistent between what we see and what we store.
> That's why In my current implementation, I replace Integer "Material Index"
> by a material' pointer.
>
> In do_versions, I only have to retrieve material corresponding to each
> index, using give_current_material
> But I have the problem I explain in my previous email...
>
> Regards,
>
> Julien
>
> On Sat, Mar 30, 2013 at 2:46 PM, trouble daemon <troubledaemon at gmail.com
> >wrote:
>
> > Hi!
> >
> > First of all, I love the idea of finally replacing silly numbers with
> > actual names of materials! Surely this has been a feature request of
> > everyone that uses blender since they were added :)
> >
> > But what I question is why you would need a do_versions? Would it not
> make
> > more sense to leave the underlying value as a number, but just change the
> > display to be a looked up value from some py dict or enum or something?
> > This would allow it to "just work".
> >
> > Anyways, forgive my ignorance as I am not aware of what the typical
> > approach to this would be in blender. And thanks again for working on
> this
> > type of number -> string mapping! :)
> >
> >
> > Dan
> >
> >
> > On Sat, Mar 30, 2013 at 8:46 AM, Julien Duroure <
> julien.duroure at gmail.com
> > >wrote:
> >
> > > Hi all,
> > >
> > > I implemented some code to replace, in particle render section, the
> > > material index ( 1, 2 or 3 for example ), by a direct material choice (
> > > Material, Material.001, etc...)
> > >
> > > Code is now OK, but I am currenly working on do_versions, to be able to
> > > open old files with this new "feature".
> > >
> > > I try to implement this kind of code : http://pastebin.com/Czy3rfqZ
> > > But I have a segfault when access on part->omat.
> > > It seems to be linked to preview.blend objects.
> > > GDB said that psys->part adresse can't be access.
> > >
> > > I don't know how preview exactly works : is there someome can explain
> me
> > > why I have this problem and how to correct it ?
> > >
> > > Thanks & Regards,
> > >
> > > Julien
> > > _______________________________________________
> > > Bf-committers mailing list
> > > Bf-committers at blender.org
> > > http://lists.blender.org/mailman/listinfo/bf-committers
> > >
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-committers
> >
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list