More Bug Fixes

-=-=-=-=-=-=-

-Fixed a few bugs in Mixer, now playback of chiptunes works great :)
-Changed how visibility AABB generation from skeletons work, it's fully automatic and real-time now, generated from current skeleton pose for the frame.
-Fixed camera in 3D kinematic character demo.
This commit is contained in:
Juan Linietsky
2014-09-17 20:03:10 -03:00
parent 76aaa96d0e
commit 990f6cf50e
18 changed files with 288 additions and 33 deletions

View File

@ -369,7 +369,17 @@ void AudioMixerSW::mix_channel(Channel& c) {
AS::SampleLoopFormat loop_format=sample_manager->sample_get_loop_format(c.sample);
AS::SampleFormat format=sample_manager->sample_get_format(c.sample);
bool use_fx=fx_enabled && (c.mix.old_reverb_vol || c.mix.reverb_vol || c.mix.old_chorus_vol || c.mix.chorus_vol );
bool use_fx=false;
if (fx_enabled) {
for(int i=0;i<mix_channels;i++) {
if (c.mix.old_reverb_vol[i] || c.mix.reverb_vol[i] || c.mix.old_chorus_vol[i] || c.mix.chorus_vol[i] ) {
use_fx=true;
break;
}
}
}
/* audio data */
@ -547,8 +557,8 @@ void AudioMixerSW::mix_channel(Channel& c) {
}
c.mix.offset+=rstate.pos;
dst_buff+=target*2;
dst_buff+=target*mix_channels;
rstate.reverb_buffer+=target*mix_channels;
}
c.filter.old_coefs=c.filter.coefs;

View File

@ -502,6 +502,7 @@ void AudioServerSW::voice_set_reverb(RID p_voice, ReverbRoomType p_room_type, fl
cmd.voice=p_voice;
cmd.reverb.room=p_room_type;
cmd.reverb.send=p_reverb;
voice_rb.push_command(cmd);
}

View File

