Archived

This topic is now archived and is closed to further replies.

digitalfreak

who've read chap13 of LaMothe's Tricks 3D book?

Recommended Posts

You''ll probably have better luck getting comments if you paste the code of the function that trys to build temp_wall rather than refering to page numbers. Use [source] [/source] tags to enclose the code.

Share this post


Link to post
Share on other sites
temp_wall = (BSPNODEV1_PTR)malloc(sizeof(BSPNODEV1));

// set links
temp_wall->front = NULL;
temp_wall->back = NULL;
temp_wall->link = NULL;

// poly normal is the same
temp_wall->wall.normal = next_wall->wall.normal;
temp_wall->wall.nlength = next_wall->wall.nlength;

// poly color is the same
temp_wall->wall.color = next_wall->wall.color;

// poly material is the same
temp_wall->wall.mati = next_wall->wall.mati;

// poly texture is the same
temp_wall->wall.texture = next_wall->wall.texture;

// poly attributes are the same
temp_wall->wall.attr = next_wall->wall.attr;

// poly states are the same
temp_wall->wall.state = next_wall->wall.state;

temp_wall->id = next_wall->id + WALL_SPLIT_ID;

temp_wall and next_wall are of same type,so what don''t just memcpy next_wall to temp_wall instead of setting all the individual feilds of temp_wall?

Share this post


Link to post
Share on other sites
yeah, it looks like it's the same, except for the links (they are set to NULL) and the wall_id. So it's not the same . And you don't even need a memcpy.

*temp_wall = *next_wall;
temp_wall->id = next_wall->id + WALL_SPLIT_ID;
temp_wall->front = NULL;
temp_wall->back = NULL;
temp_wall->link = NULL;

It is not necessarly faster that way, and it's more prone to bugs.

For a tutorial, it is better to detail stuff like he did, to clear out any confusions.

[edited by - oliii on November 16, 2003 7:30:19 AM]

Share this post


Link to post
Share on other sites