On Thu, Jun 23, 2016 at 1:04 PM, Param Hanji <param.catchch...@gmail.com>
wrote:

>
>
> On Wed, Jun 22, 2016 at 7:43 PM Vasco Alexandre da Silva Costa <
> vasco.co...@gmail.com> wrote:
>
>> On Wed, Jun 22, 2016 at 2:36 PM, Param Hanji <param.catchch...@gmail.com>
>> wrote:
>>
>>> - in copy_to_cpu if gpu_seg->seg_sti is zero the cpu_seg->seg_stp->st_id
>>>> will be uninitialized. worse. you are writing to an uninitialized pointer.
>>>> what I think you want to do is lookup the seg_stp pointer based on the
>>>> seg_sti id and use that to initialize the cpu->seg_stp pointer field.
>>>>
>>>
>>> I can't find the relevant code that initializes the seg_stp. The rt_shot
>>> methods in primitive files simply copy the passed soltab pointer. In
>>> shootray(), this is obtained from a cutter, which is a union for space
>>> partitioning.
>>>
>>> My understanding is that the structure soltab keeps track of all the
>>> relevant information pertaining to a solid (primitive). On the GPU side,
>>> only ID (seg_sti) is used. How do I initialize the cpu->seg_stp field?
>>>
>>
>> One way to do it would be to store the soltab pointers in an array
>> indexed by the integer solid 'id'. You should be able to do this in
>> src/librt/primitives/primitive_util.c:clt_db_store. It's iterating through
>> a cutter's solids and the current solid pointer is stored in the variable
>> 'stp'.
>>
>> I realized I can loop through all the all the solids using the macros
> defined in soltab.h like this
>
>     RT_VISIT_ALL_SOLTABS_START(stp, a->a_rt_i) {
>         if (stp->st_id == (int)gpu_seg->seg_sti)
>             cpu_seg->seg_stp = stp;
>     } RT_VISIT_ALL_SOLTABS_END
>
> When I ran this I noticed that some of the GPU segments don't have seg_sti
> initialized (value 0). How can I process these?
>

This won't work. You see the st_id doesn't define a unique per solid
identifier. It's the solid class identifier.
So let's say you have two ellipsoids in the scene. Both solids will have an
st_id of ID_ELL. Sorry about that I induced you in error a couple of emails
back.

Also the GPU side seg_sti doesn't have the same meaning at all. It's a
unique solid id. In the soltabs list. So '0' would be the first valid solid
in the soltabs list. So your code should work like this:

unsigned int i=0;
    RT_VISIT_ALL_SOLTABS_START(stp, a->a_rt_i) {
        /* Ignore "dead" solids in the list.  (They failed prep) */
        if (stp->st_aradius <= 0) continue;
        /* Infinite solids make the BVH construction explode. */
        if (stp->st_aradius >= INFINITY) continue;

        if (i == gpu_seg->seg_sti) {
            cpu_seg->seg_stp = stp;
            break;
        }
        i++;
    } RT_VISIT_ALL_SOLTABS_END


-- 
Vasco Alexandre da Silva Costa
PhD in Computer Engineering (Computer Graphics)
Instituto Superior Técnico/University of Lisbon, Portugal
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to