Fixes for subentity shader bindings.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1565 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
35d3a61ba2
commit
36eff7cb26
@ -528,6 +528,12 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (id<OOWeakReferenceSupport>) superShaderBindingTarget
|
||||||
|
{
|
||||||
|
return [self parentEntity];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (ShipEntity *) rootShipEntity
|
- (ShipEntity *) rootShipEntity
|
||||||
{
|
{
|
||||||
ShipEntity *parent = [self parentEntity];
|
ShipEntity *parent = [self parentEntity];
|
||||||
|
@ -33,6 +33,7 @@ MA 02110-1301, USA.
|
|||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[drawable release];
|
[drawable release];
|
||||||
|
drawable = nil;
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShipEntity* subent;
|
ShipEntity* subent;
|
||||||
quaternion_normalize(&sub_q);
|
quaternion_normalize(&sub_q);
|
||||||
|
|
||||||
subent = [UNIVERSE newShipWithName:subdesc]; // retained
|
subent = [UNIVERSE newShipWithName:subdesc]; // retained
|
||||||
if (subent == nil)
|
if (subent == nil)
|
||||||
@ -217,6 +217,7 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
|
|||||||
|
|
||||||
isShip = YES;
|
isShip = YES;
|
||||||
|
|
||||||
|
// FIXME: like_ships should have been resolved before getting here. Replace with assert for no like_ship after 1.71 release. -- Ahruman 2008-04-19
|
||||||
// check if this is based upon a different ship
|
// check if this is based upon a different ship
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -600,7 +601,7 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
|
|||||||
{
|
{
|
||||||
if (![self hasSubEntity:sub])
|
if (![self hasSubEntity:sub])
|
||||||
{
|
{
|
||||||
OOLog(@"ship.subentity.sanityCheck.failed.deatails", @"Attempt to set subentity taking damage of %@ to %@, which is not a subentity.", [self shortDescription], sub);
|
OOLog(@"ship.subentity.sanityCheck.failed.details", @"Attempt to set subentity taking damage of %@ to %@, which is not a subentity.", [self shortDescription], sub);
|
||||||
sub = nil;
|
sub = nil;
|
||||||
}
|
}
|
||||||
if (![sub isShip])
|
if (![sub isShip])
|
||||||
@ -2902,8 +2903,26 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
|
|||||||
|
|
||||||
if (subEntities == nil) subEntities = [[NSMutableArray alloc] init];
|
if (subEntities == nil) subEntities = [[NSMutableArray alloc] init];
|
||||||
sub->isSubEntity = YES;
|
sub->isSubEntity = YES;
|
||||||
[sub setOwner:self];
|
// Order matters - need consistent state in setOwner:. -- Ahruman 2008-04-20
|
||||||
[subEntities addObject:sub];
|
[subEntities addObject:sub];
|
||||||
|
[sub setOwner:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) setOwner:(Entity *)owner
|
||||||
|
{
|
||||||
|
[super setOwner:owner];
|
||||||
|
|
||||||
|
/* Reset shader binding target so that bind-to-super works.
|
||||||
|
This is necessary since we don't know about the owner in
|
||||||
|
setUpShipFromDictionary:, when the mesh is initially set up.
|
||||||
|
-- Ahruman 2008-04-19
|
||||||
|
*/
|
||||||
|
OODrawable *drawable_ = [self drawable];
|
||||||
|
if (isSubEntity)
|
||||||
|
{
|
||||||
|
[drawable_ setBindingTarget:self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ static OOMaterial *sActiveMaterial = nil;
|
|||||||
NSMutableDictionary *newConfig = nil;
|
NSMutableDictionary *newConfig = nil;
|
||||||
NSMutableDictionary *uniforms = nil;
|
NSMutableDictionary *uniforms = nil;
|
||||||
|
|
||||||
if (configuration == nil) configuration = [NSDictionary dictionary];
|
if (configuration == nil) configuration = [NSDictionary dictionary]; // If it's nil, lookups will always give 0/nil results regardless of defaultValue:.
|
||||||
ambient = [OOColor colorWithDescription:[configuration objectForKey:@"ambient"]];
|
ambient = [OOColor colorWithDescription:[configuration objectForKey:@"ambient"]];
|
||||||
diffuse = [OOColor colorWithDescription:[configuration objectForKey:@"diffuse"]];
|
diffuse = [OOColor colorWithDescription:[configuration objectForKey:@"diffuse"]];
|
||||||
specular = [OOColor colorWithDescription:[configuration objectForKey:@"specular"]];
|
specular = [OOColor colorWithDescription:[configuration objectForKey:@"specular"]];
|
||||||
@ -178,7 +178,7 @@ static OOMaterial *sActiveMaterial = nil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shininess 0 or nil/black specular colour means no specular.
|
// Shininess 0 or nil/black specular colour means no specular.
|
||||||
if (shininess == 0 || specular == nil || [specular isBlack])
|
if (shininess == 0 || [specular isBlack])
|
||||||
{
|
{
|
||||||
specular = nil;
|
specular = nil;
|
||||||
}
|
}
|
||||||
@ -257,6 +257,7 @@ static OOMaterial *sActiveMaterial = nil;
|
|||||||
return newConfig;
|
return newConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
+ (OOMaterial *)defaultShaderMaterialWithName:(NSString *)name
|
+ (OOMaterial *)defaultShaderMaterialWithName:(NSString *)name
|
||||||
forModelNamed:(NSString *)modelName
|
forModelNamed:(NSString *)modelName
|
||||||
configuration:(NSDictionary *)configuration
|
configuration:(NSDictionary *)configuration
|
||||||
@ -359,9 +360,8 @@ static OOMaterial *sActiveMaterial = nil;
|
|||||||
{
|
{
|
||||||
result = [[OOSingleTextureMaterial alloc] initWithName:name configuration:configuration];
|
result = [[OOSingleTextureMaterial alloc] initWithName:name configuration:configuration];
|
||||||
}
|
}
|
||||||
if (result == nil)
|
|
||||||
{
|
{
|
||||||
result = [[OOBasicMaterial alloc] initWithName:name];
|
result = [[OOBasicMaterial alloc] initWithName:name configuration:configuration];
|
||||||
}
|
}
|
||||||
[result autorelease];
|
[result autorelease];
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,8 @@ typedef uint16_t OOUniformConvertOptions;
|
|||||||
macros:(NSDictionary *)macros
|
macros:(NSDictionary *)macros
|
||||||
bindingTarget:(id<OOWeakReferenceSupport>)target;
|
bindingTarget:(id<OOWeakReferenceSupport>)target;
|
||||||
|
|
||||||
|
+ (id)placeholderMaterial;
|
||||||
|
|
||||||
- (id)initWithName:(NSString *)name
|
- (id)initWithName:(NSString *)name
|
||||||
configuration:(NSDictionary *)configuration
|
configuration:(NSDictionary *)configuration
|
||||||
macros:(NSDictionary *)macros
|
macros:(NSDictionary *)macros
|
||||||
|
@ -90,6 +90,23 @@ static NSString *MacrosToString(NSDictionary *macros);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME: should be handled at a higher level.
|
||||||
|
+ (id)placeholderMaterial
|
||||||
|
{
|
||||||
|
static OOBasicMaterial *placeholderMaterial = nil;
|
||||||
|
|
||||||
|
if (placeholderMaterial == nil)
|
||||||
|
{
|
||||||
|
NSDictionary *materialDefaults = nil;
|
||||||
|
|
||||||
|
materialDefaults = [ResourceManager dictionaryFromFilesNamed:@"material-defaults.plist" inFolder:@"Config" andMerge:YES];
|
||||||
|
placeholderMaterial = [[OOBasicMaterial alloc] initWithName:@"/placeholder/" configuration:[materialDefaults dictionaryForKey:@"no-textures-material"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return placeholderMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (id)initWithName:(NSString *)name
|
- (id)initWithName:(NSString *)name
|
||||||
configuration:(NSDictionary *)configuration
|
configuration:(NSDictionary *)configuration
|
||||||
macros:(NSDictionary *)macros
|
macros:(NSDictionary *)macros
|
||||||
@ -514,12 +531,9 @@ static NSString *MacrosToString(NSDictionary *macros);
|
|||||||
|
|
||||||
- (void)setBindingTarget:(id<OOWeakReferenceSupport>)target
|
- (void)setBindingTarget:(id<OOWeakReferenceSupport>)target
|
||||||
{
|
{
|
||||||
if (target != [bindingTarget weakRefUnderlyingObject])
|
[[uniforms allValues] makeObjectsPerformSelector:@selector(setBindingTarget:) withObject:target];
|
||||||
{
|
[bindingTarget release];
|
||||||
[[uniforms allValues] makeObjectsPerformSelector:@selector(setBindingTarget:) withObject:target];
|
bindingTarget = [target weakRetain];
|
||||||
[bindingTarget release];
|
|
||||||
bindingTarget = [target weakRetain];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -531,16 +545,7 @@ static NSString *MacrosToString(NSDictionary *macros);
|
|||||||
{
|
{
|
||||||
id textureDef = nil;
|
id textureDef = nil;
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
OOMaterial *material = nil;
|
OOMaterial *material = nil;
|
||||||
|
|
||||||
static OOBasicMaterial *placeholderMaterial = nil;
|
|
||||||
NSDictionary *materialDefaults = nil;
|
|
||||||
|
|
||||||
materialDefaults = [ResourceManager dictionaryFromFilesNamed:@"material-defaults.plist" inFolder:@"Config" andMerge:YES];
|
|
||||||
placeholderMaterial = [[OOBasicMaterial alloc] initWithName:@"/placeholder/" configuration:[materialDefaults dictionaryForKey:@"no-textures-material"]];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Allocate space for texture object name array
|
// Allocate space for texture object name array
|
||||||
texCount = MAX(MIN(max, [textureNames count]), 0U);
|
texCount = MAX(MIN(max, [textureNames count]), 0U);
|
||||||
@ -559,14 +564,13 @@ static NSString *MacrosToString(NSDictionary *macros);
|
|||||||
[self setUniform:[NSString stringWithFormat:@"tex%u", i] intValue:i];
|
[self setUniform:[NSString stringWithFormat:@"tex%u", i] intValue:i];
|
||||||
|
|
||||||
textureDef = [textureNames objectAtIndex:i];
|
textureDef = [textureNames objectAtIndex:i];
|
||||||
material =[[OOTexture textureWithConfiguration:textureDef] retain];
|
material =[OOTexture textureWithConfiguration:textureDef];
|
||||||
|
|
||||||
if (material !=nil)
|
if (material !=nil)
|
||||||
textures[i] = [material retain];
|
textures[i] = [material retain];
|
||||||
else{
|
else{
|
||||||
textures[i] = [placeholderMaterial retain];
|
textures[i] = [[OOShaderMaterial placeholderMaterial] retain];
|
||||||
}
|
}
|
||||||
[material autorelease];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +327,6 @@ OOINLINE BOOL ValidBindingType(OOShaderUniformType type)
|
|||||||
id<OOWeakReferenceSupport> superCandidate = nil;
|
id<OOWeakReferenceSupport> superCandidate = nil;
|
||||||
|
|
||||||
if (!isBinding) return;
|
if (!isBinding) return;
|
||||||
if (EXPECT_NOT([value.binding.object weakRefUnderlyingObject] == [(id)target weakRefUnderlyingObject])) return;
|
|
||||||
|
|
||||||
// Resolve "supertarget" if applicable
|
// Resolve "supertarget" if applicable
|
||||||
if (bindToSuper)
|
if (bindToSuper)
|
||||||
@ -342,6 +341,14 @@ OOINLINE BOOL ValidBindingType(OOShaderUniformType type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Bad optimization - we need to be able to rebind entities when their
|
||||||
|
owner changes.
|
||||||
|
-- Ahruman 2008-04-19
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
if (EXPECT_NOT([value.binding.object weakRefUnderlyingObject] == [(id)target weakRefUnderlyingObject])) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
[value.binding.object release];
|
[value.binding.object release];
|
||||||
value.binding.object = [target weakRetain];
|
value.binding.object = [target weakRetain];
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ MA 02110-1301, USA.
|
|||||||
#import "OOOpenGLExtensionManager.h"
|
#import "OOOpenGLExtensionManager.h"
|
||||||
#import "OOGraphicsResetManager.h"
|
#import "OOGraphicsResetManager.h"
|
||||||
#import "OODebugGLDrawing.h"
|
#import "OODebugGLDrawing.h"
|
||||||
|
#import "OOShaderMaterial.h"
|
||||||
|
|
||||||
|
|
||||||
// If set, collision octree depth varies depending on the size of the mesh. This seems to cause collision handling glitches at present.
|
// If set, collision octree depth varies depending on the size of the mesh. This seems to cause collision handling glitches at present.
|
||||||
@ -505,12 +506,6 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)target
|
|||||||
{
|
{
|
||||||
OOMeshMaterialCount i;
|
OOMeshMaterialCount i;
|
||||||
OOMaterial *material = nil;
|
OOMaterial *material = nil;
|
||||||
static OOBasicMaterial *placeholderMaterial = nil;
|
|
||||||
NSDictionary *materialDefaults = nil;
|
|
||||||
|
|
||||||
materialDefaults = [ResourceManager dictionaryFromFilesNamed:@"material-defaults.plist" inFolder:@"Config" andMerge:YES];
|
|
||||||
placeholderMaterial = [[OOBasicMaterial alloc] initWithName:@"/placeholder/" configuration:[materialDefaults dictionaryForKey:@"no-textures-material"]];
|
|
||||||
|
|
||||||
|
|
||||||
if (materialCount != 0)
|
if (materialCount != 0)
|
||||||
{
|
{
|
||||||
@ -524,15 +519,18 @@ shaderBindingTarget:(id<OOWeakReferenceSupport>)target
|
|||||||
bindingTarget:target
|
bindingTarget:target
|
||||||
forSmoothedMesh:isSmoothShaded];
|
forSmoothedMesh:isSmoothShaded];
|
||||||
if (material!=nil)
|
if (material!=nil)
|
||||||
|
{
|
||||||
materials[i] = [material retain];
|
materials[i] = [material retain];
|
||||||
else{
|
}
|
||||||
materials[i] = [placeholderMaterial retain];
|
else
|
||||||
|
{
|
||||||
|
materials[i] = [[OOShaderMaterial placeholderMaterial] retain];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
material = [placeholderMaterial retain];
|
material = [[OOShaderMaterial placeholderMaterial] retain];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8214,9 +8214,9 @@ static NSComparisonResult comparePrice(NSDictionary *dict1, NSDictionary *dict2,
|
|||||||
@"// System description grammar:\n\n"
|
@"// System description grammar:\n\n"
|
||||||
"digraph system_descriptions\n"
|
"digraph system_descriptions\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"\tgraph [charset=\"UTF-8\", label=\"System description grammar\", labelloc=t, labeljust=l rankdir=LR compound=true nodesep=0.02]\n"
|
"\tgraph [charset=\"UTF-8\", label=\"System description grammar\", labelloc=t, labeljust=l rankdir=LR compound=true nodesep=0.02 ranksep=1.5 concentrate=true fontname=Helvetica]\n"
|
||||||
"\tedge [arrowhead=dot sametail=1]\n"
|
"\tedge [arrowhead=dot]\n"
|
||||||
"\tnode [shape=none height=0.2]\n\t\n"];
|
"\tnode [shape=none height=0.2 width=3 fontname=Helvetica]\n\t\n"];
|
||||||
|
|
||||||
systemDescriptions = [[self descriptions] arrayForKey:@"system_description"];
|
systemDescriptions = [[self descriptions] arrayForKey:@"system_description"];
|
||||||
count = [systemDescriptions count];
|
count = [systemDescriptions count];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user