@ -146,6 +146,38 @@ void SampleManagerMallocSW::sample_set_data(RID p_sample, const DVector<uint8_t>
dst[i]=src[i];
}
switch(s->format) {
case AS::SAMPLE_FORMAT_PCM8: {
if (s->stereo) {
dst[s->length]=dst[s->length-2];
dst[s->length+1]=dst[s->length-1];
} else {
dst[s->length]=dst[s->length-1];
}
} break;
case AS::SAMPLE_FORMAT_PCM16: {
if (s->stereo) {
dst[s->length]=dst[s->length-4];
dst[s->length+1]=dst[s->length-3];
dst[s->length+2]=dst[s->length-2];
dst[s->length+3]=dst[s->length-1];
} else {
dst[s->length]=dst[s->length-2];
dst[s->length+1]=dst[s->length-1];
}
} break;
}
}
const DVector<uint8_t> SampleManagerMallocSW::sample_get_data(RID p_sample) const {

View File

@ -275,7 +275,7 @@ public:
virtual void mesh_remove_surface(RID p_mesh,int p_index)=0;
virtual int mesh_get_surface_count(RID p_mesh) const=0;
virtual AABB mesh_get_aabb(RID p_mesh) const=0;
virtual AABB mesh_get_aabb(RID p_mesh,RID p_skeleton=RID()) const=0;
virtual void mesh_set_custom_aabb(RID p_mesh,const AABB& p_aabb)=0;
virtual AABB mesh_get_custom_aabb(RID p_mesh) const=0;

View File

@ -561,7 +561,7 @@ int RasterizerDummy::mesh_get_surface_count(RID p_mesh) const {
return mesh->surfaces.size();
}
AABB RasterizerDummy::mesh_get_aabb(RID p_mesh) const {
AABB RasterizerDummy::mesh_get_aabb(RID p_mesh,RID p_skeleton) const {
Mesh *mesh = mesh_owner.get( p_mesh );
ERR_FAIL_COND_V(!mesh,AABB());

View File

@ -471,7 +471,7 @@ public:
virtual void mesh_remove_surface(RID p_mesh,int p_index);
virtual int mesh_get_surface_count(RID p_mesh) const;
virtual AABB mesh_get_aabb(RID p_mesh) const;
virtual AABB mesh_get_aabb(RID p_mesh,RID p_skeleton=RID()) const;
virtual void mesh_set_custom_aabb(RID p_mesh,const AABB& p_aabb);
virtual AABB mesh_get_custom_aabb(RID p_mesh) const;

View File

@ -888,8 +888,17 @@ int VisualServerRaster::skeleton_get_bone_count(RID p_skeleton) const {
void VisualServerRaster::skeleton_bone_set_transform(RID p_skeleton,int p_bone, const Transform& p_transform) {
VS_CHANGED;
return rasterizer->skeleton_bone_set_transform(p_skeleton,p_bone,p_transform);
rasterizer->skeleton_bone_set_transform(p_skeleton,p_bone,p_transform);
Map< RID, Set<Instance*> >::Element *E=skeleton_dependency_map.find(p_skeleton);
if (E) {
//detach skeletons
for (Set<Instance*>::Element *F=E->get().front();F;F=F->next()) {
_instance_queue_update( F->get() , true);
}
}
}
Transform VisualServerRaster::skeleton_bone_get_transform(RID p_skeleton,int p_bone) {
@ -2113,8 +2122,17 @@ void VisualServerRaster::instance_attach_skeleton(RID p_instance,RID p_skeleton)
VS_CHANGED;
Instance *instance = instance_owner.get( p_instance );
ERR_FAIL_COND( !instance );
if (instance->data.skeleton.is_valid()) {
skeleton_dependency_map[instance->data.skeleton].erase(instance);
}
instance->data.skeleton=p_skeleton;
if (instance->data.skeleton.is_valid()) {
skeleton_dependency_map[instance->data.skeleton].insert(instance);
}
}
RID VisualServerRaster::instance_get_skeleton(RID p_instance) const {
@ -2773,7 +2791,7 @@ void VisualServerRaster::_update_instance_aabb(Instance *p_instance) {
} break;
case VisualServer::INSTANCE_MESH: {
new_aabb = rasterizer->mesh_get_aabb(p_instance->base_rid);
new_aabb = rasterizer->mesh_get_aabb(p_instance->base_rid,p_instance->data.skeleton);
} break;
case VisualServer::INSTANCE_MULTIMESH: {
@ -3673,10 +3691,23 @@ void VisualServerRaster::free( RID p_rid ) {
VS_CHANGED;
if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_skeleton(p_rid) || rasterizer->is_shader(p_rid)) {
if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid)) {
rasterizer->free(p_rid);
} else if (rasterizer->is_skeleton(p_rid)) {
Map< RID, Set<Instance*> >::Element *E=skeleton_dependency_map.find(p_rid);
if (E) {
//detach skeletons
for (Set<Instance*>::Element *F=E->get().front();F;F=F->next()) {
F->get()->data.skeleton=RID();
}
skeleton_dependency_map.erase(E);
}
rasterizer->free(p_rid);
} else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) ) {
//delete the resource
@ -3763,6 +3794,8 @@ void VisualServerRaster::free( RID p_rid ) {
instance_set_scenario(p_rid,RID());
instance_geometry_set_baked_light(p_rid,RID());
instance_set_base(p_rid,RID());
if (instance->data.skeleton.is_valid())
instance_attach_skeleton(p_rid,RID());
instance_owner.free(p_rid);
memdelete(instance);

View File

@ -610,7 +610,7 @@ class VisualServerRaster : public VisualServer {
void _portal_disconnect(Instance *p_portal,bool p_cleanup=false);
void _portal_attempt_connect(Instance *p_portal);
void _dependency_queue_update(RID p_rid,bool p_update_aabb=false);
void _instance_queue_update(Instance *p_instance,bool p_update_aabb=false);
_FORCE_INLINE_ void _instance_queue_update(Instance *p_instance,bool p_update_aabb=false);
void _update_instances();
void _update_instance_aabb(Instance *p_instance);
void _update_instance(Instance *p_instance);
@ -640,7 +640,8 @@ class VisualServerRaster : public VisualServer {
mutable RID_Owner<CanvasItem> canvas_item_owner;
Map< RID, Set<RID> > instance_dependency_map;
Map< RID, Set<Instance*> > skeleton_dependency_map;
ViewportRect viewport_rect;
_FORCE_INLINE_ void _instance_draw(Instance *p_instance);